Вы находитесь на странице: 1из 1

:h operator :h navigation :help :h keycodes

[operator][count][motion] gg
:h up-down-motions

:h cmd Normal mode cmd help


<CR> ^m \r Enter

ts sw sts et tabstop ts Columns per tabstop

:h i_cmd <Tab>
first
line Insert mode cmd help ^i \t Tab

d Any motion can follow an


operator. Marks and searches
w word
WORD
use spaces only n n n on shiftwidth sw Columns per <<

:h v_cmd <C-n>
W
count as motions, too! d/
delete/cut foo will delete from the
cursor to the next instance
s
[, ]
sentence
[ ] block ^b use tabs only n n 0 off softtabstop sts Spaces per tab Visual mode cmd help ^n Ctrl-n

y of “foo”. y3fi will yank from


the cursor to the 3rd “i” on
the line after it. Counts can
(, )
<, >
t
( ) block
< > block
XML/HTML tag
up 1
page
Set n to desired tab width (default 8)

MIXING T A BS AND SPAC ES


expandtab et

IS
<Tab> inserts spaces

RIGHT OUT.
:h c_cmd Command-line editing cmd help
:h tags-and-searches <M-n> Alt-n

yank/copy also come before operators:


5dd will delete five lines.
{, } { } block

^u
(t h a t m e an s don 't do i t . )
:h :cmd Command-line cmd help ^] Jump to tag under cursor,
including [tags] in help files <Esc> ^[ Escape

c ", ' quoted string

:retab :h ‘option’ ^t <BS>


starting cursor position
up ½
Replace all tabs with spaces according to current
:h text-objects
page tabstop setting Option help Jump back up the tag-list ^h \b Backspace
change
(use text-objects )
gU
make
uppercase
~
swap case

iw k fileformat ff Try changing this if your line-endings are messed up :helpgrep Search through all help docs!
g^] Jump to tag if it's the only
match; else list matching tags <Del> Delete

<
shift left
=
indent

