Vim notes

Start here

Neovim + Lua

Jumps

I’ve been familiar with c-o and c-i for a while, but I have not used them effectively, some things were missing.

  • gi — Insert text in the same position as where Insert mode was stopped last time in the current buffer.

The following mappings simplify working with relativenumber and <count>j/<count>k:

" Change j and k to add movements to the jump list.
nnoremap <expr> k (v:count > 1 ? "m'". v:count : '') . 'gk'
nnoremap <expr> j (v:count > 1 ? "m'". v:count : '') . 'gj'

Source: reddit post

inoremap and white spaces

Just found out that white spaces matter in inoremap mappings, the following are not equivalent (notice the space after <Esc>):

inoremap <c-q> <Esc> :call Quit()<cr>
inoremap <c-q> <Esc>:call Quit()<cr>

The extra white space after <Esc> was causing the command to fail when positioned on the last character of a file. I don’t know why, but it works fine after removing the space.


Posted

in

,

by

Tags: