Here's summaries on the key points in his tutorials:
Tutorial 1
1. Vim is a modal editor. There are a lot of modes:
- Normal mode: Press ESC or CRTL+[
- Insert mode: Press i in normal mode
- Command mode: Press : in normal mode
- Visual mode: Press v in normal mode
- Append mode: Press a in normal mode
- :e filename : open a file whose name is "filename"
- :e! : reopen the current file; all changes are lost
- :w : save the current file
- :w filename : save the current file as filename; primarily used when a file is to be saved for the first time
4. To move around in a most efficient way use "h", "j", "k", "l" as left, down, up, right respectively.
5. Move more quickly:
- ^: Home; move to the head of the current line
- $: End; move to the end of the current line
- CRTL + D: Pagedown
- CRTL + U: Pageup
- w: Move to the next word
- b: Move to the previous word
1. Move the beginning or the end of a document:
- gg: Move to the beginning of the document
- GG: Move to the end of the document
- XGG: Move the Xth line of the document, like 10G(move to the 10th line)
- yy: Copy the whole line
- yw: Copy the next word
- y$: Copy till the end of line
- x: cut the current letter
- dd: Delete the whole line
- dw: Delete the next word
- p: Paste the text that just deleted or yanked
- cw: Change the next word
- cb: Change the previous word
- c$: Change till the end of line
- ct
: Change till , like ctD(change till the first occurence of letter D)
Tutorial 3
1. Search
- :/<Pattern>
: Search forward according to the <Pattern> - :?<Pattern>
: Search backward - n: Go to the next occurence <Pattern>
- p or N: Go to the previous occurence <Pattern>
- f
<Symbol> : Find the first occurence of <Symbol> - ; : Go to the next occurence of the <Symbol>
- , : Go to the previous occurence of the <Symbol>
- %s/
<TargetString>/ <SubstituteBy>/g : % means the range is the whole text, % means substitution, is what we are looking for, is the substitution for . Don't forget the /g. For example, %s/Good/Bad/g will substitute all ocurrences of "Good" by "Bad" in the whole document.
- # : Go to the previous occurence of the word under cursor
- * : Go to the next occurence of the word under cursor
没有评论:
发表评论