【skill】Use snippets in vim

0. Introduce

Code snippet is much useful to speed up coding.It allows concentrating more on the main logic. It is code reuse for programmers.

1. Install

  1. Install vim. You may refer to this blog.
  2. If you have already vim installed, add below to .vimrc and PluginInstall.
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
  • 1
  • 2
  • 3
  • 4
  • 5

2. How

After installation, everything is ready. Have a look at this gif:

Cool, HA?

Use three kinds of keys:
1. tab to trigger expand.
2. control+b to jump forward.
3. control+z to jump backward.
Of course, you can change them in vimrc.

3. More snippets

You can refer to here to find how many snippets you can use. They are also stored in ~/.vim/bundle/vim-snippets/snippets.

If you want to add you own snippets, create a folder named UltiSnips in ~/.vim/. And add you own snippets file in that folder. Refer to those examples to find how to write snippets.


Ref:link

0. Introduce

Code snippet is much useful to speed up coding.It allows concentrating more on the main logic. It is code reuse for programmers.

1. Install

  1. Install vim. You may refer to this blog.
  2. If you have already vim installed, add below to .vimrc and PluginInstall.
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
  • 1
  • 2
  • 3
  • 4
  • 5

2. How

After installation, everything is ready. Have a look at this gif:

Cool, HA?

Use three kinds of keys:
1. tab to trigger expand.
2. control+b to jump forward.
3. control+z to jump backward.
Of course, you can change them in vimrc.

3. More snippets

You can refer to here to find how many snippets you can use. They are also stored in ~/.vim/bundle/vim-snippets/snippets.

If you want to add you own snippets, create a folder named UltiSnips in ~/.vim/. And add you own snippets file in that folder. Refer to those examples to find how to write snippets.


Ref:link

猜你喜欢

转载自blog.csdn.net/qq_30214939/article/details/78507530
Vim