Vimmerãªã2013å¹´ä¸ã«è©¦ãã¦ããããæµ·å¤ç£Vim plugin 8é¸
ãã®è¨äºã¯Vim Advent Calendar 2013ã®15æ¥ç®ã®è¨äºã§ãã
14æ¥ç®ã¯joker1007ããã«ããwebapi-vimã¨BufWriteCmdã§Webä¸ã®ãªã½ã¼ã¹ãVimã§ç·¨éããã§ããã
æ¬è¨äºã§ã¯ã2013å¹´ä¸ã«è©¦ãã¦ãããæµ·å¤ç£Vim pluginã8åãç´¹ä»ãã¾ãã
ã¯ããã«
ãªãã§æµ·å¤ç£éå®ãªã®ï¼
çç±ã¯ä»¥ä¸ã®ã¨ããã§ãã
- æ¥æ¬ç£ã®Vim pluginã¯å ¥ãã¦ãã人ãå¤ãæ¥æ¬èªã§ã®æ å ±ãå¤ã(vimrcèªæ¸ä¼ã«åå ããæè¦ã¨ãã¦)
- Vim Advent Calendar 2012ãï¼å¹´ç¶ãããã¨ããããèå³æ·±ãæ¥æ¬ç£Vim pluginãå¤ãããâ¦
æµ·å¤ã§ããããæµè¡ã£ã¦ãã¦ãæ¥æ¬ã§ã¯ãã¾ãç¥ããã¦ããªãVim pluginãå¤ãã®ã§ãã£ãããªã¼ã¨æã£ãã®ã§ãæ¬è¨äºãæ¸ããã¨èãã¾ããã
ã¡ãªã¿ã«ãä»åãç´¹ä»ããã®ã¯ä»å¹´ç§ãè¦ã¤ããVim pluginã«éå®ãã¦ãã¾ãããã®ãããæµ·å¤ç£ã§ãæããããæå㪠plugin(surround.vimãsyntastic.vimãªã©ãªã©)ã«ã¤ãã¦ã¯ãç´¹ä»ãã¦ãã¾ããã
ãªããæµ·å¤ç£Vim pluginã¯æ¥æ¬ç£ã¨æ¯è¼ããã¨ã以ä¸ã®ããã«ãã¾ããè¡åã®ãããããªãVim pluginã®æ¯çãå¤ãã®ã§ã使ãã¨ãã«ã¯æ³¨æããæ¹ãããã§ãã
(ä»åãç´¹ä»ãããã®ã®ãªãã§ã¯ã»ã¨ãã©ããã¾ããã)
- pluginãã£ã¬ã¯ããªé ä¸ã«ãã¹ã¦ã®ã³ã¼ããé ç½®ãã¦ãã¦ã(pluginé ä¸ã¯èµ·åæã«èªã¿è¾¼ã¾ããããèµ·åãé ããªã)
- ããã©ã«ããã¼ãããã³ã°ãç¡å¹ååºæ¥ãªã
- ãã¼ãããã³ã°ãå¤æ´ã§ããªã
ãã¡ããå ¨é¨ãå ¨é¨ã§ã¯ãªãã§ãããæ¥æ¬ç£ã§ãåããããªãã®ãããã¾ãããæ¯è¼ããã¨å¤ãããã«æãã¾ãã
æµ·å¤ç£Vim pluginã¯ã¢ã¤ãã£ã¢ãé¢ç½ããã®ãå¤ãã®ã§ãã©ãã©ãæ°ããpluginã試ãã¦ã¿ããã¨ããããããã¾ãã 使ã£ã¦ã¿ã¦æ°ã«ãªãæãããã°pull requestãéãããææªæ°ã«å ¥ããªãæãããã°forkãã¦ãªã¬ãªã¬éæ¹é çãä½ãã®ãããã§ãã (ããã§ã足ããªããã°ãªã¬ãªã¬pluginã1ããâ¦)
ã§ã¯ãæ¬ç·¨ã«ç§»ãã¾ãã
vim-startify
Vimã®èµ·åç»é¢ã«ãç´è¿ã§éãããã¡ã¤ã«ããããã¯ãã¼ã¯ãããã¡ã¤ã«ãªã©ãã·ã§ã¼ãã«ããã§éããç»é¢ã表示ããpluginã§ãã
以ä¸ã«ã¹ã¯ãªã¼ã³ã·ã§ãããè¼ãã¾ãã
æ¬pluginãã¤ã³ã¹ãã¼ã«ãã¦ããã¨ãä¸è¨ç»åè¨è¼ã®ããã«ãVimã®èµ·åç»é¢ã«
æè¿ä½¿ã£ããã¡ã¤ã«ãªã©ã®ãã¹ã表示ããã¾ãã
該å½ãã¡ã¤ã«ã®å
é ã®æ°åãã¢ã«ãã¡ããããã¿ã¤ããããã該å½ãã¡ã¤ã«ã«
ã«ã¼ã½ã«ãããã<Enter>
ãæ¼ä¸ããã¨ã対å¿ãããã¡ã¤ã«ãéãã¾ãã
ã¤ã³ã¹ãã¼ã«ããã ãã§ã便å©ã§ãããèªåã§è¡¨ç¤ºãããã¡ã¤ã«ãã«ã¹ã¿ãã¤ãºããããã§ãã¾ãã
è¨å®é
ç®ã¯è²ã
ããã®ã§ã詳細ã¯:help startify
ã§helpãè¦ã¦ããã ãããã§ããã便å©ãªè¨å®ãï¼ã¤ã»ã©è¼ãã¦ããã¾ãã
以ä¸ã®æ§ã«ç¨æããã¦ããå¤æ°ã§è¨å®ã§ãã¾ãã
" startifyã®ãããã¼é¨åã«è¡¨ç¤ºããæååãè¨å®ãã(dateã³ãã³ããå®è¡ãã¦æ¥ä»ãè¨å®ãã¦ãã) let g:startify_custom_header = \ map(split(system('date'), '\n'), '" ". v:val') + ['',''] " ããã©ã«ãã ã¨ãæè¿ä½¿ã£ããã¡ã¤ã«ã®å é ã¯æ°åãªã®ã§ã使ç¨ããã¢ã«ãã¡ããããæå® let g:startify_custom_indices = ['f', 'g', 'h', 'r', 'i', 'o', 'b'] " ãã使ããã¡ã¤ã«ãããã¯ãã¼ã¯ã¨ãã¦ç»é²ãã¦ãã let g:startify_bookmarks = [ \ '~/.vimrc', \ '~/localrepos/blog/vac_20131215.md', \ ]
vim-multiple-cursors
Sublime Text ã®æ©è½ã¨ãã¦æåãªãmultiple cursorsã®æ©è½ãVimã«ç§»æ¤ããpluginã§ãã
multiple cursorsã®æ©è½ã¨ã¯ãæä½å¯¾è±¡ã®ç®æãè¤æ°é¸æããç¶æ ã§ãè¦è¦çã«æä½å 容ã 確èªããªããä¸æ¬æä½ã§ããæ©è½ã§ãã
Vimã¯ãæä½å¯¾è±¡ã®ç¹å®ãæä½ãããã¦æä½ç¹°ãè¿ãã¨ãããã¨ã容æãªã®ã§ãVimçã«å¸¸ç¨ã㦠便å©ãã¨ããã¨å¾®å¦ãªã¨ããã§ãããå 容çã«èå³æ·±ãã®ã§è¼ãã¾ããã
(ä¹ ãã¶ãã«ä½¿ã£ã¦ã¿ããå¤ãªæåãããã®ã§è©¦ãããæ¹ã¯ã注æãã ãã)
(æµ·å¤ã§ãä¸æçã«è©±é¡ã«ãªã£ã¦ããã®ã§githubã§ã®starã1900è¿ããã£ã¦ãã¾ããããã)
ã¡ãªã¿ã«ãVimã§ã®multiple cursorså®è£ ã¯ããã以å¤ãè²ã ããããã§ãã
ãã ãç§ã¯ä¸è¨çç±ãã使ã£ã¦ã¾ãããVimmerãªãæ¤ç´¢ãæä½ã.
ã§ã®ç¹°ãè¿ãã
ãã¯ãã:substitute
ã³ãã³ããªã©ãçµåãã¦ä½¿ã£ãã»ããéããã§ãããï¼
è¤æ°ç®æãè¦è¦çã«æä½å 容ã確èªããªããç·¨éãããã®ã§ããã°ã æä½æãæ©è½çã«ã¯ç°ãªããã®ã§ãããmanga_osyoããä½ã®over.vim ã使ã£ãæ¹ã使ãåæãè¯ãããã«æãã¾ãã
over.vimã¯ãæ¨å¹´ã®Vim Advent Calendar 2012ã§ã ãæ¬äººãç´¹ä»ããã¦ããã®ã§ãããã§ã¯ããã°è¨äºã®ãç´¹ä»ã¾ã§ã«ãã¾ãã
Vim ã® :substitute ããã¬ãã¥ã¼ãããã©ã°ã¤ã³ã¤ãã£ã
vim-expand-region
visual modeã§ã®é¸æç¯å²ããããã«å¤å´ã«ããtextobjectsã«æ¡å¼µãã¦é¸æããã縮å°ãã¦é¸æããããããã¨ãåºæ¥ãpluginã§ãã
以ä¸ã«ã¹ã¯ãªã¼ã³ã·ã§ãããè¼ãã¾ãã
ä¸è¨ã¹ã¯ãªã¼ã³ã·ã§ããã§ã¯ãåãã¯iw
ãç¶ãã¦iW
ãib
ã
il
(textobj-lineã¤ã³ã¹ãã¼ã«è¦)ã¨
æ¡å¼µãã¦ããã®å¾ãéé ã§ç¸®å°ãã¦ãã¾ãã
æ¡å¼µã縮å°ããã¨ãã«èæ ®ããtextobjectsã¯ä»¥ä¸ã®æ§ã«vim-expand-regionã®ã°ãã¼ãã«å¤æ°ã§å¤æ´ãããã¨ãã§ãã¾ãã
" ããã©ã«ãã®è¨å® let g:expand_region_text_objects = { \ 'iw' :0, \ 'iW' :0, \ 'i"' :0, \ 'i''' :0, \ 'i]' :1, \ 'ib' :1, \ 'iB' :1, \ 'il' :0, \ 'ip' :0, \ 'ie' :0, \ }
ä¸è¨ã®ããã«textobjectsããã¼ã¨ããè¾æ¸ãã°ãã¼ãã«å¤æ°ã«è¨å®ãã¾ãã
å¤ã¯ã0
ã1
ãæå®ãã¾ããtextobjectsããã¹ãããå ´åã¯1ãããªãå ´åã¯0ãæå®ãã¾ãã
ã¡ãªã¿ã«ãil
, ie
ã¯ãæ¨æºVimã®textobjectsã§ã¯ãªããVim pluginã§è¿½å å¯è½ãªtextobjectsã§ããil
ã¯textobj-lineãie
ã¯textobj-entireã©ã¡ãã便å©ãªtextobjectsãªã®ã§ã試ãã¦ã¿ããã¨ããããããã¾ãã
ã¾ããä¸è¨ã°ãã¼ãã«å¤æ°åã®å¾ãã«_{filetype}
ãã¤ãããã¨ã«ãã£ã¦ãfiletypeãã¨ã«è¨å®ãå¤ãããã¨ãã§ãã¾ãã
" Rubyã®ã¨ãã ãæå¹ãªè¨å®ã¯ä»¥ä¸ã®å¤æ°ã§è¨å®ã§ãã let g:expand_region_text_objects_ruby = { \ 'iw' :0, \ 'iW' :0, \ 'i"' :0, \ 'i''' :0, \ 'i]' :1, \ 'ib' :1, \ 'iB' :1, \ 'il' :0, \ 'ip' :0, \ 'ie' :0, \ }
è±ç·(submode.vimã使ã£ã¦å ¥åãããã)
ç§ã¯expand-regionã§ããã©ã«ãã®ãã¼ãããã³ã°ã§ãã+
ã_
ã¯ä½¿ç¨ãã¦ãã¾ããã
expand-regionã使ãæã¯ã大æµã®å ´åãç¹°ãè¿ãæ¡å¼µãè¡ãããããããã³ã°ãããã¼ã«ãã£ã¦ã¯
ç¹°ãè¿ãå
¥åããã®ãé¢åã«ãªãã¾ãã
ç§ã¯æ¡å¼µã®ãã¼ãããã³ã°ã,e
ã«è¨å®ãã¦ããã®ã§ãããåç´ã«ãã¼ãããã³ã°ããã¨ã
é£ç¶ãã¦æ¡å¼µããéã¯,e,e,e
ã¨å
¥åããå¿
è¦ããããè¥å¹²å
¥åãã¥ããã§ãã
ã¾ãã縮å°ç¨ã«å¥ã§ãã¼ãããã³ã°ããå¿
è¦ãããããããèæ
®ããã¨ãã¾ããããã³ã°ãããã¼ã¯
å¢ãããããªããããæ¡å¼µã¯,ee
ã縮å°ã¯,es
ãªã©ã¨ããå¿
è¦ãããã,ee,ee,ee
ã¨æ´ã«å
¥åãã¥ãããªãã¾ãã
ããããããªã«ãã®æä½ããã£ã¦ããéã«ç¹°ãè¿ãå ¥åããå¿ è¦ããããããªå ´åã¯ã submode.vimã使ãã¨ä¾¿å©ã§ãã
submode.vimãã¤ã³ã¹ãã¼ã«ãã¦ã
以ä¸ã®è¨å®ãããã¨ã,e
ã§expand-regionã®ã¢ã¼ãã«å
¥ãã以éã¯e
ã§æ¡å¼µã
s
ã§ç¸®å°ã§ãã¾ãã
" expand-regionã¢ã¼ãã®è¨å®ã,eã§ã¢ã¼ãã«å ¥ããeã§æ¡å¼µãsã§ç¸®å°ã§ãã call submode#enter_with('expand-region', 'nv', 'r', '<Leader>e', '<Plug>(expand_region_expand)') call submode#map('expand-region', 'nv', 'r', 'e', '<Plug>(expand_region_expand)') call submode#map('expand-region', 'nv', 'r', 's', '<Plug>(expand_region_shrink)')
ã¹ã¯ãªã¼ã³ã·ã§ããã§ãsubmode.vimã使ã£ã¦ãã¾ãã
,eeee
ãªã©ã¨ã§ãã¦ä¾¿å©ã§ãã
splitjoin.vim
1è¡ã®ã³ã¼ããæèçã«åãæå³ã®è¤æ°è¡ã®ã³ã¼ãã«ç¸äºå¤æããpluginã§ãã
以ä¸ã«ã¹ã¯ãªã¼ã³ã·ã§ãããè¼ãã¾ãã
ã¹ã¯ãªã¼ã³ã·ã§ããã§ã¯ãRubyã®ä¸è¡ã³ã¼ããè¤æ°è¡ã³ã¼ãã«å¤æãã¦ãã¾ãã
æ¬pluginã¯filetypeã«ãã£ã¦ããã¤ãã®å¤æã«ã¼ã«ãå®ç¾©ããã¦ãã¾ãã
12/15(æ¥)ç¾æç¹ã§ã¯ä»¥ä¸ã®è¨èªã®å¤æã«ã¼ã«ãå®ç¾©ããã¦ãã¾ãã
èªåãæãè¨èªã®å¤æã«ã¼ã«ããªããã°ãpull requestãéã£ã¦ã¿ã¦ã¯ãããã§ããããï¼
linediff.vim
visual modeã§2çµã®è¡ãé¸æããé¸æãã2ã¤ã®diffãvimdiffã§è¡¨ç¤ºã§ãã¾ãã
以ä¸ã«ã¹ã¯ãªã¼ã³ã·ã§ãããè¼ãã¾ãã
æ¯è¼ãããè¡ããvisual modeã§é¸æããä¸ã§ã:'<,'>Linediff
ã³ãã³ããå®è¡ãã
ããã«æ¯è¼å¯¾è±¡ã®è¡ãvisual modeã§é¸æããä¸ã§åæ§ã«ã:'<,'>Linediff
ã³ãã³ã
ãå®è¡ããã¨ã両è
ã®diffãæ°ããã¿ããã¼ã¸ãéã表示ãã¾ãã
ããã©ã«ãã§ã¯ãæ°ããã¿ããã¼ã¸ãéãåç´åå²ã§éãã¾ããã以ä¸ã® ã°ãã¼ãã«å¤æ°ãå¤æ´ãããã¨ã«ããã好ã¿ã«ãã£ã¦ã«ã¹ã¿ãã¤ãºãããã¨ãã§ãã¾ãã
" ï¼ã¤ç®ã«é¸æããè¡ãã¿ããã¼ã¸ã§éã let g:linediff_first_buffer_command = 'tabnew' " ï¼ã¤ç®ã«é¸æããè¡ãåç´åå²ãã¦æ°ããã¦ã£ã³ãã¦ã§éã let g:linediff_second_buffer_command = 'rightbelow vertical new'
textobj-word-column.vim
ååã«ããåèªãç©å½¢é¸æã§é¸æãããoperatorã®å¯¾è±¡ã¨ãã¦æå®ããããããã¨ãã§ããpluginã§ãã
以ä¸ã«ã¹ã¯ãªã¼ã³ã·ã§ãããè¼ãã¾ãã
ä¾ã§ã¯ååã«ããåèªãvic
ã§é¸æããå¾ãc
ã§ç·¨éãã¦ã¾ããåæ§ã«ãã¦dic
ã§åé¤ããããcic
ã§ç·¨éããããããã¨ãã§ãã¾ãã
ååã®åèªãä¸æ¬ãã¦ç·¨éãããã¨ãã«ãããã<C-v>
ã§ç©å½¢é¸æãã¦èª¿æ´ããªãã¦ãããã£ããé¸æã§ããã®ã§ä¾¿å©ã§ãã
ã¡ãªã¿ã«ãæ¬pluginã¯ãæåã«è¿°ã¹ããã¾ãè¡åã®è¯ããªãpluginã«å±ãããã(pluginãã£ã¬ã¯ããªé ä¸ã«ãã¹ã¦ã®ã³ã¼ããé ç½®)ã æ°ã«ãªãæ¹ã¯ãããã解æ¶ããLindanããã®forkçã使ããã¨ãæ¤è¨ãã¦ãããããããã¾ããã
ãã ãLindanããã®forkçã¯ä»¥ä¸2ç¹ã®å¤é¨ã¤ã³ã¿ã¼ãã§ã¼ã¹ãç°ãªãããã使ãã®ã§ããã°æ³¨æãå¿ è¦ã§ãã
- ããã©ã«ãã®key mappingãoriginalçã¨ç°ãªãã(originalçãã
ic
,ac
ãªã®ã«å¯¾ããLindanããã®forkçã¯ãiv
,av
) - kanaããä½ã®Vim pluginã§ãããtextobj-userãå¿ é ã¨ãªãã(å¤ãã®ä¾¿å©ãªtextobjectsãæ¬pluginãå¿ é ã¨ãã¦ããããã¤ã³ã¹ãã¼ã«ãã¦ãããã¨ããããããã¾ã)
switch.vim
æååã®ãã°ã«ãã§ãã¾ãã
以ä¸ã«ã¹ã¯ãªã¼ã³ã·ã§ãããè¼ãã¾ãã
ä¾ãã°ãtrue
ã¨ããæååä¸ã§ã:Switch
ã³ãã³ããå®è¡ãããã¨ã«ããfalse
ã¨ããæååã«å¤æ´ã§ãã¾ãã
éãåæ§ã§ãã
æ¯åã³ãã³ããå®è¡ããã®ã¯ããã©ããªã®ã§ãå®éã«ä½¿ãéã¯ç´æ¥ã³ãã³ããå®è¡ããã® ã§ã¯ãªãã以ä¸ã®æ§ã«ä½ãããã®ãã¼ã«ãããã³ã°ãã¦ä½¿ãã¾ãã (ä¸è¨ã¹ã¯ãªã¼ã³ã·ã§ããã§ããããã³ã°ãããã¼ã§æä½ãã¦ãã¾ãã)
" <Space>mã«ãswitch.vimããããã³ã° " nnoremap <Space>m <Plug>(switch-next) " 12/16 ä¿®æ£ nnoremap <Space>m :<C-u>Switch<CR>
ãªããtoggleç³»ã®pluginã¯è²ã ããã¾ãããæ¬pluginã¯ã æ£è¦è¡¨ç¾ã§ã®è¨å®ã«ããããªãæè»ãªè¨å®ãã§ãããã¨ãç¹å¾´ã§ãã ã¾ããã°ãã¼ãã«å¤æ°ã®è¾æ¸ã§è¨å®ããã®ã§ã«ã¹ã¿ãã¤ãºãæ¯è¼ç容æã§ãã
vim-signify
VCSã®å·®åãsignã§è¡¨ç¤ºããpluginã§ãã
以ä¸ã«ã¹ã¯ãªã¼ã³ã·ã§ãããè¼ãã¾ãã
:SignifyToggle
ã³ãã³ããå®è¡ããã¨ãVCSã®å·®åãVimã®signã§
表示ããã¾ãã
ã¾ããä¸è¨ã¹ã¯ãªã¼ã³ã·ã§ããã®ä¾ã§ã¯ã次ã®å·®åãåã®å·®å
ã¸ã®ç§»åããããã³ã°ãããã¼ã§è¡ã£ã¦ãã¾ãã
å·®åã®ç§»åã¯ä»¥ä¸ã®æ§ã«ãã¼ã«ãããã³ã°ãã¦ããã¨ä¾¿å©ã§ãã
ã¾ããåããã¦:SignifyToggle
ããããã³ã°ãã¦ããã¨ä¾¿å©ã§ãããã
" 次ã®å·®åç®æã«ç§»å nmap <Leader>gj <Plug>(signify-next-hunk)zz " åã®å·®åç®æã«ç§»å nmap <Leader>gk <Plug>(signify-prev-hunk)zz " å·®åç®æããã¤ã©ã¤ã nmap <Leader>gh <Plug>(signify-toggle-highlight) " å·®å表示ããã°ã«ãã(:SignifyToggleã³ãã³ãã¨åã) nmap <Leader>gt <Plug>(signify-toggle)
ãã¾ã
æ°ããVim pluginãçºæããæ¹æ³
æ°ããVim pluginãçºæããã«ã¯ä»¥ä¸ã®æ§ãªæ¹æ³ãããã¾ãã
- vim.orgã§Scriptsãã¼ã¸ãçºãã
- vim-jpã§ãæåVimãã¬ã¸ã³ãçºãã
- githubã§Trendingãçºãã
- vimrcèªæ¸ä¼ã«åå ãã
çããã試ãã¦ã¿ã¦ãã ãããããã¦é¢ç½ãããªpluginããã£ãã æ¯éVim Advent Calendarã«æ稿ãã¦ã¿ã¦ãã ããã
ã¡ãªã¿ã«ãä¸è¨ã®ä¸ã§ã¯ãvimrcèªæ¸ä¼ã«åå ããã ãç¹ã«ãå§ãã§ãã
ä»åãç´¹ä»ããpluginã®ä½è
ä»åãç´¹ä»ããpluginã¯ããããè¦ã¦ã¿ãã¨ãä½è ãåãæ¹ã®ãã®ãçµæ§ããã¾ãã
ä½è ãã¨ã«ã¾ã¨ãã¦ã¿ã¾ããã
AndrewRadevããã®pluginã3ã¤ãããã¾ããï½ é¢ç½ãpluginãæ¸ãæ¹ã¯ãä»ã«ãé¢ç½ãpluginãæ¸ãã¦ããå¯è½æ§ãé«ãã®ã§ã ä½è ã®ãªãã¸ããªãçºãã¦ã¿ãã®ãè¯ãããããã¾ããã
ã¾ã¨ã
以ä¸ãã2013å¹´ä¸ã«è©¦ãã¦ããããæµ·å¤ç£Vim plugin 8é¸ã§ããã
æ¬è¨äºã§ç´¹ä»ãã以å¤ã«ãæµ·å¤ç£Vim pluginã¯ããããããã®ã§ã èå³ãããã°ãããã調ã¹ã¦è¦ã¦ã¯ãããã§ããããï¼
(ããã¦Vim Advent Calendar 2013ã®ãã¿ã¨ããã¨ä¸ç³äºé³¥)
æ¬é¡ã¨ã¯ããã¾ãããVimã¬ãã«ãä¸ããã®ã§vimrcèªæ¸ä¼ã«åå ãããã¨ããããããã¾ããæ¯é±åææ¥23æãããã£ã¦ã¾ãã
ããã§ã¯Vim Advent Calendar 2013ã®15æ¥ç®ãçµããã¾ãã
ææ¥ã®Vim Advent Calendar 2013ã¯c0hamaããã§ãã