Open main menu

Changes

1,897 bytes added ,  12:49, 24 May 2018
adds a couple new sections
 
<html>
<p>This document is a <b>vi</b> cheat sheet, designed to be kept
</html>
 
== To comment out blocks in vim: ==
 
* press <kbd>Esc</kbd> (to leave editing or other mode)
* hit <kbd>ctrl</kbd>+<kbd>v</kbd> (visual block mode)
* use the up/down arrow keys to select lines you want (it won't highlight everything - it's OK!)
* <kbd>Shift</kbd>+<kbd>i</kbd> (capital I)
* insert the text you want, e.g. '# '
* press <kbd>Esc</kbd>
 
Give it a second to work.
 
== To uncomment blocks in vim: ==
 
* press <kbd>Esc</kbd> (to leave editing or other mode)
* hit <kbd>ctrl</kbd>+<kbd>v</kbd> (visual block mode)
* use the up/down arrow keys to select the lines to uncomment.
 
*If you want to select multiple characters, use one or combine these methods:
** use the left/right arrow keys to select more text
** to select chunks of text use <kbd>shift</kbd> + left/right arrow key
** you can repeatedly push the delete keys below, like a regular delete button
 
* press <kbd>d</kbd> or <kbd>x</kbd> to delete characters, repeatedly if necessary
 
* press <kbd>Esc</kbd>
 
Give it a second to work.
 
== Edit multiple files: ==
* press <kbd>Esc</kbd> (to leave editing or other mode)
* then use one of the following sequences
* type <kbd>:</kbd> <kbd>t</kbd> <kbd>a</kbd> <kbd>b</kbd> <kbd>e</kbd> (e for edit), [space] and then start typing the /path/to/filename
* type <kbd>:</kbd> <kbd>t</kbd> <kbd>a</kbd> <kbd>b</kbd> <kbd>n</kbd> (n for next), to switch to the next buffer
* type <kbd>:</kbd> <kbd>t</kbd> <kbd>a</kbd> <kbd>b</kbd> <kbd>p</kbd> (p for previous), to switch to the previous buffer
* You can also type <kbd>:args</kbd> to get a list of the open buffers
 
== Move everything flush to the left ==
<kbd>:</kbd><kbd>%</kbd><kbd>l</kbd><kbd>e</kbd>
: colon mode
% the current buffer
l 'left' command
e 'end' of document
 
Or, in visual mode, you can use the <kbd><</kbd> key to move a selection left.
 
== More VIM Cheat Sheets ==
* https://www.fprintf.net/vimCheatSheet.html
[[Category:Tools]]
4,558

edits