Andrew Pennebaker
https://github.com/mcandre/cheatsheets/blob/master/vim.md
Vim is a highly customizable command line and graphical text editor.
vi and Vim Editors Pocket Reference
$ apt-get install vim
$ brew install macvim --override-system-vim && brew linkapps
C:\> chocolatey install vim
By default, Ubuntu uses the vim.tiny, which lacks support for arrow key navigation. Use apt-get install vim to upgrade to full vim with arrow key support.
$HOME/.vimrc
%HOME%/_vimrc
By default, Vim begins in Normal mode, for entering commands. To issue a command, type Colon, then the command, then Enter. This is represented in Vim documentation with the notation :command.
From Normal mode, press i to switch to Insert mode. Then begin typing text.
To return to Normal mode, press ESC.
From Normal mode, press v to switch to Visual mode. This also allows highlighting text by moving the cursor.
To return to Normal mode, press ESC.
$ vi <file/dir>
$ vi
:e <file/dir>
$ view <file/dir>
C:\> vim <file/dir>
gitbash$ vim <file/dir>
:w
:w <filename>
:o
:wa
:e
:q
:q!
:qa
:qa!
u
Control+r
ESC
:enew
:set syntax=<name>
/<term>
n next match.
:%s/<term>/<replacement>/gc
a - replaces all occurences.
y - replaces current match.
n - skips over current match.
:grep <term> *.?<file extensions>
http://vimhelp.appspot.com/intro.txt.html#key-notation
:%<command>
Vim will integrate with the OS clipboard, provided that +clipboard is enabled at compile time, and:
set clipboard=unnamed
is configured in vimrc.
dd
D
- Use Visual mode (
v) and arrow keys to select text. d- Cut,y- Copy
yy[n]
:%y Enter
p
Control+r, +
Arrow keys may also be used, but they require a full vim package, provided by default in some Unix installations but not all.
h
j
k
l
I
A
0
$
b
Control+b
Control+f
:<n>
<n>G
:1
Or
gg
G
Or
G$
o
O
Control+v u <n>
x
:h '<term>
Control+w, s
Control+W, v
Control+w, Control+w
:hide
:b <name>
- Select text with Visual mode (
v). - Press
gc.
Or
- Navigate to the desired line.
- Press
gcc.
>
<
:sh
Control+d
Vim doesn't have the most intuitive defaults. Here are some snippets you can insert into your $HOME/.vimrc / $HOME/_vimrc in order to fix common problems.
set backspace=2
Or use MacVim
set number
syntax on
set foldmethod=syntax
set foldcolumn=1
set foldlevelstart=20
For more helpful snippets, see https://github.com/mcandre/dotfiles/blob/master/.vimrc
set bomb
- Vim Scripts http://www.vim.org/scripts/index.php