i( iW up 1
line
list Display whitespace visibly according to listchars

7 words
:h left-right-motions
:h word-motions

beginning
of line
0
first
non-blank
character ^
previous
WORD B previous
word b previous
character h next
character l end of
word e beginning
of next
word
w end of
WORD E beginning
of next
WORD
W end of
line $ http://www.vimcheatsheet.com
1 WORD

j
:h pattern-searches

SEARCHING p paste after


cursor P paste before
cursor ^[ return to Normal
mode :h options
down

:set opt?
Prev Next Forward Backward Matches hidden hid Lets you switch buffers without saving Use a instead
1 line
u undo
^r redo
. repeat
View current value of opt
of i when
/foo ?foo foo laststatus ls Show status line never (0), always (2) or with 2+ windows (1) beginning text-

^d :set noopt
file-searching
N n find file under

* # word under cursor gf cursor in path


and jump to it
dd delete current
line yy yank current line Turn off flag opt
hlsearch hls Highlight search matches. Also see ‘highlight’
object motions to
include delimiters

:set opt
down
or surrounding

; ,
tx Tx upto x ½ page
x delete character
after cursor % jump to
matching paren r replace char
under cursor
Turn on flag opt number nu Show line numbers
whitespace.

:set opt=val
For example,
fx Fx find x showcmd sc Show commands as you type them

:h mark-motions ^f nG jump to line n


^o
jump-motions
jump back
^i
jump-motions
jump forward Overwrite value of opt
ruler ru Show line and column number of the cursor
di( will change
“(foo)” into

:set opt+=val
set mark M jump to first down align top of align bottom

mm set mark m
(a-z) in file mM (A-Z) across
files '[ char of just-
changed text
1 page
zz center screen on
cursor zt screen with
cursor zb of screen with
cursor
Append to value of opt
backspace bs Set to ‘2’ to make backspace work like sane editors
“()”, but
will delete the
da(

'm
jump to first
char of line
containing m
`m jump to exact
character of m '' jump back to
last jump
G == auto-indent
current line << shift current line
left by shiftwidth >>
shift current
line right by
shiftwidth
:echo &opt Access opt as a variable wrap

background bg
Control line wrapping

Set to ‘dark’ if you have a dark color scheme


parentheses as
well.

last line
:h buffers
Pass a directory to the :edit command to open a directory explorer. Using ^[ to return to Normal mode lets you keep your fingers on the home
REGISTERS CLIPBOARDS
:ls
Instructions for usage are at the top of the screen. row. It’s even easier if you map Caps Lock to Control! are Use :map to
List all open files
:h insert.txt All commands that delete, copy, or paste text use registers. To change which register view all current
is used by a command, type the register before the command. The default register is custom key
ENTERING INSERT MODE COOL INSERT MODE STUFF
:b path Jump to unique file matching path. Use
<Tab> to scroll through available completions! called “the unnamed register”, and it is invoked with a pair of double-quotes (""). Typ- mappings. Read
:h map-which-
beginning
of line I before
cursor i after
cursor a end of
line A ^w delete word before cursor
^u delete line before cursor

:bn Jump to file n, number from first column of :ls


ing dd or yy is the same as typing ""dd or ""yy. Think of the first " as a short way
of saying “register”, so "" is pronounced “register "”, and "a, “register a”.
:h registers
keys for a guide
on which keys

previous
line O next
line o substitute
character s substitute
line S line from
cursor C ^rr insert the contents of
register r ^r=
use the expression register
(try ^r=5+10)
:bnext Jump to next file
:registers View all current registers
are best for your
own custom
mappings. Get

ENTERING VISUAL (SELECT) MODE ^t increase line indent


by shiftwidth ^d decrease line indent
by shiftwidth
:bprev Jump to previous file
:echo @r Access register r as a variable used to Vim’s
help system -
The most basic type. Useful for moving Great for working

^x^l ^n :bdelete "/


Use Visual mode to chunks of a program with tables made of line completion
find next completion suggestion Last search it’s a fantastic
according to complete Remove file from the buffer list Contains the last pattern you searched for
select characters around the file. Use text, or anything pattern register resource!

v V ^v
within a line. Visual Line mode to that happens to be
:h cmdline.txt

:edit "_
select one or more conveniently aligned.
The black hole Use this to delete without clobbering any
Open a file for editing
COMMAND-LINE MODE ONLY
lines. Visual Block mode
can be used to select register register ("_dd)
boxes across lines.

switch cursor
to start/end o re-select
previous area gv prepend to each
Visual block line
I jump to start
of prior area
'<
edit using
Normal mode
cmdwin ^f
insert word
under cursor
cmdline-editing ^r^w completion
suggestions
cmdline-completion ^d :enew Open a blank new file for editing
"0 Last yank
register
Contains the last text you yanked
1st Edition
funded by...
MML
Adam.

"1
jdiemz
:h v_o :h gv :h v_b_I :h '<
Last big delete Lin Qiu
Put cnoremap %% <C-R>=expand(‘%:h’).’/’<CR> in your .vimrc so you can type %% in Command-line :h windows Contains the last line(s) you deleted @webjoe
register grantok

ZZ Write current file, if modified,


ZQ Quit without checking for
:split
mode to refer to the directory of the current file, regardless of pwd. storrgie
Split current window horizontally David G.

"2 - "9
and quit changes (like :q!) Big delete Every time "1 is written to, its content is
Digininja
Dave Remy
Supply % as a range to the :substitute command to run it on every line in the file. register stack pushed to "2, then "2 to "3, and so on Ralph Bean

:write :vsplit
Arve Løken
Rajat Ghai
Write current file :%s/Scribbl/Design/ “Scribbled” -> “Designed” Split current window vertically

"-
Paul-Kenji
Small delete Contains the last text you deleted within a Mark Dizon

Specify the “g” flag to apply the substitution to every match on a line.
Neil Munro
register single line Kyle Verma

:wq ^w hjkl Move cursor to window left, below, above or to Guy Bensky
Write current file and quit :s/[dla]//g “badly” -> “by” :h s_flags, :h /[] Ross Timson

"+
the right of the current window If the OS integration gods smile upon Abdul Qabiz

Vim supports many regular expression features. System clipboard you, this register reads and writes to your Daniel Beck
Hazel Smith

^w HJKL Move current window to left, bottom, top, or system clipboard. Kelly Raila

Use :scriptnames to list all files sourced during initialization. :s/..k/ax/ “Mook” -> “Max”
:h usr_27, :h /.
right of screen
Charles Chen
Pivotal Labs

"a - "z
Eric Sporkin

Use \_. instead of . if you want to search across multiple lines. Named registers 26 registers for you to play with M. Adam Price

:syntax ^w r
Daniel Hahler
Enable and configure syntax highlighting Rauli Silvola

“Cheatsheet\nBungler” -> “Cantor”


:h /\_. Rotate windows clockwise Lawrence Kemp
Use :sy sync fromstart to redraw broken highlights :%s/heat\_.*Bungle/anto/
"A - "Z
Bill LaPierre
Using upper-case to refer to a register will Brandon Tyree
Append registers
Special escapes can be used to change the case of substitutions. append to it rather than overwrite it Laurence Emms

:make ^w +-<>
:h quickfix Infonautic.de
Run a compiler and enter quickfix mode :h sub-replace-special Increase/decrease current window height/width @andersosthus
:s_\(f..\)_\U\1\E_ “foobar” -> “FOObar” Damon Jablons

qr Record into register r. Stop recording by Travis McHenry


Record Ganesh Sugunan
Use :global to perform a command on matching lines. hitting q again

:! ! ^w T
Rouven Hernier
Execute external shell Filter motion with shell Digital Gnomes
Move current window to a new tab Sam Napolitano
command command :g/foobar/delete Delete all lines containing “foobar”

@r
Jens O. Meiert

Playback Execute the contents of register r Thomas Nitsche


Philip Ratzsch
If your pattern contains slashes, just use a different character as your delimiter.

:only
Hurricane Labs
Use :earlier and :later to quickly jump backward and forward in a file's history. Close all windows except current window Michael Schmidt

@@
:s_Data/Lore_Brent Spiner_ Repeat last Repeat the last @r, this is particularly
Matthew Datcher
Arya Reais-Parsi
David Macfarlane
playback useful with a count

:read :bufdo
Use \= to evaluate expressions with replacement groups. Christer Edvartsen

Read external program output into current file Execute a command in each open file
St. Louis Vim Geeks
Haraldur Tristan Gunnarsson
“10 25” -> “21 36” :h sub-replace-\=
:s_\d_\=submatch(0) + 1_g vim one-liner used to sort the list of names by length:
:exe 'g/^/let @x = len(getline(".")) | normal "xPa ' | sort n | :g//normal dw
and others!

Вам также может понравиться