28 lines
924 B
Markdown
28 lines
924 B
Markdown
---
|
|
title: "custom placeholders solution"
|
|
date: 2020-01-12T00:59:03+01:00
|
|
draft: false
|
|
snippet_types: ["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.
|
|
|
|
```vim script
|
|
" 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>**
|
|
1. 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:
|
|
|
|
- [Luke Smith Youtube Channel](https://www.youtube.com/channel/UC2eYFnH61tmytImy1mTYvhA)
|