ãã¿ã¼Vimã¨ãã¦Atomã使ã
ãã®è¨äºã¯ATOM-editor Advent Carendar 2015ã®15æ¥ç®ã®è¨äºã§ãã
2016/03/01 追è¨
vim-mode-plus, vim風ãã¼ãããã³ã°ã®çºè¦ã«ããè²ã 追è¨ãã¾ããã
ã¯ããã«
ã©ãããVimã®æ¹ãããã£ã¦ãã¾ããã
æ§ã
ãªã¨ãã£ã¿ãIDEã«Vimãã©ã°ã¤ã³ããããã¨ããåããããã«ãã©ããªç°å¢ã«ç§»ããã¨ãVimã¨å
±ã«çããVimæ好è
ã¯ä¸çä¸ã«ããããããããã§ãã
èªåããã®ãã¡ã®ä¸äººã§ã¡ã¤ã³ã¨ãã£ã¿ã¯Vimã使ããIDEã使ãã¨ããVimãã©ã°ã¤ã³ãææ¾ããªãã£ãã®ã§ããããããã«2015å¹´ã«ããªã£ããæµè¡ãã®ã¨ãã£ã¿ã試ãã¦ã¿ããã¨ãããã¨ã§ä»å¹´ããAtomã«å
¥éãã¦ã¿ã¾ããã
Atomã«ãä¾ã«æ¼ããVimãã©ã°ã¤ã³ãããã®ã§åæ¥ããVimåã«ææ¦ããããè²ã
ã¨è¶³ããªãæ©è½ã«ç´å¾ã§ããSublimeã®ã¨ãã®ããã«è«¦ãããã¦ããã®ã§ãããããã±ã¼ã¸ãè²ã
æ¢ããã¨ãã大ä½èªåãæºè¶³ããã¨ããã¾ã§Vimåãããã¨ãã§ãã¾ãããä»åã¯ãã®ã¨ãã«è¦ã¤ããããã±ã¼ã¸ãç´¹ä»ãããã¨æãã¾ãã
ï¼ã»ã¨ãã©ã®ããã±ã¼ã¸ã®ãã¼ã¸ã«gifã¢ãã¡ãããã¾ãã®ã§ããã²ãªã³ã¯ãè¦ãã¦ã¿ã¦ãã ããã
èªåã®ç´¹ä»ããè¦ãã»ããåããããããã¨æãã¾ãã
Vimæ¨æºæ©è½ãå®ç¾ããããã±ã¼ã¸
vim-mode
2016/03/01 追è¨
vim-modeããè²ã
æ©è½ãæ¡å¼µããã¦ããvim-mode-plusã«ä¹ãæãã¾ãã
ã¾ãã¯ãããå ¥ããªãã¨å§ã¾ããªãã§ãã
æ©è½ | ãã¼ |
---|---|
ã«ã¼ã½ã«ç§»å | h, j, k, l, gg, G, ctrl+j, ctrl+k |
ã¤ã³ãµã¼ãã¢ã¼ã | i, I, o, O |
ãã¸ã¥ã¢ã«ã¢ã¼ã | v, V |
ã¤ã³ã¯ | y, yy, yaw, yiw |
åé¤ | d, dd, daw, diwï¼åé¤ãã¤ã¤insertã¢ã¼ãã«ãã'c'ã使ç¨å¯è½ï¼ |
ãã¼ã¹ã | p, P |
undo/redo | u, R |
æ¤ç´¢ | /, * ï¼æ¤ç´¢å¾ã®n, Nãå¯è½ï¼ |
Paneã®ç§»å | ctrl+h,j,k,l |
æ°å¤ã®ã¤ã³ã¯ãªã¡ã³ã/ãã¯ãªã¡ã³ã | ctrl+a, ctrl+x |
ç¹°ãè¿ã | .(ã³ãã³ï¼ |
å®ç¾ã§ãã¦ããæ©è½ä¸è¦§ãã¼ã¸ãè¦ã¤ãããªãã£ãã®ã§ãã©ãã¾ã§æ¬å®¶Vimã®æåãã«ãã¼ã§ãã¦ããã®ãæ£ç¢ºã«ã¯åããã¾ããããã®ãããã®åºæ¬æä½ã¯æãã¦ããããã§ãã
vimã§æ¤ç´¢çµæããã¤ã©ã¤ããããhlsearchæ©è½ãç¡ããã¨ãå人çã«ã¯é常ã«æããã®ã§ãããPull requestãè¦ãéãç²¾åçã«éçºãç¶ãããã¦ããã®ã§ãã®ãã¡å®ç¾ãããã§ãããã
ex-mode
2016/03/01 追è¨
vim-modeããvim-mode-plusã«ä¹ãæããex-modeã使ããªããªã£ãã®ã§ä»£ããã«ãã¼ãããã³ã°ã使ãæ¹æ³ã追è¨ãã¾ãã
vimã¨ããååãä»ãã¦ããªãã®ã§æåã¯æ°ãä»ãã¾ããã§ãããvimã®exã¢ã¼ããå®ç¾ããããã±ã¼ã¸ã§ãã
‘:'ãå
¥åãããã¨ã§æ¬å®¶Vimã¨åãããã«:w, :wq, :q, :sp, :vspãªã©ã使ãã¾ãã
vimã§ä½æ¥ï¼ç¹ã«ã³ã¼ããªã¼ãã£ã³ã°ï¼ããã¨ãã¯ã¬ã³ã¬ã³ç»é¢åå²ããã¦ã«ã¼ã½ã«ç§»åããã¾ãã£ã¦ããã®ã§ãex-modeãå
¥ãããã¨ã§atomã§ãåããã¨ãã§ããã®ãæåçã§ããã
ã¡ãªã¿ã«:s, :%sã«ããç½®æãä¸å¿å¯è½ãªã®ã§ãããèªåã§è©¦ããã¨ãã以ä¸ã®æ©è½ãå®è£ ããã¦ããªãããæ®å¿µãªããå®ç¨çã¨ã¯è¨ãé£ãã§ãã
- æ¤ç´¢çµæã使ã£ãçç¥è¨æ³ï¼fooãæ¤ç´¢å¾ã«barã«ç½®æãããå ´åãæ¬å®¶vimã§ããã°:s//bar/ã§ç½®æã§ããï¼
- ã«ã¼ã½ã«ä¸ã®åèªãããã¹ãããã¯ã¹ã«ãã¼ã¹ãï¼æ¬å®¶vimã§ã®ctrl+r, wï¼
- ç½®æãªãã·ã§ã³ã®g, c
- ãã¸ã¥ã¢ã«ã¢ã¼ãã§ã®é¸æç¯å²éå®ã§ã®ç½®æ
vim-mode-visual-block
2016/03/01 追è¨
vim-mode-plusã«ã¯å
ã
ãã¸ã¥ã¢ã«ã¢ã¼ããçµã¿è¾¼ã¾ãã¦ããã®ã§èªåã¯ä¸è¦ã«ãªãã¾ããã
æ¬å®¶vimã§ã®ç©å½¢ãã¸ã¥ã¢ã«ã¢ã¼ããå®ç¾ããããã±ã¼ã¸ãç¥ã
ç©å½¢ã¢ã¼ãé¸æããã®'I'ã'A'ã§insertã¢ã¼ãã«ç§»è¡ããä¸æ¬ç·¨éãå®ç¾ãã¦ã¾ã
cursor-history
vim-mode-visual-blockã¨åãt9mdããã«ããæ¬å®¶vimã®ctrl-oãå®ç¾ããããã±ã¼ã¸ãç¥ã
Highlight Selected
å ã ã¯SublimeTextã§åèªãããã«ã¯ãªãã¯ããã¨åãåèªãå ¨ã¦ãã¤ã©ã¤ããã¦ãããã¨ããæ©è½ã®ã³ãã¼ã®ããã§ããã vim-modeã§ã¯ç¾ç¶æ¤ç´¢çµæã®ãã¤ã©ã¤ããã§ããªãã®ã§ãã®ä»£ããã¨ãã¦ä½¿ã£ã¦ãã¾ãã
sort-lines
é¸æããç¯å²ã®è¡ãã½ã¼ããã¦ããã¾ãã
ãã¾ã«ãä¸è©±ã«ãªãvimã®:sortã¨åãã§ããã
æåãªVimãã©ã°ã¤ã³ã®ä»£æ¿
linterç³»
lintã§ããã±ã¼ã¸æ¤ç´¢ããã¨åè¨èªç¨ã®linter-**ãããããè¦ã¤ããã¾ãã
syntasticã¯éåæã«ãã§ãã¯ã§ããªãã£ãã®ã§å·¨å¤§ãªãã¡ã¤ã«ã ã¨ä¿åæã«åºã¾ãã¨ããåé¡ãããã¾ããããatomã®linterã¯éåæã«ãã§ãã¯ãèµ°ã£ã¦ããã®ã§é常ã«å¿«é©ã§ãã
autocompleteç³»
Vimã ã¨: neocomplcache, neocomplete
linteråæ§ãautocompleteã§æ¤ç´¢ããã¨åè¨èªç¨ã®ããã±ã¼ã¸ãè²ã
è¦ã¤ããã¾ãã
autocomplete-pathã¨èªåã使ãè¨èªç¨ã®ãã®ãã¤ã³ã¹ãã¼ã«ãã¦ãã¾ãã°å
¥åè£å®ã§å°ããã¨ã¯ã»ã¼ç¡ãã¨æãã¾ãã
status-barç³»
Vimã ã¨: powerlineããã
ï¼ã¡ãªã¿ã«èªåã¯lightline.vimãæç¨ãã¦ã¾ããï¼
vimã«ã¯ã¹ãã¼ã¿ã¹ãã¼ã«gitãã©ã³ãæ å ±ãæåã³ã¼ãã表示ãããpowerlineç³»ã®ãã©ã°ã¤ã³ãè²ã ããã¾ããããatomã§ã¯ãã®ãããã®æ å ±ã¯ããã©ã«ãã§ã¹ãã¼ã¿ã¹ãã¼ã«è¡¨ç¤ºããã¦ã¾ãã
clip-history
vimã ã¨: yankringããã ï¼ã¡ãªã¿ã«èªåã¯yankround.vimãæç¨ãã¦ã¾ããï¼
ããããã¯ãªãããã¼ãæ¡å¼µç³»ã®ããã±ã¼ã¸ã
vimã¢ã¼ãã«é¢ä¿ãªãatomã®ããã±ã¼ã¸ã«è²ã
ããã¾ããè²¼ãä»ããã¨ãã«ãã¡ãã¡åè£ãé¸ã¶UIãä½è¨ã§ãyankround.vimã§ctrl+pã ãã§æ¸ãã§ããæä½æ§ã«æ¯ã¹ãã¨ã¤ãã¤ãã£ã½ãã£ãã§ãã
clip-historyã¯yankround.vimããã®ã¾ã¾atomã«ç§»æ¤ãã¦ããã¨ããæãã§é常ã«ä½¿ããããã§ãã
ã¡ãªã¿ã«ä½è ã¯vim-mode-visual-block, cursol-historyã¨åãt9mdããã§ãããã¤ããä¸è©±ã«ãªã£ã¦ããã¾ãã
script
vimã ã¨: vim-quickrun
éãã¦ããã¹ã¯ãªãããå®è¡ãã¦ãå®è¡çµæãatomã«è¡¨ç¤ºãã¦ããã¾ãã 試è¡é¯èª¤ããªããæ¸ãã¦ããã¨ãã«é常ã«ä¾¿å©ã
vim-modeã§ã®ãã¼ãããã³ã°
vim-modeãå ¥ããã¨atomã®ãã¼ãããã³ã°è¨å®ã«vimã§ã®normalã¢ã¼ãããinsertã¢ã¼ãä¸ãã®æ¡ä»¶åããã§ãã¾ãã
'atom-text-editor.vim-mode.normal-mode': 'ctrl-i': 'cursor-history:next' 'ctrl-o': 'cursor-history:prev' 'atom-text-editor.vim-mode:not(.insert-mode)': 'ctrl-p': 'clip-history:paste' 'ctrl-P': 'clip-history:paste-last' 'ctrl-n': 'clip-history:paste-newer'
ä¸ã¯èªåã®keymap.csonã®ä¸é¨ã§ãã
ã«ã¼ã½ã«ç§»åç³»ã®cursor-historyã¯normalã¢ã¼ãããã¼ã¹ãæ¡å¼µç³»ã®clip-historyã¯insertã¢ã¼ã以å¤ãã¨ããããã«åã¢ã¼ããã¨ã«ãã¼ãããã³ã°ãå¯è½ã«ãªã£ã¦ãã¾ãã
ä»å¾å¥ã®ããã±ã¼ã¸ããããã³ã°ãããã¨ãããã¨ã«ãªã£ã¦ãã³ã³ããªã¯ããæ¸ããããã§ããã
ãããã«
ããã¾ã§ç´¹ä»ããããã±ã¼ã¸ãå°å ¥ãããã¨ã§Vimã§å®ç¾ã§ãã¦ãããã¨ãAtomã§ãå®ç¾ã§ããããã«ãªããä»ã§ã¯å¿«é©ãªVimçæ´»ãAtomä¸ã§ãããã¦ãã¾ãã
ãããVimã§ãããªãï¼ã¨ããæè¦ãããããã¨ãå¤ãã®ã§ãããä½åº¦ãvimscriptã«ããã£ã¬ã³ã¸ãããã®ã®vimscriptã®åºæ¬çãªæåã«ã¤ãã¦èªåãç¥ãããæ å ±ãè¦ã¤ããã®ãããã©ãããã®ã¨ãæ¥åç¨ã«æ¸ããç°¡åãªãã©ã°ã¤ã³ãæ°ã¶æå¾ã«èªåã§è¦è¿ããéã«vimscriptã§ä½ãæ¸ãã¦ããã®ããã£ã±ãåãããªãã£ãï¼èªåãæ¸ããã«ãé¢ãããï¼ã®ãããã«ã±ã§æ¬æ ¼çã«Atomã«ç§»è¡ãå§ãããã¨æãã¾ããã
Atomã§ã®ããã±ã¼ã¸ä½æã¯åå¼·ãå§ããã°ããã§ããããããªãã«æ £ã親ããã CoffeeScriptã§æ¸ããã®ã¨ãããããAtomã®ã»ã¨ãã©ã®åºæ¬æ©è½ãããã±ã¼ã¸ã§æä¾ããã¦ãã¦åèã«ã§ãããµã³ãã«ãå¤ãã®ã§Vimãæ¬æ ¼çã«ã«ã¹ã¿ãã¤ãºããããã¯éå£ãã ãã¶ä½ãæãã§ãã
2016å¹´ããã¿ã¼Vimã¨ãã¦Atomã使ã£ã¦ãããã¨æãã¾ãã
2016/03/01 追è¨
è¨äºãæ¸ãã¦ããããã«ãã¿ã¼VImåãé²ãããã¨ãã§ããã®ã§ç´¹ä»ãã¾ã
vim-mode-plus
t9mdããã«ããvim-modeã®æ¡å¼µçã 詳ãã説æã¯22æ¥ç®ã®AdventCalendarã«ãæ¬äººã«ããç´¹ä»è¨äºãããã¾ãã ã©ã®ãããªæ©è½ã追å ããã¦ããã®ãã¯ãå ¬å¼ã®gifã¢ãã¡ãè¦ãã®ãä¸çªç解ãæ©ãã¨æãã¾ãã vim-modeã¨ã¯ããã±ã¼ã¸åãå¤ãã£ã¦ããã®ã§ãã¼ããããå¤ããå¿ è¦ãããã¾ããããããå ¬å¼ã§ãµã³ãã«ãç¨æããã¦ããã®ã§å¿ è¦ãªã¨ãããèªå好ã¿ã«æ¸ãæããã ãã§ä¹ãæããããã¨æãã¾ãã
å人çã«ã¯/
æ¤ç´¢ã®å¼·åãä¸çªæåãã¾ãããvim-modeã§ã/
ã«ããæ¤ç´¢ã¯ã§ãã¾ããããã¤ã³ã¯ãªã¡ã³ããµã¼ãã¨ãã¤ã©ã¤ããå¹ããªãã£ãã®ã§ãæ¬å®¶Vimã«æ¯ã¹ãã¨çæè½ã¡æãå¦ãã¾ããã§ããã
vim-mode-plusã¯ãã®ç¹ãæ¹åããã¦ãã¦ããã®æ©è½ã ãã§ãä¹ãæãã価å¤ãããã¾ããã
ãã¼ãããã³ã°ã«ããex-modeã®ç½®ãæã
èªåã¯ãã®ãã¼ãããã³ã°ã追å ãããã¨ã§ex-modeãä¸è¦ã«ãªãã¾ããã
# emulate vim ex-mode # https://github.com/atom/vim-mode/issues/50 '.editor.vim-mode-plus:not(.insert-mode)': ': w enter': 'core:save' ': q enter': 'core:close' ': s p enter': 'pane:split-down' ': v s p enter': 'pane:split-right' 'g c c': 'editor:toggle-line-comments' # emulate tomtom/tcooment_vim
vim-mode-plusã«ä¹ãæãããã¨ã§ex-modeã¨é£æºã§ããªããªããè²ã
æ¢ãã¦ãããvim-modeã®issueãããã®ã³ã¡ã³ããçºè¦ãã¾ããã
ãã¼ãããã³ã°ã§:w
ãåç¾ããã¨ãããã®ã§ãè¦ã¤ããæã«ããã®çºæ³ã¯ç¡ãã£ãï¼ãã¨ææ¿ãã¾ããã
ç½®æã ãã¯ãã¯ãæ¬å®¶Vimã®åç¾ã¯ã§ããªãã£ãã®ã§ãããããAtomã®å ã ã®ç½®ææ©è½ã§ããããªã¨ããæãã«ãªã£ã¦ãã¾ããã
2016/02æç¹ã®èªåã®è¨å®
èªåã®dotfilesã®.atomãã£ã¬ã¯ããªã«ãã¼ããããããã±ã¼ã¸ä¸è¦§ãç½®ãã¦ããã®ã§ããããã°åèã«ãã¦ã¿ã¦ãã ããã