TONS of cool tips: https://www.cs.oberlin.edu/~kuperman/help/vim/windows.html
-
Use
]pto paste into the correct location. VIM will automatically indent to the same position as the line the cursor starts on -
When pasting from outside the document, can yank the lines back out, then use
]pto repaste them into place
-
Use double-quote and any lower-case letter, then yank or delete
-
E.g.
"aywto save the current word into the register a -
To paste, use double-quote and the letter, then paste
-
NOTE: Can use the upper-case letter to append (repeatedly, if needed) to what’s already saved in that register
-
Use
:regto view the contents of all registers (useful when working with lots of bits of text) -
One guide says can access the Windows or Linux system clipboard with
"+or"*, but I couldn’t get them to work
-
(In command mode)
-
q# To start recording -
The letter to assign the macro to, i.e.
a -
Perform the series of actions
-
q# To stop recording
-
(In command mode)
-
@ + the letter the macros is stored under, i.e.
@a
-
(In last line mode)
-
Example running a macro over lines 5 through 10
:5,10norm! @a -
Example running a macro over lines 5 through the ened of the file
:5,10norm! @a -
Example running a macro over all lines in the file
:%norm! @a -
Example running a macro over all lines that match a pattern
:g/pattern/norm! @a
-
(In command mode)
-
v # (lower case) Select block character by character
-
V # (upper case) Select block line by line. Cursor can be anywhere on the line
-
Ctrl+v # Selects vertically oriented blocks
-
All of the operations are available, but not very useful
-
Huge strength of this mode is that is makes it easy to check indentation across man lines
-
Great for YAML, jSON, and XML files
-
-
-
Navigate cursor as normal to select block
-
Operations available:
-
y # yank
-
d # delete
-
c # change, effectively the same as cw
-
> # increase indentation of the block
-
< # decrease indentation of the block
-
: # apply last-line command to the block
-
-
:e <filename> # edit new file
-
:split filename # split window horizontally and load another file
-
:vsplit filename # split window vertically and load another file
-
Ctrl+w Ctrl+w # move cursor to another window (cycle)
-
Ctrl+w= # make all windows equal size
-
:hide # close current window
autocmd Filetype python setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab autocmd Filetype go setlocal tabstop=4 shiftwidth=4 softtabstop=4 autocmd FileType yaml setlocal ts=2 sw=2 et ai ci cuc cul autocmd FileType sh setlocal ts=2 sw=2 et ai ci cuc " ts - tabstop - number of spaces in a TAB " sw - shiftwidth - number of spaces to use by autoindent " sts - softtabstop - num of <tab> and <bs> to insert to match tabstop " et - expandtab - <tab> will insert spaces " ai - autoindent - auto indent next line based on previous line " ci - copyindent - copy indent from previous line " cuc - cursorcolumn - draw a vertical ruler at current cursor position " cul - cursorunderline - draw a vertical ruler at current cursor position