neovimã®terminal emulatorã便å©ããã
å°ãåã«vimããneovimã«ç§»è¡ããã®ã§ããã
vimãããããããªæ°ããããç¨åº¦ã§neovimã®æ©è½ãç¹ã«æ´»ç¨ãã¦ãã¾ããã§ããã
å®ã¯neovimã«ã¯terminal emulatorã¨ããæ©è½ããããvimã®ä¸ã§shellãèµ·åãããã¨ãã§ãã¾ãã
ä¾ãã°ã³ã¼ããæ¸ãã¤ã¤ãrspecãå®è¡ãããpryãtigã使ã£ãããªã©ãé常ã«ä¾¿å©ã§ãã
ç°¡åãªä½¿ãæ¹ã®ç´¹ä»
terminal emulatorãèµ·åããã«ã¯:terminal
ãå®è¡ãã¾ãã
èµ·åããã¨æåã¯ãã¼ãã¤ã³ããterminal modeã«ãªã£ã¦ãã¾ãã
ãã®ã¾ã¾lsãªã©ãå®è¡ããã°å®è¡ã§ããã¨æãã¾ãã
<C-\><C-n>
ã§command modeã«ãããã¨ãã§ãã¾ãã
command modeããåã³terminal modeã«ããã«ã¯ãinsert modeã«å
¥ãã¨ãã®ããã«i
ãa
ãªã©ã§ã§ãã¾ãã
terminal emulatorãçµäºãããã¨ãã¯terminal modeä¸ã«exitãªã©ã§æ®éã«shellãçµäºãããããcommand modeã§:q
ãªã©ã使ãã°vimãã¨çµäºã§ãã¾ãã
èªåããã£ãè¨å®
ããã©ã«ãã®ã¾ã¾ã§ã¯ä½¿ãã¥ãããããããã¤ãèªåãè¨å®ããé ç®ãç´¹ä»ãã¾ãã
ããã©ã«ãã§èµ·åããshellãå¤ãã
terminal emulatorã¯ããã©ã«ãã§shãèµ·åãã¾ãã®ã§ãæ®æ®µä½¿ã£ã¦ããshellç°å¢ã§ãªãã£ããããã¹ãéã£ã¦ãªãã£ããã§ä½¿ãã¥ããã§ãã
ããã©ã«ãã§èµ·åããshellã¯ä»¥ä¸ã®ããã«æ¸ããã¨ã§å¤ãããã¨ãã§ãã¾ãã
" ~/.config/nvim/init.vim set sh=zsh
ESCã§command modeã«ãã
terminal modeä¸ã¯ãinsert modeãªã©ã¨éããcommand modeã«æ»ãããã®ããã©ã«ãã®ãã¼ãã¤ã³ãã<C-\><C-n>
ã¨ãªã£ã¦ãã¾ãã
ãã®ã¾ã¾ã§ã¯ä½¿ãã¥ããã®ã§ãESCã§command modeã«æ»ããããã«è¨å®ãã¾ãã
terminal modeå
ã§key mapãè¨å®ãããå ´åã¯tnoremap
ã§è¨å®ã§ãã¾ãã
Vim documentation: nvim_terminal_emulator
" ~/.config/nvim/init.vim tnoremap <silent> <ESC> <C-\><C-n>
æåã¯jj
ã§ãæ»ããããã«è¨å®ãã¦ããã®ã§ãããterminal modeå
ã§tigãªã©ãvimã©ã¤ã¯ãªãã¼ãã¤ã³ãã®ãã¼ã«ã使ãã¨ãã«å°ã£ããããESCã®ã¿è¨å®ãã¦ãã¾ãã
ããinsert modeã¨åãããã«jj
ã§command modeã«ãããå ´åã¯ä»¥ä¸ã®ããã«æ¸ãã°è¯ãã¨æãã¾ãã
" ~/.config/nvim/init.vim tnoremap <silent> jj <C-\><C-n>
neotermã使ã
ä¸è¿°ããããã«ç¹ã«vim pluginãå
¥ããã¨ãneovimã¯:terminal
ã§terminal emulatorã使ããã¨ãã§ãã¾ãã
ãã ãneotermãå
¥ãããã¨ã§:T tig
ã®ããã«ä»»æã®ã³ãã³ããå®è¡ãããã¤splitã¦ã£ã³ãã¦ã§terminalãèµ·åãããã¨ãã§ããããã«ãªãã¾ãã
ã¾ãç§ã¯ä½¿ã£ã¦ãã¾ããããneotermå´ã§ãã¹ãã³ãã³ããREPLããµãã¼ããã¦ããããã¡ãã¡:T bundle exec rspec
ã:T bundle exec pry
ã®ããã«ããã¨ãä¸çºã§ç«ã¡ä¸ãããã¨ãã§ãã¾ãã
ãã¾ã
vimã®ä¸ã§emacsãèµ·åãããã¨ããè¸å½ãã§ãã¾ã