27
loading...
This website collects cookies to deliver better user experience
:chistory
or :chi
- Show the stack of quickfix lists and point out the current one.:colder
or :col
- Change the current quickfix list to the next older one.:cnewer
or :cnew
- Change the current quickfix list to the next newer one.:colder
and :cnewer
. For example, running :colder 3
will select the quickfix list which is 3 positions down the current one.c
(quic
kfix) of the commands above with a l
(l
ocation).:help quickfix-error-lists
:digraphs
or :dig
- Display the digraphs available.:digraphs <char1><char2> <number>
- Create a new digraph represented with the characters <char1><char2>
. The <number>
is its decimal representation (Unicode character).CTRL+K <char1><char2>
- Insert the digraph represented with the characters <char1>
and <char2>
.<char1><BS><char2>
- Insert the digraph represented with the characters <char1>
and <char2>
(only if the option digraph
is set to true).CTRL+K ->
: →CTRL+K TM
: ™CTRL+K Co
: ©CTRL+K Rg
: ®CTRL+K Eu
: €CTRL+K +-
: ±CTRL+K OK
: ✓CTRL+K XX
: ✗CTRL+k AN
), "∨" (CTRL+k OR
) or "∈" (CTRL+k (-
).ga
in NORMAL mode to display the digraph of the character under the cursor (if there is one).:help digraph
:help digraph-table
CTRL
, specifying to Vim that we don't want to insert some text.CTRL+a
- Insert the la
st content inserted.CTRL+@
- Insert the la
st content inserted and quit INSERT mode.CTRL+h
- Delete the character before the cursor.CTRL+w
- Delete the w
ord under the cursor.CTRL+u
- Delete everything before the cu
rsor.CTRL+t
- Add one indentat
ion.CTRL+d
- D
elete one indentation.CTRL+R <reg>
- Spit the content of the register <reg>
as if you typed it.CTRL+R CTRL+R <reg>
- Same as CTRL+R
, but insert the text literally.CTRL+R CTRL+P <reg>
- Spit the literal content of the register <reg>
with the correct indentation.^M
or ^I
. You can think of them as CTRL+m
and CTRL+i
, which means, if you recorded some macros while being in INSERT more, end-of-line and tabulation respectively.CTRL+R <reg>
will insert these end-of-lines and tabulations. For example, if you have the characters ^M
in your register when you display them via :reg
, it will become an end-of-line when you insert it.CTRL+R CTRL+R <reg>
, you'll have the literal characters ^M
inserted in your buffer. It's handy to spit a recording for a macro, modify it, and then save it back to your register <reg>
. From there, you can execute your modified macro.CTRL+V
(or CTRL+Q
) in INSERT mode followed by the key. For example, CTRL+V ENTER
will display ^M
.CTRL+V
, you can also use it followed by the decimal, octal, or hexadecimal value of a character. It's another way to insert special characters without using digraphs. You can run man ascii
to have access to the ASCII table in your shell and choose whatever character you want.CTRL+V
and the equivalent CTRL+Q
can be used in COMMAND-LINE mode too.CTRL+o
in INSERT mode allows you to come back to NORMAL mode for one keystroke (or one command in COMMAND-LINE mode). When it's done, you'll be automatically back in INSERT mode.CTRL+G u
in INSERT mode.u
in NORMAL mode. Everything you've inserted is now gone.:inoremap <space> <C-G>u<space>
SPACE
in INSERT mode, you'll stop the undo sequence. When you hit u
in NORMAL mode, it will undo what you've inserted after hitting the last SPACE
. If you undo again, it will undo another word, and so on. There is a drawback, however: abbreviations won't work anymore in insert mode.CTRL+G u
as creating chunks of undo.:help ins-special-keys
:help insert−index
o
- Move your cursor to the o
pposite side of the selection (or the o
ther end if you prefer). Doesn't work in VISUAL mode linewise.R
or S
- Delete the selected lines and start INSERT mode.U
- U
ppercase the selection.gv
- Switch back and forth between the previous selection and the current one.CTRL+v
and SHIFT+v
.o
- Move to the o
pposite corner of the selection.O
- Move to the o
pposite side of the selection.I
- I
nsert some content at the beginning of every line selected.A
- A
ppend some content on every line selected after the highlighted area.$A
- A
ppend some content at the end of every line selected.c
- Delete selected lines and begin INSERT mode on every line.:help visual-index
:help blockwise-operators
:help perl-patterns
.^
is "beginning of the line". [A-Z]
is an atom because it matches only one character from A
to Z
.magic
. You might be tempted to change its value; please don't. Every plugin out there expect this option set to magic
. Instead, we'll see different ways to change the magic level for each regex.\v
before your pattern.\V
before your pattern.:%s/\v(emacs)/\1 is bad/
will work flawlessly.:help \magic
. You'll be granted with a wonderful table nobody remembers.\s
or [:blank:]
- whitespace characters.[A-Z]
or \u
or [:upper:]
- Uppercase.[a-z]
or \l
or [:lower:]
- Lowercase.[0-9]
or \d
or [:digit:]
- Digits.\_
- Character class with end of line included.\_u
.\L
is equivalent to [^a-z]
(every character except the characters in the range a
to z
).\f
- Filename characters (option isfname
)\i
- Identifier characters (option isident
option)\k
- Keyword character (option iskeyword
)\p
- Printable character (option isprint
)gf
use isfname
under the hood. 48-57
in these options, it means the ASCII characters from 48 to 57, which are the numbers from 0 to 9.^
and $
are zero-width. :%s/^/->
in a buffer for example.\zs
- Only match your pattern if what's before the metacharacter \zs
match what's before your pattern.\ze
- Only match your pattern if what's after the metacharacter \ze
match what's after your pattern.\<
- Match the beginning of a word./>
- Match the end of a word.\%^
- Match the beginning of the file.\%$
- Match the end of the file.\%V
- Match inside the visual selection (or the previous one if you're not in VISUAL mode)./
for searching:\v^\s+\zsfor
- Only match for
if there are one or more whitespace before the pattern.\<if\>
- Only match the word if
and not the substring if
in cliff
for example.end\%$
- Only match the pattern end
if it's just before the end of the current file.mv my-file-name.jpg my-file-name.jpg
-
with underscores _
in the filename my-file-name.jpg
. I could: my-file-name.jpg
:'<,'>s/-/_/g
g
flag, and, if I don't use it, I only replace the first hyphen on the line. \%V
::'<,'>s/\%V-/_/g
\%<'m
- Matches before the position of mark m.\%>'m
- Match after the position of mark m./\%>'mcat\%<'a
search the pattern cat
between the mark m
and a
.:help regex
:help /magic
:help holy-grail
:help pattern
:help pattern-atoms
:help pattern-overview
:! <cmd>
- Execute the shell command <cmd>
.:!!
- Repeat the last command executed.man ascii
in a shell. Now, you can look at it directly in Vim with :!man ascii
.:read! <cmd>
or :r! <cmd>
- Execute the command <cmd>
and insert the output in the current buffer.:read!!
or :r!!
- Repeat the last command executed and insert the output in the current buffer.:help :!
:help :r!
:!
with a range will help you fulfill your destiny. For example, you could::'<,'>!grep <pattern>
<pattern>
will disappear in a magical cloud. Show that to your friends, your family, or your boss, and they'll respect you forever.1,10:!sort
, it won't filter anything, it will replace the input I gave to sort
and it will replace it with the output.:help filter
foldmethod
will determine how you want to manage your folds. There are 6 in total:manual
- You manually define folds with the commands below.indent
- Folds are created depending on the indentation level.expr
- Folds are created depending on a Vimscript expression defined in foldexpr
.syntax
- Fold are created depending on the syntax highlighting (if the syntax highlighting defines them).diff
- Fold unchanged text.marker
- Fold depending on markers.marker
, here's an example I use in my .vimrc
:" Install Plugins ---------------------- {{{
"
" Some config here
"
" }}}
" Plugins Config ---------------------- {{{
"
" Some config here
"
" }}}
z
. When you look at this wonderful letter, you can let your imagination going into foreign worlds and see a fold. Folded: -
. Unfolded: z
. Think about unfolding an old manuscript full of hidden Vim knowledge. Impressed? Me too.manual
or marker
.zf
- Create a f
old. It can be used in VISUAL mode or with a motion. zd
- d
elete the fold under the cursor (but not the nested ones).zD
- D
elete the fold under the cursor, including the nested ones.zE
- E
liminate every fold in the window. It deletes the markers if your foldmethod is set to marker
. Brutal.zo
- o
pen the fold under the cursor.zc
- c
lose the fold under the cursor.za
- Toggle the fold under the cursor (close it if it's open, open it if it's close).zx
- Undo opened and closed folds.zO
for example) can be used to propagate the action to every nested fold.zM
- Close all foldszR
- Open all foldszi
- Toggle the use of folds (option foldenable
).[z
- Move to the start of the current fold.]z
- Move to the end of the current fold.zj
- Move downward to the start of the next fold.zk
- Move upward to the start of the next fold.:foldopen
or foldo
- Open folds.:foldclose
or foldc
- Close folds.:folddoopen <cmd>
or :foldd <cmd>
- Execute command <cmd>
on all opened fold.:folddoclosed <cmd>
or :folddoc <cmd>
- Execute command <cmd>
on all closed fold!
for the first two ones (foldo!
and foldc!
) will open or close all nested folds too.:help Folding
:help fold-methods
:help fold-commands
:!
.:read
.:foldd
and :folddoc
.27