vim visual cheat sheet - hamwaves.comhamwaves.com/vim.tutorial/en/vim.tutorial.a4.pdf · visual...
TRANSCRIPT
Vim Visual Cheat SheetSerge Y. Stroobandt
Copyright 2016, licensed under Creative Commons BY-NC-SA
This document is still under construction.
IntroductionVim (and vi for that matter) is renowned for its notoriously steep learningcurve.
Figure 1: Comparison of editor learning curves Source:
This should not scare you off. If you have not done so yet, first read “Why I UseVim” If you cannot bother reading it, here is my personal break down.
No, this is not an extreme case of fanboyhood. Vim is a way of life, or rather,a means towards extreme levels of productivity with the Vim–Mark-down–Pandoc–make input combo with any of the LaTeX/Con-TeXt/XHTML/Prince/DZSlides back‑ends.
1
vi gang sign
Among other things, Vim will teach you to use a keyboard professionally;keeping your index fingers stuck to the home row. Vim allows you to edit textslightning fast without resorting to any computer mouse or other pointing de-vice. Imagine the space you will gain on the folding table on your next transat-lantic business flight! You will no longer have to use the Home , End or ar-row keys, if you chose so.
Vim’s predecessor vi has been around since 1976and has been continuously improved ever since.If computer application has been around for suchan extended period in time, for sure, there must bea good reason to it! Are you not curious towards ex-periencing for yourself why?
My interest in Vim grew out of my annoyance withother text editors not recognising words, parenthesis, brackets, etc. I got fed upwith manually tapping the cursor to the desired editing position. Vim is one ofthe few text editors which is a word processor in the true sense of the word.It is a word processor which effectively recognises word, bracket and parenthe-sis boundaries, counts words, etc.
Vim continuously records a small macro of your last command combination,which is easily accessible through the dot . key. Don’t be deceived; this func-tionality is far more powerful than the usual repeat function!
2
Visual Cheat Sheet
For English keyboards
Figure 2: Vim visual cheat sheet for English keyboards
3
For German keyboards
Figure 3: Vim visual cheat sheet for German keyboards
Tutorialvi/vim graphical cheat sheet tutorial
4
vi / vim graphical cheat sheet
prev(find)N
n next(find)
undolineU
u undo
exmodeQ
q recordmacro·
nextWORDW
w nextword
endWORDE
e endword
back'till·T
t 'till·insertat bolI
i insertmode
openaboveO
o openbelow
appendat eolA
aappend
substlineS
s substchar
"soft"bol^
6prevident#
3eol$
4goto
match%5
nextident*
8begin
sentence(9
endsentence)0 "hard"
bol
repeat:s
7& "soft" bol
down_- prev
line
"back"find chF
f findchar·
·
Rreplacemode
r replacechar·
ex cmdline:
; repeatt/T/f/F
motion
command
operator
extra
moves the cursor, or defines the range for an operator
direct action command,
requires a motion afterwards, operates between cursor & destinationspecial functions,requires extra input
if red, it enters insert mode
back-spaceX
x deletechar
q· commands with a dot needa char argument afterwards
playmacro@
2·
screenmid'lM
m setmark·
visuallinesV
v visualmode
prevWORDB
b prevword
find(rev.)?
/ find··
~ togglecase
`goto
mark·beginparag.{
[ misc·end
parag.}]· misc
| bol/goto col
\ notused!·
CTRL-R: redo (vim),CTRL-F/-B: page up/down,CTRL-E/-Y: scroll line up/down,CTRL-V: block-visual mode (vim only)
Main command line commands ('ex'):
bol = beginning of line, eol = end of line,mk = mark, yank = copy
Escnormalmode
words:WORDs: quux(foo, bar, baz);
:w (save), :q (quit), :q! (quit w/o saving):e f (open file f),:%s/x/y/g (replace 'x' by 'y' filewide),:h (help in vim), :new (new file in vim),
Other important commands:
reg.spec"
' gotomk. bol
··
1
pastebeforeP
p pasteafter
1
!1
externalfilter
2
yanklineY
y yank1,3
Ddeleteto eol
d delete1,3
un-indent<
, reverset/T/f/F
3indent>
. repeatcmd
3
+ nextline
= autoformat
3
Z quit
z extracmds·· 4
5
G eof/goto ln
g extracmds· 6
C changeto eol
c change1,3
type in a number before any actionto repeat it that number of times(e.g.: 2p, d2w, 5i, d4j)
use "x before a yank/paste/del commandto use that register ('clipboard') (x=a..z,*)(e.g.: "ay$ to copy rest of line to reg 'a')
duplicate operator to act on current line(dd = delete line, >> = indent line)
Notes:(1)
(2)
(3)
ZZ to save & quit, ZQ to quit w/o saving(4)
zt: scroll cursor to top,zb: bottom, zz: center
(5)
gg: top of file (vim only),gf: open file under cursor (vim only)
(6)
Move around and type operator to acton selected region (vim only)
Visual mode:
For a graphical vi/vim tutorial & more tips, go to www.viemu.com - home of ViEmu, vi/vim emulation for Microsoft Visual Studio
screentopH
h
joinlinesJ
jhelpK
kscreenbottomL
l
quux(foo, bar, baz);
version 1.1April 1st, 06
Figure 4: Vi/vim graphical cheat sheet tutorial
Vim gameVIM Adventures
From here onBy now, you might have Vim is actually a word processor which you can easilymodify and/or extend yourself.
In other applications
This work is licensed under a Creative CommonsAttribution‑NonCommercial‑ShareAlike 4.0 International License.
Other licensing available on request.
Unattended CSS typesetting with .
This work is published at http://hamwaves.com/vim.tutorial/en/.
Last update: Tuesday, August 7, 2018.
5