www-gem words
This post is part of the #(Neo)vim topic(s)

Few customized (Neo)vim keybindings

I am sharing here few keybindings that helped me daily.

As you know, defining a keybinding in vim is as simple as adding this line of in your vimrc or init.lua:

modemap key command # for vimrc

vim.keymap.set( 'mode', 'key', 'command') # for init.lua

# where:
# mode is n (for normal), i (for insert), v (for visual)
# key is your keypress
# command is the command to be executed by vim

Take care of your eyes

Adding zz to some default commands allow the current line to be automatically placed in the middle of the screen. This greatly reduces the fatigue on the eyes and helps finding things easily.

key command action
j jzz move down one line
k kzz move up one line
n nzz jump to the next search match
N Nzz jump to the previous search match

Work on your files easily

For these ones I can’t share all my personal keybindings but here are few that shorten long commands and that I use quite often:

command action
:so reload vim config on the fly
:History open a list of previously opened files
:%s//g write the replace command so you only have to
type the text to be replaced (to be used in normal/insert mode)
:s//g write the replace command so you only have to
type the text to be replaced (to be used in visual mode)

Makes visual keybindings act as the delete/yank ones

There is certainly a good reason why hitting vv or V doesn’t act like dd, yy, or D and Y but that confuses me. So I’ve made this happen:

key command action
vv 0v$ select the entire line
V v$ select the end of the line


Interact with this post using Mastodon or

Comment on wwwgem's post

Copy and paste this URL into the search field of your favourite Fediverse app or the web interface of your Mastodon server.