VI Editor.org -
VI Editor FAQ -
VI Lovers home page -
VIM (Vi IMproved) -
VIM for Psion 5
Cream for GViM - Windows version of GViM - taking the bitterness out of ViM.
ViM eBook Online
Vim Doc
Vi Cheat sheet
VI Quick Ref.
Writing and Exiting
- :w
- writes changes to file
- :wq
- writes changes to file and quits
- :q
- quits without writing
- :e!
- discard changes and re-edit
- :w filename
- write to filename
- :w! filename
- overwrite filename
Moving around
- [CTRL]f
- forward screenful
- [CTRL]b
- backward screenful
- [CTRL]d
- down 1/2 screen
- [CTRL]u
- up 1/2 screen
- nG
- go to line n; default is end of file
- /pattern[RET]
- search forward for pattern
- ?pattern[RET]
- search backward for pattern
- n
- repeat last / or ? search
Adjusting the screen
- [CTRL]l
- redraw screen
- z[RET]
- redraw screen, current line at top
- z.
- redraw screen, current line at middle
- z-
- redraw screen, current line at bottom
Positioning the cursor
- H
- to top of screen
- M
- to middle of screen
- L
- to bottom of screen
- h
- left, a character at a time
- j
- down, a line at a time
- k
- up, a line at a time
- l
- right, a character at a time
- 0
- to the beginning of the line
- $
- to the end of the line
- w
- to the beginning of the next word
- e
- to the end of the next word
- b
- back one word
Inserting text
- i
- insert at cursor
- a
- append after cursor
- I
- insert at beginning of line
- A
- append at end of line
- O
- open line above cursor and insert
- o
- open line below and insert
- [ESC]
- exits insert mode; puts you back in command mode
Inserting and replacing text
- xp
- transpose characters
- rx
- replace character at cursor with x
- R
- replace characters to end of line; use [ESC] after
- cw
- change word; use [ESC] after
- cnw
- change n words; use [ESC] after
- C
- change rest of line; use [ESC] after
- [SHIFT]~
- converts case of letters at cursor
Deleting text
- x
- delete character
- dw
- delete word
- dnw
- delete n words
- dd
- delete line
- ndd
- delete n lines
- d$
- delete from cursor to end of line
Copying text
- Y
- yank (put copy of) line to buffer, yy does the same
- nY
- yank n lines to buffer, nyy does the same
- P
- put buffer contents in text before cursor
- p
- put buffer contents in text after cursor
NOTE: Buffer contains last yank or delete.
Copying text to another file
- ma
- mark position "a" in file
- mb
- mark position "b" in file
- :'a,'b w filename
- copy text from position "a" to position "b" to filename
Inserting text from another file
- :r filename
- inserts all text from filename
Searching and replacing text
- /pattern
- search forward for pattern
- ?pattern
- search backward for pattern
- n
- repeat last / or ? search
- //[RET]
- repeat last / or ? search
- N
- reverse last / or ? search
- :g/string1/s//string2/g
- global search and replace of string1 with string2
- :g/string1/s//string2/gc
- search and replace with confirmation [y][RET] = replace, [RET] = no
Undoing and redoing changes
- u
- undo last change
- U
- undo all changes on the current line
- .
- repeat last change
- [CTRL]R
- redo last undo
Misc
- :set list
- view control characters
- :set nolist
- turn 'view control characters' off
[Back to HomePage]
Last modified 17/1/2005
|