Vim ã®ã«ã¹ã¿ãã¤ãº ããã¼å²ãå½ã¦å¤æ´æ¹æ³ã
ãã¼å²ãå½ã¦å¤æ´
vi/Vimã¯æå°éã®ãã¼æä½ã§æ§ã
ãªäºãè¡ããããã«ä½ããã¦ãã¾ããã§ããã
ãã©ããã¦ã使ãã«ãããã¼é
ç½®ãããã®ã§ãå¤ããããã
ãç¹°ãè¿ãè¡ãè¤éãªæä½ãç°¡åã«è¡ããããã¨ãããã¨ãããã¾ãã
ãããªæã«ãã¼å²ãå½ã¦å¤æ´ãæ´»èºãã¾ãã
ãªãããã¼å²ãå½ã¦ã®å®ä¾ã«ã¤ãã¦ã¯ãVim ã®ã«ã¹ã¿ãã¤ãº ããã¼å²ãå½ã¦å¤æ´ã®å®ä¾ã ã§ç´¹ä»ãã¦ãã¾ãã
ãã¼å²ãå½ã¦å¤æ´ã³ãã³ã
ãã¼å²ãå½ã¦å¤æ´ã³ãã³ãã¯ãä¸ã®ããã«ãã¢ã¼ããã¨ãåå²å½(remap)ã®æç¡ã«ãã£ã¦å¥ã®ååãå²ãå½ã¦ããã¦ãã¾ãã
ã¢ã¼ã | åå²å½ç¡ã | åå²å½æã |
---|---|---|
ãã¼ãã«ã¢ã¼ãï¼ãã¸ã¥ã¢ã«ã¢ã¼ã | noremap | map |
ã³ãã³ãã©ã¤ã³ã¢ã¼ãï¼ã¤ã³ãµã¼ãã¢ã¼ã | noremap! | map! |
ãã¼ãã«ã¢ã¼ã | nnoremap | nmap |
ãã¸ã¥ã¢ã«(é¸æ)ã¢ã¼ã | vnoremap | vmap |
ã³ãã³ãã©ã¤ã³ã¢ã¼ã | cnoremap | cmap |
ã¤ã³ãµã¼ã(æ¿å ¥)ã¢ã¼ã | inoremap | imap |
ãã®ã³ãã³ãã¯ã
ã³ãã³ãå([n/v/c/i][nore]map]) <ãªãã·ã§ã³> ã¦ã¼ã¶ã¼ãå ¥åããæä½ Vimã解éããæä½
ã¨ããå½¢ã§ä½¿ãã¾ãããªãã·ã§ã³ã®æç¡ã¯ä»»æã§ããä¾ãã°ã
nnoremap ; :
ã¨.vimrcã«è¨å ¥ããã¨ããã¼ãã«ã¢ã¼ã㧠; (ã»ãã³ãã³)ãå ¥åãããæã«ãVimã¯æ¬æ¥ã®æ©è½ãå¼ã³åºã代ããã« : (ã³ãã³)ãå ¥åãããã¨ã¿ãªãã¦ãã³ãã³ãã©ã¤ã³ã¢ã¼ãã«å ¥ãã¾ãã
nnoremap <C-c><C-c> :<C-u>nohlsearch<cr><Esc>
ã¨ããã°ã CTRL-C ãï¼åæ¼ããã¨ã§æ¤ç´¢æååã®ãã¤ã©ã¤ãã解é¤ãããã¨ãåºæ¥ã¾ãããã®ä¾ã®ããã« < 㨠> ã§å²ããã¨ã§ç¹æ®ãªãã¼ãæå®ãããã¨ãåºæ¥ã¾ããã¾ãå²ãå½ã¦å ã«ã³ãã³ãã©ã¤ã³ã¢ã¼ãã®ã³ãã³ãå®è¡ãæå®ãããã¨ãåºæ¥ã¾ãã
ãã¼ã®åå²å½ã¦
nore ãã¤ããªããmap/map!/nmap/vmap/cmap/imapã¨ãã£ãã³ãã³ãã使ã£ãå ´åããã¼ã®åå²å½ã¦ãçºçãã¾ããã¤ã¾ããVimã解éããæä½ã¯ããã¦ã¼ã¶ã¼ãå®ç¾©ãããã¼å²ãå½ã¦ãã«å¾ã£ã¦è¡ããã¾ããããã¯ã¦ã¼ã¶ã¼ã®å²ãå½ã¦ãå¤åãããã®ã§ãã以ä¸ãæ··ä¹±ã®å ã«ãªãäºãå¤ãã®ã§ãç¹ã«çç±ãç¡ããã° noremap ãç¨ã㦠Vim ã®æ¬æ¥ã®ãã¼å²ãå½ã¦ã«ããæå®ãè¡ãäºããªã¹ã¹ã¡ãã¾ãã
ããã«è©³ããæ å ±
:h key-mapping
ã§ãã«ããåç §ãã¦ã¿ã¾ããããä¸è¨ä»¥å¤ã®ã¢ã¼ãã«å¯¾å¿ããã³ãã³ããã<silent> ã <buffer> ã¨ãã£ããªãã·ã§ã³ã«ã¤ãã¦ã説æãããã¾ãã
ãã¼å²ãå½ã¦ã®æ³¨æ
ãã¼ãæ©è½ã«å²ãå½ã¦ãã®ã§ã¯ãªãã¦ãå¥ã®ãã¼ãå²ãå½ã¦ãããã«ãªã£ã¦ãããã¨ããåããããã«ããã®æ©è½ã¯ãå ã ãvi / Vim ã®ãã¼ãã¤ã³ããåæã¨ãã¦ãããã«å¯¾ãã¦ä¸é¨å¤æ´ãè¡ãããã®ãã®ã§ããæ¢åã®ãã¼ãã¤ã³ãã丸ãã¨å¤ãã¦ãã¾ãã®ã§ã¯ãªãã¦ããã¾ãéåæãªãå ±åãããããªãã¼å²ãå½ã¦ãè¡ãããã«ãã¾ãããã