I think it won't be my thing but it is nice to know the basics to be able to edit texts files one any pc.
These basics you learn in vimtutor and more, by doing not memorizing.
NOTE: Remember that you should be learning by doing, not memorization.
:q! quit vim withhout changing
:wq saving edited text, also ZZ
editing text -insert: i brings the insert mode; Esc to stop insert.
The letter position after the cursor highlighted letter is inserted
editing text append: Capital A moves the inserted text to end of line.
p put line below this line (moving lines)
ctrl+o opens new line below the present one: ctrl+O above.
stop editing text Esc
u undo last edit; U undo all editing on line
Ctrl+r redo command
moving cursor: h j k l cursor left down up right
motion: w- until the start of the next word, EXCLUDING its first character.
e - to the end of the current word, INCLUDING the last character.
$ - to the end of the line, INCLUDING the last character.
0 move to begin of the line
2w two words forward first letter
2e two words forward last letter
moving in text: Ctr+G is show on what line you are in text
G move to end of text; gg move to start of text;486G move to line 486
ctrl+o go back to last position
ctrl+i go forward again
ctrl+l moving cursor left while in insert mode
% find matching parenthesis
search forward: /searchword
search backwards: ?searchword
n search again; N search again other direction
delete letter: x cursor on letter is delete
delete word: dw delete word
delete line: dd
delete motions:
dw - until the start of the next word, EXCLUDING its first character.
de - to the end of the current word, INCLUDING the last character.
d$ - to the end of the line, INCLUDING the last character.
replace letter: rx to replace the character at the cursor with x: Capital R to replace more than one character, stopped by Esc.
replace word: ce deletes word and activates insert mode (ce- change till end word; remember motion operators)
replace line: c$
v visual mode being able to select text
y yank+copy text to buffer yw yank word
p paste selected text
:wwrite file
Substitute
s one character; S rest of line
To substitute new for the first old in a line type :s/old/new
To substitute new for all 'old's on a line type :s/old/new/g
To substitute phrases between two line #'s type :#,#s/old/new/g
To substitute all occurrences in the file type :%s/old/new/g
To ask for confirmation each time add 'c' :%s/old/new/gc
" Auto-completing words
In insert mode, type the beginning characters of a word that has appeared in
the file before.
Ctrl-N " auto-complete with next match
Ctrl-P " auto-complete with prev match
Nice links, reference card and book:
Vim is a beautiful tool - Eric Wendelin's Blog
Gentoo Wiki Archives - Vim
Reference Card Another one both PDF's
Vim Tutorial Book by Molenaar
No comments:
Post a Comment