Reading
command |
description |
ctrl + e |
scroll down |
ctrl + y |
scroll up |
Convenient Functions
command |
description |
gg |
go to the top |
gx |
open a link |
gq |
wrap line |
Spelling
command |
description |
zg |
add word to dictionary |
zw |
mark the word as wrong word |
Autocompletion
command |
description |
<C-X><C-K> |
autocomplete from dictionary |
Surrounds
command |
description |
yss |
Surround the line |
Navigation
command |
description |
]m |
Jump forward to begin of next method/scope |
[m |
Jump backwards to begin of previous method/scope |
Folding
How to fold everything except current block
zMzO
How to fold a certain level
zr
zm
Command Mode
Copy a word from a text
<C-r><C-w>: to copy/paste the word under the cursor in command mode
<C-d>
Helpgrep
search a keyword in help
helpgrep <KEYWORD>
Marks
Automatic Marks
command |
description |
`` |
Position before the last jump within the current file |
`. |
location of last change |
`^ |
Location of last insertion |
`[ |
Start of last change or yank |
`] |
End of last change or yank |
`< |
start of last visual selection |
`> |
end of last visual selection |
Normal Mode
Remember where you were
ctrl + o + o + o
Go back in time
g- and g+ vim go back and forth in time
Autocompletion
command |
description |
<C-x><C-n> |
generic keywords |
<C-x><C-n> |
Current buffer keywords |
<C-x><C-k> |
From dictionary |
<C-x>s |
spelling correction by suggestion(super) |
<C-y> |
accept |
<C-e> |
reject |
Add dictionary to autocompletion list
:set complete+=k
Etc
command |
description |
~ |
change case |
Autocommand
autocmd BufReadPost * call MyFollowSymlink(expand('<afile>'))
Vimscript
getftype: Seems to get type file type
if getftype(fname) != 'link'
Search
Special Anchor
\ze
If you want to match “A” in “ABC” but not in “ADD”, use \ze
anchor.
/A\zeBC
Read: Find A
, which is followed by BC
but only match A
.
Here’s the official help page for \ze
from doc/pattern.txt
\ze Matches at any position, and sets the end of the match there: The
previous char is the last char of the whole match. |/zero-width|
Can be used multiple times, the last one encountered in a matching
branch is used.
Example: "end\ze\(if\|for\)" matches the "end" in "endif" and
"endfor".
This cannot be followed by a multi. |E888|
{not available when compiled without the |+syntax| feature}