Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- View current file
- ctrl+g ; relative to vim working dir
- 1 ctrl+g ; full path
- Word deletion
- daw ; delete current word
- caw ; delete current word/move to insert mode
- Move line number to line number -/+ indicate relative line movements
- :-2m-4 ; move line located 2 lines above current line to 4 above current line
- :+2m+7 ; move line located 2 lines below current line to 7 below current line
- Move a range of lines
- :-4,.m0 ; move range of lines 4 above current - current to the first line of file
- Move a range of lines to 5 lines above current
- :-6,-4m+5
- Delete lines relative to line number
- :-4,-7d ; delete lines 4 to 7 above current relative line
- Same commands work with yanking. Just use 'y' instead of 'd'
- ----------
- dt<char> ; delete until character
- dT<char> ; delete backwards until character
- df<char> ; delete until including character
- dF<char> ; delete backwards until including character
- ----------
- vim surround
- cs"' ; changes "Hello" to 'hello'
- ds> ; changes <remove> to remove - deletes surrounding
- ds{ds) ; chain surround deletion ({ Hello } world!) - Hello world!
- ysiw] ; changes word to [word]
- ysiw[ ; changes word to [ word ]
- yss) ; (wrap the entire line in brackts)
- ci' -- change inside quote, for changing 'quoted' values.
- di' -- delete inside quote
- ---------
- ( and ) quickly move backward and forward one sentence.
- { and } quickly move you up and down paragraphs.
- HML will jump your cursor to high, medium, and low parts of the screen.
- zt, zz, and zb will similarly move your current line to the area of the screen.
- I - move to beginning of line and enter insert mode
- :set incsearch will set incremental search
- :set hlsearch will set highlight search
- /string will search forward for the next occurrence
- ?string will search backward for the previous occurrence
- n moved forward one match, N moves backward one match
- (reversed if searching .. in reverse)
- ggn will jump to the first match, or GN to jump to the last
- * searches forward for the string under the cursor
- # searches forward for the string under the cursor
- :noh will unhighlight the search
- & repeats the last search-and-replace
- Commenting - Nerd commenter
- ----------
- ,cs comment line
- ,cu uncomment line
- Unit of Work
- ------------
- Changing to insert mode, making edits, and switching back to command mode is
- considered one unit of work in vim. The "dot operator" (.) replays the previous
- unit of work. This can make it to quickly repeat similar edits, like when you
- make an edit and then realize you have to apply the edit a few more times.
- Macros
- ------
- Ever hit the wrong key and get stuck in `recording` mode? This is that.
- qq -- start recording
- q -- finish recording
- @q -- playback macro
- 10@q -- playback macro 10 times
- * search forward for word under cursor; # search backward for word under cursor
- fx forward to next character x; Fx backward to previous character x
- ; move again to same character in same direction; , move again to same character in opposite direction
- ------
- ctrl+n - scroll autocomplete
Add Comment
Please, Sign In to add comment