clever-f.vim ã§ã«ã¼ã½ã«ã®æ¨ªç§»åã便å©ã«ãã
ãã®è¨äºã¯Vim Advent Calendar 2012 291 æ¥ç®ã®è¨äºã«ãªãã¾ãï¼å¾ã ã«æ°æ¸©ãç§ããããªãï¼çµãããè¦ãã¦ãã¦ã¾ããï¼
ãã®è¨äºã§ã¯ï¼Vim ã® f
ãã¼ãæ¡å¼µãã clever-f.vim ã¨ãããã©ã°ã¤ã³ãç´¹ä»ãã¾ãï¼
ä»ã¾ã§ tekkoc ããã thinca ããã«ç´¹ä»ãã¦ããã ããã®ã§ããï¼èªåã§ç´¹ä»ãã¦ããªãã£ãã®ã¨ï¼è²ã
ã¨æ©è½è¿½å ãããã®ã§ä»åææ°ã®å
容ã§ç´¹ä»ãããã¨ã«ãã¾ããï¼
- clever-f.vimã§fé£æã便å©ããã件 - tekkoc'blog
- clever-f.vim ãéæ¹é ãã話 - æ°¸é ã«æªå®æ
Vim ã® f{char}
ï¼ä½¿ã£ã¦ã¾ããï¼
Vim ã§ã®æ¨ªç§»åã¯ä½ã使ã£ã¦ããã§ããããï¼h
ã l
ã§ã®1æåãã¤ã®ç§»åã w
ã b
ã§ã®åèªåä½ã§ã®ç§»åãªã©è²ã
ããã¾ããï¼å人çã«ãããããªã®ã f
㨠F
ã§ãï¼
Vim ã® f{char}
ãã¼ã¯ï¼{char}
ã«ä»»æã®1æåãå
¥ãï¼ç¾å¨ã®ã«ã¼ã½ã«è¡å
ã§å³æ¹åã« æåã«ç¾ãã {char}
ã«ç§»åãã¾ãï¼ã¾ãï¼;
ã§ç´åã®æ¤ç´¢ãç¹°ãè¿ããã¨ãã§ãï¼è¡ãéããå ´åãªã©ã¯ ,
ã§æ»ããã¨ãã§ãã¾ãï¼ ã¾ãï¼ãã以å¤ã«ãéæ¹åã«åã F{char}
ãï¼{char}
ã®æåã¾ã§ç§»åãã t{char}
ããã³ T{char}
ã¨ãã£ããããã³ã°ã Vim ã®ããã©ã«ãã§ç¨æããã¦ãã¾ãï¼
ï¼èµ¤åãã«ã¼ã½ã«ä½ç½®ï¼
poyo hoge huga
ããâfh
poyo hoge huga
ããâ;
poyo hoge huga
è¡ãé·ãã¨ããï¼è¡å
ã«è¨å·ãå¤ãæï¼l
ã w
ã«ãã移åãããããªãå°ãªãæéµæ°ã§ç®çã®ä½ç½®ã¾ã§ç§»åã§ãã¾ããï¼
;
ã§ç¹°ãè¿ãå¿ è¦ãçããã¨ãã«æèçã«f
ãã;
ã«ãã¼ãæ¼ãå¤ããªãã¨ãããªãf
ã,
ï¼;
ã¨ããã¨ã¦ãæ¼ããããä½ç½®ã®ãã¼ã3ã¤ã使ã£ã¦ãã¾ã
ã¨ããåé¡ãããã¾ãï¼ç¹ã«å¾è
ã®çç±ã§ f
ã ,
ï¼;
ãæ½°ãã¦ãã¾ã£ã¦ããè¨å®ãããè¦ã¾ãï¼
f{char}
ã«ãã移åãå¼·åã«ãã clever-f.vim
clever-f.vim ã¯åç« ã® f
ã®æ©è½ãå¼·åããããã®ãã©ã°ã¤ã³ã§ãï¼æåã« f{char}
ã§ç§»åãããã¨ï¼ãã®ã¾ã¾ f
ã§é æ¹åï¼F
ã§éæ¹åã«ç´åã®ç§»åãç¹°ãè¿ããã¨ãã§ãã¾ãï¼ããã«ããï¼ç®çã®ä»»æã®ç®æã« f{char}ff...
ã§å°éãããã¨ãã§ãã¾ããï¼ã«ã¼ã½ã«ãé²ããããå ´åã§ã F
ã§æ»ããã¨ãã§ãã¾ãï¼ã¾ãï¼;
㨠,
ã¯ä½¿ããªãã®ã§ï¼èªåã®å¥½ããªä»ã®ãããã³ã°ã«ä½¿ããã¨ãã§ãã¾ãï¼ããã«ï¼ãªãªã¸ãã«ã®f
ã¨éãï¼w
ã¨åæ§ã«è¡ãã¾ããã§ç§»åã§ãã¾ãï¼ãã¡ããï¼F{char}
ï¼t{char}
ï¼T{char}
ã§ãåãæåãå®è£
ããã¦ãã¾ãï¼
ãªãï¼é£ç¶ã§ f{char}
ãå
¥åãããã¨ã¯ã§ããªããªãã¾ããï¼f{char}
ãç¹°ãè¿ãããå ´åã¯ããããç¡ãä¸ï¼h
ã l
ã§1æååã§ãã«ã¼ã½ã«ãåããã°è¯ãã®ã§ãã¾ãåé¡ã«ã¯ãªãã¾ããï¼
;
ã«ããç¹°ãè¿ãã®é¢åãããããæå㯠nnoremap ff ;
ã¨ããåç´ãªãããã³ã°ããã¦ããã®ããã©ã°ã¤ã³åãï¼thinca ããã®éæ¹é ãªã©ãçµã¦ãããªãã«ãã£ããããä½ãã«ãªã£ã¦ããã¨æãã¾ãï¼
clever-f.vim ã®æåãã«ã¹ã¿ãã¤ãºãã
clever-f.vim ã§ã¯ï¼å¤æ°ãè¨å®ãããã¨ã§æ¤ç´¢ã®æåãã«ã¹ã¿ãã¤ãºãããã¨ãã§ãã¾ãï¼clever-f.vim ã®æ¤ç´¢ã®ããã©ã«ãã®æåã¯è¡ãã¾ããã§ç§»åã§ããç¹ãé¤ãã¦ãªãªã¸ãã«ã® f
ã¨åãã«ãªã£ã¦ããã®ã§ï¼.vimrc ã§èªå好ã¿ã«ã«ã¹ã¿ãã¤ãºããããã«ãã¾ãï¼
ignore caseï¼smart case
ä¸è¬çã«å¤§æåã®å
¥åã«ã¯ã·ãããæ¼ããªãã¨ãããªãããï¼f{大æå}
ã¯å°ãä¸ä¾¿ã§ãï¼ãªã®ã§ï¼clever-f.vim ã§ã¯å¤§æåå°æåãåºå¥ããã«æ¤ç´¢ãããã¨ãã§ãã¾ãï¼
ãã¹ã¦ã®å ´åã«å¤§æåå°æåãç¡è¦ãããå ´å㯠g:clever_f_ignore_case
ã 1
ã«ï¼å¤§æåãå
¥åããæã®ã¿å¤§æåå°æåãåºå¥ãããå ´å㯠g:clever_f_smart_case
ã 1
ã«ããã¨æå¹ã«ãªãã¾ãï¼
migemo ã£ã½ãæ¤ç´¢
f
ãããã³ã°ã®åé¡ç¹ã¨ãã¦ï¼ã¢ã«ãã¡ãããã¨è¨å·ããå
¥åã§ããªãã¨ããç¹ãæãããã¾ãï¼ãããï¼æ¥æ¬èªã®æç« ã§ãã£ã¦ã f{char}
ã§ç§»åãããã¨æãããã¨ãããã¾ãï¼
ããã§ï¼clever-f.vim ã§ã¯ migemo ã£ã½ãæ¤ç´¢ãå®è£
ãã¦ãã¾ãï¼
migemo ã¨ã¯ï¼ãã¼ãåã®å
¥åã§æ¥æ¬èªãæ¤ç´¢ããããã®ãã¼ã«ã§ãï¼clever-f.vim ã§ã¯ migemo ã§çæããæ£è¦è¡¨ç¾ããã©ã°ã¤ã³å
ã«æã£ã¦ããï¼ä¾ãã° fm
ã¨å
¥åãã㨠ã
ã«ããããããããªæ¤ç´¢ãã§ãã¾ãï¼ãã®æ©è½ã¯ g:clever_f_use_migemo
ã 1
ã«ããã¨æå¹ã«ãªãã¾ãï¼ãªãï¼cmigemo ãªã©ã®ãã¼ã«ã¯ä¸è¦ã§ãï¼f
ã®ãã¨ã®ã¢ã«ãã¡ããã1æåã ãã§ããããããã®ã§äºæ³å¤ã®æåã«ãããããããããã¨ãããã¾ãã便å©ã§ãï¼
è¡ãã¾ããã§æ¤ç´¢ããªã
åç« ã§ãæ¸ããããã«ï¼clever-f.vim ã¯è¡ãè¶
ã㦠{char}
ãæ¤ç´¢ãã¾ããï¼ãªãªã¸ãã«ã® f
ã®æåã«åããã¦ç¾å¨è¡ã®ã¿ã§æ¤ç´¢ãããå ´åãããã¾ãï¼
ãã®å ´å㯠g:clever_f_across_no_line
ã 1
ã«è¨å®ãã¾ãï¼
ç´°ãã話ã§ããï¼ä¸è¨ã® migemo æ¤ç´¢ãæå¹ã«ãã¦ããå ´åï¼migemo æ¤ç´¢ãç¾å¨è¡ã«ãã«ããã¤ãæåãããã¨ãã®ã¿æå¹ã«ãªããªã©ï¼å°ãæåãè³¢ããªã£ããããã¾ãï¼
f
㨠F
ã®æ¤ç´¢æ¹åãåºå®ãã
f{char}
ã®ãã¨ã®ç¹°ãè¿ã㯠f
ãé æ¹åï¼F
ãéæ¹åã¨ãªã£ã¦ããï¼F{char}
ã§æ¤ç´¢ããã¨å·¦æ¹åï¼é æ¹åï¼ã¸ã®ç¹°ãè¿ã㯠f
ï¼å³æ¹åï¼éæ¹åï¼ã¸ã®ç¹°ãè¿ãã¯F
ã¨ãªãã¾ãï¼
ããã¯ï¼é æ¹åã®ã»ããæ¼ãé »åº¦ãå¤ãããï¼æ¼ãããã f
ã使ãããã«ãã¦ããããã§ãï¼
ã§ããï¼f
ã¯å¿
ãå³æ¹åã«ç§»åï¼F
ã¯å¿
ãå·¦æ¹åã«ç§»åããããã«ããã»ããæåãåç´ã«ãªãåãããããã®ãäºå®ãªã®ã§ï¼g:clever_f_fix_key_direction
ã 1
ã«è¨å®ããã¨ãã®ãããªæåã«ãããã¨ãã§ãã¾ãï¼
ä»»æã®è¨å·ã«ãããããæåãè¨å®ãã
è¨å·ã¯ã·ãããã¼ãæ¼ããªããå
¥åããªããã°ãªããªãã£ããï¼è·é¢ãé ãã£ããã§æ¼ãã®ãé¢åãªãã¨ãå¤ã
ããã¾ãï¼
ãã㧠clever-f.vim ã§ã¯ä»»æã®è¨å·ã«ãããããæåãè¨å®ã§ãã¾ãï¼ä¾ãã° let g:clever_f_chars_match_any_signs = ';'
ã¨ããã¨ï¼f;
ã§ä»»æã®è¨å·ã«ããããã¾ãï¼
é¡ä¼¼ã®ãã©ã°ã¤ã³
ã«ã¼ã½ã«ç§»åç³»ã®ãã©ã°ã¤ã³ã®ä¸ã§ï¼clever-f.vim ã«è¿ããã®ãããã¯ã¢ãããã¦æ¯è¼ãã¦ã¿ã¾ããï¼
vim-easymotion
vim-easymotion 㯠ç»é¢ä¸ã«ã©ãã«ãæ£ãã°ãï¼è¡ãããã©ãã«ãå
¥åãããã¨ã§ã«ã¼ã½ã«ã移åããããã©ã°ã¤ã³ã§ãï¼
ããªãã¨ãªããã®è¾ºãã«è¡ããããã¨ãã«ã¨ã¦ã便å©ã§ãï¼
clever-f.vim ã横æ¹åã®ç§»åãè¡ãã®ã«å¯¾ãï¼vim-easymotion ã¯ç¸¦ï¼æããªã©ãã«ãã¼ãã¦ãã¾ããï¼clever-f.vim ã¯ç®çä½ç½®ã®æåã ããè¦ã¦ f{char}ff...
ã¨å
¥åããã®ã«å¯¾ã㦠vim-easymotion 㯠ã©ãã«ãåºãâã©ã®ã©ãã«ãä¸çªè¡ãããå ´æã«è¿ããå¤æããã©ãã«ãå
¥åãã ã¨ããã¹ããããè¸ãããï¼è¥å¹²é¢åã§ãï¼
使ã£ã¦ã¿ãæè¦ã¨ãã¦ã¯ï¼å°ãé ç®ã®ã¨ããã«é£ã³ããã¨ãã«ä¾¿å©ã§ããï¼æ¨ªç§»åã§ã¯ clever-f.vim ã®ã»ããèãããã¨ãå°ãªã便å©ãªã®ã§ä½¿ãåããã¨è¯ãæãã§ãï¼
vim-seek
2æåå
¥åãã¦ã«ã¼ã½ã«ã移åãããã©ã°ã¤ã³ã§ãï¼s{char}{char}
ã§ç§»åãã¾ãï¼å½ç¶ï¼2æåå
¥åããåæéããããã¾ããï¼ä¸çºã§ã¸ã£ã³ãã§ããå¯è½æ§ã¯é«ããªãã¾ãï¼
ä¸çºã§ç®çä½ç½®ã¾ã§ã¸ã£ã³ããããã¨ãæ³å®ãã¦ãããããç¹°ãè¿ããå®è£
ããã¦ããªãã®ã¨ï¼åæã«å¤ãã®ãããã³ã°ãå®ç¾©ããã®ãé£ç¹ã ã¨æãã¾ããï¼
ã¾ã¨ã
f{char}
ãããã³ã°ãå¼·åãã clever-f.vim ãç´¹ä»ãã¾ããï¼æåå³åã§ããï¼3ã¯ã¼ã以ä¸é¢ãã¦ããã°ã¨ãããã f
ãæ¼ãã¨ãã£ãæãã§ä½¿ã£ã¦ãã¦ï¼ããã使ãå§ãã¦ãã横æ¹åã®ç§»åãããªãæ¹åããããã«æãã¾ããï¼æ¯é試ãã¦ããã ããã¨è¯ãã¨æãã¾ãï¼ã«ã¼ã½ã«ç§»åã¯ã³ã¼ãã£ã³ã°ã®å¹çã«ç´çµããã¨æã£ã¦ããã®ã§ï¼ãããããæ¹åãã¦ããããã§ãï¼