Vim #
References:
General #
General notes:
<C>
:Ctrl
on Windows,control
on Mac.<Esc>
:Esc
on Windows,esc
on Mac.- Consider remapping
caps lock
toesc
.
- Consider remapping
- If some command has a upper-case key, you should press at the same time
shift
.
.vimrc
files from all three teachers:
- dotfiles/.vimrc at master · JJGO/dotfiles
- configs/init.vim at master · jonhoo/configs
- dotfiles/vimrc at master · anishathalye/dotfiles
" Save changes (write)
:w
" Close file (quit)
:q
" Close file without saving
:q!
" Help with some command
:help some command
" Enter normal mode
<Esc>
Normal Mode #
Move Around #
" One line up
k
" One line down
j
" One character left
h
" One character right
l
In-line:
" Next word's first letter (word)
w
" Next word's last letter (end)
e
" Previous word's first letter (back)
b
" Previous word's last letter
ge
" Beginning of the line
0
" First non-blank character of the line
^
" End of the line
$
" Jump between a pair of parentheses
%
Across lines:
" One screen up
<C>u
" One screen down
<C>d
" Beginning of the file
gg
" End of the file
G
" Last line on screen (low)
L
" Middle line on screen
M
" First line on screen (high)
H
Search #
In line:
" First instance of some character (example: first o)
fo
" Last instance of some character (example: first o)
Fo
In whole file:
" Search text
/text here
" Go to next match
n
" Go to previous match
N
Edit #
Basics:
" Delete the character under cursor
x
" Flip text case
~
" Repeat last change (after moving to another position)
.
" Undo
u
" Undo the whole line
U
" Redo
<C>r
Combined with content change:
" Replace the character under cursor with another character (example: o)
ro
Combined with movement:
" Delete (example: current word)
dw
" Delete the whole line
dd
" Delete & enter insert mode (example: from cursor until the end of the word) (change)
ce
" Delete the whole line & enter insert mode
cc
Combined with modifier:
" Delete (example: everything inside []) (inside)
di[
" Delete (example: everything inside [], including []) (around)
da[
" Delete & enter insert mode (example: everything inside "")
ci"
" Delete & enter insert mode (example: everything inside "", including "")
ca"
Copy & Paste #
" Copy (example: current word)
yw
" Copy the whole line
yy
" Copy (example: from cursor until the end of the word)
ye
" Paste, or put what's just deleted below the cursor
p
Insert Mode #
Enter insert mode:
" Directly (cursor stays at current position)
i
" Append (cursor goes one slot ahead)
a
" Open new line below cursor
o
" Open new line at cursor
O
Visual Mode (Selection Mode) #
Enter visual mode:
" Visual mode
v
" Visual line mode
V
" Visual block mode
<C>v
Copy & return to normal mode:
y
Windows (Panels) & Tabs #
Windows (panels):
" Open horizontal panel with the same file (split)
:sp
" Close current panel
:q
" Save all panels (write all)
:wa
" Close all panels (quit all)
:qa
Tabs:
" Open new tab
:tabnew