LoginSignup
4
3

More than 5 years have passed since last update.

[Vim] neosnippetで使うsnippet自作

Posted at

NeoSnippetをインストール

vimrc
NeoBundle 'Shougo/neosnippet.vim', {
      \ 'depends' : ['Shougo/neosnippet-snippets'],
      \ 'insert' : 1,
      \ 'filetypes' : 'snippet',
      \ 'unite_sources' : [
      \ 'neosnippet', 'neosnippet/user', 'neosnippet/runtime'],
      \ }

自作スニペットを格納するディレクトリを設定

vimrc
let g:neosnippet#snippets_directory = '$HOME/.vim/snippets/'

スニペットを追加する

追加する対象のプログラミング言語のファイルを開く

vim sample.rb

NeoSnippetEditコマンドを実行する

:NeoSnippetEdit

$HOME/.vim/snippets/ruby.snipが開くので編集する

snippets/ruby.snip
snippet logger
  Rails.logger.debug '${1} ---------------------'
  Rails.logger.debug $1

保存して.rbファイルで使用する

vim_snip.gif

${1}に入力された値がそのまま$1の部分にコピーされます。このあたりはお好みで使ったり使わなかったりするといいと思います。

以上

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3