Build your custom Vim from scratch

VIM

We have been there… We have done that… Kinda.
After an update my config kinda broke. So I thought it was time for a long overdue Neovim config from scratch.
I will try to stay as minimalistic as possible while (probably) still using a plugin manager.

Initial Setup

We will use vim, nvim, neovim indifferently in this article.
If you like to play around and try different configurations, I would suggest adding the following aliases in your .zshrc. The “custom-nvim” here refers to a folder using that name in .config.

alias vim=nvim
alias vv='NVIM_APPNAME=custom-nvim nvim'

For more information on switching configs, I would recommend this website.

sudo pacman -S neovim

Once nvim is installed, open an empty document type the following command to know where vim is looking for its configuration.

:echo stdpath('config')

Config

First draft for minimalist config can be found here

Vim motions

Comments

command action exemple
gcc comment code  
gc + motion comment selection via motion gcap : comment all paragraphe
gc in visual mode comment visual selection  
[n]gcc comment n lines 5gcc : comment 5 lines

Edit

command action exemple
ci” change inside “”  
ci( change inside ()  

Selection

command action exemple
p paragraphe  
a around va{ : print{“Hello son”}
i inside vi{ : print{“Hello son”}

Text objects

command action exemple
p paragraphe  
w word  
s sentence  
{ ( [ < blocs  
” ‘ ` quotes  
t tags html  

Motions

Character

command action exemple
h left  
j down  
k up  
l right  

Word

command action exemple
w word : first letter of next word (spaces and non alphanum count as separator)  
W WORD : first letter of next WORD (only spaces count as separator)  
b back : start of previous word  
B BACK : start of previous WORD  
e end : end of next word  
E end : end of next WORD  
ge end of previous word  

Line

command action exemple
0 col 0, absolute beginning  
^ first non empyt char on the line  
$ end of line  
g_ last non empty chart on the line  
+ first non empty chart on the next line  
- first non empty chart on the previous line  

Screen

H, M, L only move the cursor.
Ctrl + [d/u/f/b] move the cursor and scroll

command action exemple
H high : jump to top of the screen  
M middle : jump to middle of the screen  
L low : jump to botton of the screen  
Ctrl + d down half a page  
Ctrl + u up half a page  
Ctrl + f down a page  
Ctrl + b up a page  

Vertical

command action exemple
gg start of the file  
G end of the file  
g go to line  
{ next paragraph  
} previous paragraph  
( next sentence  
) previous sentence  
[[ next section  
]] previous section  
% jump to next delimiter. could be (), [], {}  
command action exemple
f find : jump on char fo : “The absolute best”
t until : jump before char to : “The absolute best”
/ search forward  
n next (forward)  
? search backward  
N next (backward)  
* search the next word under the cursor  
# search the previous word under the cursor  

Marks

command action exemple
` jump to mark postion (line and col). MAJ are global marks and min are marks local to the buffer  
jump to the mark line only  
`. jump to last modification  
`^ jump to last insertion mode  
`< start of visual selection  
`> end of visual selection  
`[ start of last yank/change  
`] end of last yank/change  

Other

command action exemple
gd go to variable definition  
gf open file which path is under the cursor import “./monmodule”
gi last place where insertion mode was used  
`. jump to last modification