- 1. Match all occurrences of the word under the cursor
*
- 2. Replace a word with another word
:%s/word/newword/gc
g: global , c: confirm
- 3. Visually select a word
i / a (inside / outside)
viw ( Selects only the word itself )
vaw ( Selects the word plus surrounding whitespace )
vi( ( Visual texts inside () )
ci" ( change around double "" )
va( ( Visual () )
va" ( Visual "" )
- 4. Show all registers
:reg
- 5. Paste from a specific register
"<reg number>p
- 6. Yank (copy) the current line to the system clipboard ( + : clipboard system register)
"+yy
- 7. Yank the current file name to the system clipboard
:let @+=@% , then go to any file and ctrl+v
assigns the contents of the % register (current file name) to the + register (system clipboard).
- 8. Copy the absolute path of the current file
:let @+ = expand('%:p')
- 9. Record and play a macro
q<any character><action>q
@h
- 10. :normal Mode
When you select lines in Visual mode and press :
:'<,'>
:'<,'>normal <keys><text>
Keys:
I : go to start of lines and enter Insert mode
A : go to end of lines and append a new text
hello
world
goodbye
:'<,'>normal Ivar + space
var hello
var world
var goodbye
hello
world
goodbye
:'<,'>normal A ;
hello ;
world ;
goodbye ;
- 11. Number
Ctrl-a : increment number
Ctrl-x : decrement number
value = 2
list.get(0);
list.get(0);
list.get(0);
list.get(0);
list.get(0);
list.get(0);
select all lines + g + Ctrl-a
list.get(1);
list.get(2);
list.get(3);
list.get(4);
list.get(5);
list.get(6);
- 12. Switching Selection
select lines + o
select lines + O
- 13. w / W
letters, digits, or underscores / whitespace characters
Lis:st.get(0) hello world


Top comments (0)