-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimtutor_lesson4
29 lines (26 loc) · 1.84 KB
/
vimtutor_lesson4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#Cursor location and file status:
---------------------------------
-"ctrl+g" shows file name, file status, line number, line percentage and column number of the cursor.
-"G(shift+g)" takes the cursor to the bottom of the file.
-"gg" brings it back to where text begins.
-"<line number>+shift+g" takes the cursor to specified line.
#Search command:
----------------
-"/<search text>" searches for the specified text in the document after the current cursor location.
-"n" takes the cursor to the next occurance of that phrase.
-"N" takes the cursor to the previous occurance of that phrase. "N" basically searches in the reverse direction of "n".
-"?<search text>" searches for the occurance of the specified text before the current cursor location.
-"ctrl+o" takes the cursor to its previous position by one step at a time.
#Matching parenthesis search:
-----------------------------
-Pressing "%" while the cursor is on a bracket takes the cursor to its matching bracket. Pressing "%" while the cursor in on
a opening parenthesis, takes the cursor to its matching closing parenthesis. Pressing "%" while the cursor is on a "}" takes
the cursor to its matching opening curly brace "{".
-This is a very handy tool to debug an unmatched bracket.
#The Substitute command:
------------------------
-":s/<old>/<new>/g" replaces all the occurances of "old" with "new" in the current sentence.
-Note: ":s/<old>/<new>" replaces only the first occurance of "old" with "new". Adding "g" tells VIM to substitute globally in the sentence.
-":#,#s/<old>/<new>/g" replaces all the occureances of "old" with "new" within the line numbers specified by #.
-":%s/<old>/<new>/g" replaces all the occurances of "old" with "new" in the whole document.
-":%s/<old>/<new>/gc" performs the same action, but promts the user on whether to replace each occurance or not.