.vimrcã«æ¸ãã¹ãã§ãªãVimã®è¨å®é ç® (Vim Advent Calendar 2012, 165æ¥ç®)
Vim Advent Calendar ã®165æ¥ç®ã®è¨äºã§ãã
ååã®è¨äºã¯thincaããã®åä¸è¦ããããã¼ã«æ³¨æã§ããã
Vimã®è¨å®ãã¡ã¤ã«ãGitHubçã®ãªã¢ã¼ããªãã¸ããªã§ç®¡çããã°ãæ°ããç°å¢ã«Vimãã¤ã³ã¹ãã¼ã«ããéæéãçãã¾ãã 便å©ãªåé¢ããªã¢ã¼ãã§ç®¡çã§ããè¨å®ãã¨ããã¼ã«ã«ã§è¡ãã¹ãè¨å®ããæ£ããåºå¥ããªãã¨ã ãããã»ãã¥ãªãã£ãªã©ã®é¢ã§åé¡ãçãããã¾ããã ä»åã¯ãªã¢ã¼ããªãã¸ããªã§å ±æããæ±ç¨ã® .vimrc ã¨ããã¼ã«ã«ãªè¨å®ãã¡ã¤ã« vimrc_local ã«ã¤ãã¦ã®æè¦ãæ¸ãã¾ãã
vimrc_localã®èªã¿è¾¼ã¿
ã¾ã vimrc_local ãèªã¿è¾¼ãæ¹æ³ã«ã¤ãã¦èª¬æãã¾ãã .vimrc ã®æå¾ã«ä»¥ä¸ã®ããã«æ¸ãå ãã¾ãã
if filereadable(expand($HOME.'/.localsetting/vimrc_local')) source $HOME/.localsetting/vimrc_local endif
ããããã°ãã¼ã«ã«ãªè¨å®ãã¡ã¤ã« $HOME/.localsetting/vimrc_local ãèªã¿è¾¼ã¾ãã¾ãã åã¯ãã® $HOME/.localsetting ãã£ã¬ã¯ããªã«ä»ã®ã¢ããªã±ã¼ã·ã§ã³(zshç)ã®ãã¼ã«ã«ãªè¨å®ãã¡ã¤ã«ãã¾ã¨ãã¦ç½®ãã¦ãã¾ãã
vimrc_localãèªã¿è¾¼ãããã®ãã©ã°ã¤ã³ã¯ããããããã¾ãã
local_vimrc ã®ç¼ãç´ã localrc.vim æ¸ãã æ°¸é ã«æªå®æ#112: å ´æãã¨ã«è¨å®ãç¨æãã Vim-users.jp Hack
ãããããã©ã°ã¤ã³å
¥ããã»ã©ã®å¤§ä»°ãªè©±ãããªãæ°ããã¾ããããã
2013/5/15 è¨æ£: thincaããã®ãã©ã°ã¤ã³ã¯ããã ãããã¸ã§ã¯ãæ¯ã«å¥ã®localrc.vimãèªããããã®ãã®ã§ã ä»å話é¡ã«ãã¦ããããã·ã³æ¯ã«å¥ã®vimrc_localãèªãããã¨ã¨ã¯é¢ä¿ããã¾ããã§ããã
ãã¦æ¬¡ã«ãå ·ä½çã«ã©ã®ãããªè¨å®ãvimrc_localã«æ¸ãã¹ããèããããã§ããã ãã®åã«ããããã.vimrcã§è¡ãã¹ãè¨å®ã¨ã¯ä½ãªã®ãèãã¦ã¿ã¾ãã
.vimrcã«æ¸ãã¹ãè¨å®
æ®éã®è¨å®
set autoindent
ã®ãããªæ®éã®è¨å®ã¯ããã¡ããå
±æç¨ã®.vimrc
ã«æ¸ãã¹ãã§ãã
ãã©ã°ã¤ã³ã®è¨å®ã«ã¤ãã¦ããåºæ¬çã«ã¯.vimrcã«æ¸ãã¹ãã ã¨æãã¾ãã
OSã§åå²ã§ããè¨å®
ç°å¢ä¾åã«è¦ããè¨å®ã§ããWindows/Linux/Mac/Cygwinçã®OSã§åå²ã§ããå 容ãªãã .vimrcã«ä»¥ä¸ã®ããã«è¨è¿°ãããã¨ã§è¨å®ã§ãã¾ãã
if has("mac") " macç¨ã®è¨å® elseif has("unix") " unixåºæã®è¨å® elseif has("win64") " 64bit_windowsåºæã®è¨å® elseif has("win32unix") " Cygwinåºæã®è¨å® elseif has("win32") " 32bit_windowsåºæã®è¨å® endif
if has()
ã«ã¤ãã¦ã¯help hasãåç
§ãã¾ããããããªãç´°ããåå²ã¾ã§ãµãã¼ãããã¦ãã¾ãã
ãã®æ¡ä»¶å¼ã«ã¯ããã¤ããããã©ããããã£ã¦ããã¨ãã°win32ããå
ã«win64ãè¨å®ããªãã¨ã
64bit_windowsã®ç°å¢ã§ãwin32ç¨è¨å®ãèªã¿è¾¼ã¾ãããããã
Vimã®ãã¼ã¸ã§ã³ã§åå²ã§ããè¨å®
ãã¨ãã°set relativenumber
ã¯Vim7.3ã§å®è£
ãããã®ã§ãVim7.2ã§ã¯ä½¿ç¨ã§ãã¾ããã
ããããã®ã.vimrcã§ifæã使ãã°åå²ã§ãã¾ã
if v:version >= 703 set relativenumber else set number endif
ifæã§åå²ã§ããªããããªè¨å®ã«ã¤ãã¦ã¯ãããããvimrc_localã®åºçªã§ãã
vimrc_localã§è¡ãã¹ãè¨å®ã«ã¤ãã¦
OSããã¼ã¸ã§ã³ã®éãã«ãã£ã¦èå¥ã§ããªããããªãã¤ã¾ããã·ã³ãã¨ã«ç°ãªãåé¡ã«ã¤ãã¦ã¯ã ãã®ãã·ã³å°ç¨ã®ãã¼ã«ã«ãªè¨å®ãã¡ã¤ã«ãä½ã£ã¦å¯¾å¦ããã°ãªãã¾ããã å ·ä½çã«ã©ã®ãããªè¨å®ãvimrc_localã«æ¸ãã¹ããè¦ã¦ã¿ã¾ãã
ãã©ã³ãã®è¨å®
詳細:Gvimã®ãã©ã³ãè¨å®ã«é¢ããã¾ã¨ã
ã©ã®ãã©ã³ããå ¥ã£ã¦ãããç°å¢ã«ãã£ã¦éåç°ãªãã¾ãã Windowsã®å ´åã¯ããªã¤ã³ã¹ãã¼ã«ã®ãã©ã³ããã»ã¼æ±ºã¾ã£ã¦ãã¾ããã Linuxã®å ´åã¯ãã£ã¹ããªãã¥ã¼ã·ã§ã³ã«ãã£ã¦ç°ãªãã¾ãã Linuxã®ãã£ã¹ããªãã¥ã¼ã·ã§ã³ã«ãã£ã¦ã¯ã¢ã³ãã¼ã¹ã³ã¢ã表示ãããªã çã®åé¡ãããã¾ãã ããããåé¡ã¯åå¥ã«å¯¾å¦ããã°ãªãã¾ããã .vimrcã®æå¾ã§.vimrc_localãèªã¿è¾¼ãããã«è¨å®ãã¦ããã¦ã.vimrcã«äºãããã©ã«ãã®ãã©ã³ãè¨å®ãæ¸ãã¦ããã¦ã ããã§åé¡ãçããã° .vimrc_local ã§è¨å®ãä¸æ¸ããããã¨ããæ¹æ³ãè¯ãã¨æãã¾ãã
ä»ã®ã¢ããªã±ã¼ã·ã§ã³ã¨ã®é£æºã«é¢ããè¨å®
LaTeXã®ã³ã³ãã¤ã«ã®è¨å®ã¨ãã å¤é¨ã¢ããªã±ã¼ã·ã§ã³ã¨ã®é£æºã®è¨å®ã¨ãã ã©ã®ã¢ããªã±ã¼ã·ã§ã³ãå ¥ã£ã¦ããã¯ãã·ã³ã«ãã£ã¦ç°ãªããã æé©ãªè¨å®ããã·ã³æ¯ã«ç°ãªãã§ãããã .vimrcã«ãVimãã®è¨å®ä»¥å¤ã®ãã¨ã¯æ¸ããããªããªãã¨å人çã«æãã®ã§ã(å®æèãã§ãã)ã
ãã®ä»
ä¸æãã¡ã¤ã«é¡ã®ä¿åå ´æãã»ãã¥ãªãã£ã«çµ¡ãã é¨åãªã©ãæãããã¾ãã ã¾ããã®ã¸ãã¯å人ã®ææ³ã«ããæ¯ãå¹ ã大ãããã§ããã
ãããã¯ãã¼ã«ã«ãªè¨å®ã?ããæèãããã¨ã§ãæ±ç¨æ§ã®é«ã.vimrcã«ãªãã¾ãã ãã¡ãã vimrc_local ã®ä½¿ç¨ã¯æå°éã«æ§ããã¹ãã§ããã