Skip to content

Vim Snippets

Get the name of the file shown

:f (:file) will do same as <C-G>. :f! will give a untruncated version, if applicable.

Run a command when opening vim

nvim -c ':DiffViewOpen'

Run lua snippets

Run lua snippet within neovim with :lua <your snippet>. Useful to test the commands before binding it to keys.

Bind a lua function to a key binding

key.set({'n'}, 't', ":lua require('neotest')<cr>", {desc = 'Run the closest test'})

Use relativenumber

If you enable the relativenumber configuration you'll see how to move around with 10j or 10k.