- Introduction
- Navigation
- Project wide substitution
- Execute Ex command on a pattern
- Registers
- Macros
- Autocomplete
- Spell Checker
- Perform action inside a text object
- Perform action until a char is found
- FTPlugin
#Introduction
My vimrc configuration, plugins and some other vim useful stuff (mainly taken from Practical Vim: Edit Text at the Speed of Thought).
#Navigation
- Centralize on cursor:
zz
- Forward word navigation at word start:
w
- Forward word navigation at word end:
e
- Backward word navigation at word start:
b
- Backward word navigation at word end:
ge
- Mark line:
m[register]
- Goto marked line :
'[register]
- Goto file under cursor :
gf
- vim -o [files list or regex]
- set hidden
- argdo %s,[old-text],[new-text],ge
- argdo update
It is a good idea to put set hidden
on your .vimrc.
Executing a command only on lines that matches a pattern:
[range]g/[pattern]/[ex command]
Example, deleting all lines (entire file, using %) that contains "vim" on it:
%g/vim/d
- Listing registers:
:reg
- Executing command with specified register:
"[reg][command]
Examples:
- Pasting from yank register (0):
"0P
- Yanking to the system clipboard register (+):
"+y
- Start recording macro :
q[register]
- Stop recording macro :
q
- Execute macro:
@[register]
- Execute macro on parallel:
:[range]normal @[register]
- Start:
[C-n]
- Accept:
[C-y]
- Exit:
[C-e]
- Omni Complete:
[C-x][C-o]
- Enable:
set spell
- Disable:
set nospell
- Next:
]s
- Previous:
[s
- Correct word under cursor:
z=
- Add word to dict:
zg
- Remove word from dict:
zw
#Perform action inside a text object
Pattern: [action]i[delimiter]
The delimiter is what defines where the text object start and where it ends.
The idea is that you are performing an action inside (just remember that i means inside) the text object that is enclosed by the delimiter.
Examples:
- Start change inside braces:
ci{
- Delete the contents of a string:
di"
- Yanking everything inside parentheses:
yi(
#Perform action until a char is found
Pattern: [action]t[char]
Examples:
- Delete everything until a { is found and start editing:
ct{
- Delete everything until a ( is found:
dt(
- Yanking everything until a ) is found:
yt)
#Forcing a tab
When tabs are being replaced by spaces it can be hard to force a tab.
On INSERT mode just run: [C-v]TAB
.
This can be used to force any special character.
#FTPlugin
It is an awesome way to have different ways to configure vim according to the file type.
Check here for more details.