snippets/old_snippets/vim-placeholders.en.md

924 B

title date draft snippet_types
custom placeholders solution 2020-01-12T00:59:03+01:00 false
vim

This little bit of magic I believe I picked up from watching a Luke Smith video. The point is to leave placeholders in the form of the text "<++>" in your code/writing then quickly snap to and fill them in later.

" placeholder magic
nnoremap <Space><Space> <Esc>/<++<CR>"_c4l
nnoremap <Space>n <Esc>l/<++><CR>h
" always fill p reg with <++>
:autocmd VimEnter * :call setreg('p', '<++>')
  1. Thanks to the vim enter hook the magic placeholder text is always in my p register so its easy to put with <"><p>
  2. Then to jump to the next placeholder and immediately start editing it with a simple <Space><Space>

{{< asciicast-with-caption id="293101" title="placeholders demo" >}}

source: