Vimãã©ã°ã¤ã³ãåºæ¥ãã¾ã§
åå¿çãªVimãã©ã°ã¤ã³å
¥éã
æè¿ãã£ã¨Vim scriptãæ¸ãå§ãã¦ããã©ã°ã¤ã³ã®å½¢ã§ãã£ã¦Githubã«ã¦å
¬éã¨ããã¨ããã¾ã§è¾¿ãçãã¾ããã
ããããã¨è¶³ããªãé¨åã¯å¤ããã§ãããããã§ãåã®ãã©ã°ã¤ã³ã§ããåã®ãªã¼ãã³ã½ã¼ã¹ã§ãã
ã§ããããããåãã¦ãã®é ã®æè¦ãæé ã£ã¦ãå¾ã
ã«ãªãã¨è¦ãã¦ããªãã£ããããã®ã§ã¾ã¨ãã¦ããã¾ãã
ãã©ã°ã¤ã³ã®ãã«ãã¯ã¾ã æ¸ãã¦ãªãããããåºæ¥ä¸ãã£ã¦ãã¯ããªããã§ããã©ãã
äºåæºå
æ¥æ¬èªçã®ãã«ããæã«å
¥ãã¾ãããã
ãã«ãã¯å¿
é ã§ããããããªããã°å§ã¾ãã¾ããã
è±èªãèªãã人ã¯è±èªã§ãããã¨æãã¾ãããã¼ãã¯ããããèªããªãã®ã§æ¥æ¬èªçãå
¥ãã¦ãã¾ãã
ã©ããã§ãæ¥æ¬èªãã«ãã許ãããã®ã¯åå¿è
ã¾ã§ãã¨ããã®ãè¦ãæ°ããã¾ãããã¼ãã¯ã¾ã åå¿è
ãªã®ã§åé¡ããã¾ããã
ã¤ã³ã¹ãã¼ã«ã«ããã£ã¦ã¯ãä»ã ã¨ãããææ°æ
å ±ãªã®ããªï¼
HowToUse · vim-jp/vimdoc-ja Wiki · GitHub
Vim scriptã®åºæ¬æ§æã¯è¦ãã¦ãã
ãã©ã°ã¤ã³ãæ¸ãã«ã¯ã¾ãVim scriptãæ¸ããããã«ãªãå¿
è¦ãããã¾ãã
Vim scriptãæ¸ãå§ããã«ããã£ã¦ç¹ã«åèã«ãªãè¨äºã¯ãã®4ã¤ã§ãã
- :help vim-script-intro ããã㯠:help usr_41
- Vimスクリプト基礎文法最速マスター - 永遠に未完成
- Big Sky :: モテる男のVim Script短期集中講座
- Vimスクリプトリファレンス — 名無しのvim使い
ã©ãããã°ããããåããããããããã¨ãã£ã¦èªãé çªã決ããå¿ è¦ã¯ããã¾ããã
vimrcã«ã¨ããããä½ãæ¸ãã¦ã¿ã
ãããªããã©ã°ã¤ã³ã¨ãã¦æ¸ãå§ããã®ã§ã¯ãªããæã åå¿è ã¯ã¾ãvimrcã«æ¸ãã¦ã¿ãã¨ããããããªãã§ããããã
ãã¿ã決ãã
ä»åã¯ç°¡åã«ãå®äº/æªå®äºã®å°ãä»ãå¤ãããããã©ã°ã¤ã³ã§ãã
ã¡ãã£ã¨ããTODOãã©ã°ã¤ã³ã§ããã
æ¸ãã¦ã¿ã
- æåã®ä¸æ©
vimrcã®å¥½ããªã¨ããã«æ¬¡ã®ããã«æ¸ãã¦ã¿ã¾ãã
function! s:Done(line) call setline('.', substitute(a:line, '\[ \]', '[D]', '')) endfunction command! -nargs=0 MyTaskToggle call s:Done(getline('.'))
â»ã³ãã³ããããªãã¦ãã¼ãããã³ã°ã§ãããã¨æãã¾ãããè¨å®ããããã£ã³ã°ãããããããªããã§ã³ãã³ãã«ãã¾ããã
ããããvimrcã:sourceãã¾ããvimrcãéãã¦ãããªã:source % ã§ããã
ãããããvimrcã®ããã¾ãã©ãã§ãããã®ã§ããµã³ãã«ã®TODOãç½®ãã¦ã¿ã¾ãããã
æé ã«ã"ããå
¥ããªãã¨ã³ã¡ã³ãæ±ãã«ãªããé¢åã«ãªãã®ã§å
¥ãã¦ããã¾ãããã
ãããªæãã
function! s:Done(line) call setline('.', substitute(a:line, '\[ \]', '[D]', '')) endfunction command! -nargs=0 MyTaskToggle call s:Done(getline('.')) " [ ] åå¿é²ã®ããã®ãµã³ãã«ãæ¸ã
ããããTODOè¡ã®ä¸ã«ã«ã¼ã½ã«ãæã£ã¦è¡ã£ã¦:MyTaskToggleã¨å®è¡ãã¦ã¿ã¾ãããã
ã[ ]ããã[D]ãã¨ãªãã¯ãã§ãã
- 次ã®ä¸æ©
ä»åº¦ã¯åãæ¶ãæ¹ãå®è£ ãã¾ãã
function! s:Undone(line) call setline('.', substitute(a:line, '\[D\]', '[ ]', '')) endfunction command! -nargs=0 MyTaskToggle call s:Undone(getline(".")) " [D] åå¿é²ã®ããã®ãµã³ãã«ãæ¸ã
ã»commandã®å®è¡ãs:Doneããs:Undoneã«å¤ãã¦ããã®ã§æ³¨æ
ãã¨ã¯åãããã«:sourceãã¦TODOè¡ã§:MyTaskToggleã¨å®è¡ãã¦ã¿ã¾ãããã
ã[D]ããã[ ]ãã¨ãªãã¯ãã§ãã
- ããä¸æ©
ä¸åã®ã³ãã³ãã§åºæ¥ãããã«ãã¾ãããã
function! s:ToggleDone(line) if a:line =~ '^"*\s*\[D\]' " Undone call setline('.', substitute(a:line, '\[D\]', '[ ]', '')) else " Done call setline('.', substitute(a:line, '\[ \]', '[D]', '')) endif endfunction command! -nargs=0 MyTaskToggle call s:ToggleDone(getline(".")) " [ ] åå¿é²ã®ããã®ãµã³ãã«ãæ¸ã
åãããã«:sourceãã¦TODOè¡ã§:MyTaskToggleã¨å®è¡ãã¦ã¿ã¾ãããã
ä½ãããæãã«åãã¯ãã§ãã
- ãã¾ã
ã©ãããªãå®äºããæéã欲ããã§ããã
function! s:ToggleDone(line) if a:line =~ '^"*\s*\[D\]' call setline('.', substitute(a:line, '\[D\]<.*>', '[ ]', '')) else call setline('.', substitute(a:line, '\[ \]', '[D]<'.strftime("%Y/%m/%d %H:%M").'>', '')) endif endfunction command! -nargs=0 MyTaskToggle call s:ToggleDone(getline(".")) " [D]<2012/04/03 22:28> åå¿é²ã®ããã®ãµã³ãã«ãæ¸ã
ãã¨ã¯ã好ã¿ã®ãã¼ã«ãããã³ã°ãã¦ãããã°ã¯ã³ã¿ããã§ããæãã§ãã
ãã©ã°ã¤ã³ã®å½¢ã«ãã¦ã¿ã
ã¾ãã¯help
- ä½ã¯ãªãã¨ãã¾ãã¯helpã:help write-pluginã§ãã
- ããã«ããä¾é¡ãä¸åº¦èªåã®æã§æ¸ãã¦ã¿ããã¨ããããããã¾ãã
- è¨äºã¯â¦ç¹ã«åèã«ããªãã£ããããªãå¿ãã¦ããã ããããããªãã§ãããè¨æ¶ã«ãªãã§ãã
- ãã ãä¸è¨ã«ãããmattnããã®è¨äºä¸ã®autoloadã¯ã¨ã¦ãåèã«ãªãã¾ããããããããã¨ãªã®ãã¼ã¨
ä½ãæ¹
- pluginãã£ã¬ã¯ããªã«ç½®ã
ããã»ã©vimrcã«æ¸ããã³ã¼ãããã©ã°ã¤ã³ã®å½¢ã«ãã¦ã¿ã¾ãã
ãã©ã°ã¤ã³åã決ããå¿
è¦ãããã¾ãããããã§ã¯é©å½ã«vimtaskã¨ã§ããã¦ããã¾ãã
vimtask.vimãç½®ãå ´æã¯pluginãã£ã¬ã¯ããªã®ä¸ã§ãã
詳細ã¯:help add-plugin ããã㯠:help add-global-plugin ã§ã
ç§ã¯~/.vim/pluginã®ä¸ã«ç½®ãã¾ããã
/Users/kanno% tree .vim/plugin .vim/plugin âââ vimtask.vim 0 directories, 1 file
" vimtask.vim
" å¦çã¯ãã£ãã¨åããæåã¨æå¾ã«ãã©ã°ã¤ã³ã®ãç´æã追å ã詳細ã¯:help write-plugin
if exists("g:loaded_vimtask") finish endif let g:loaded_vimtask = 1 let s:save_cpo = &cpo set cpo&vim function! s:ToggleDone(line) if a:line =~ '^"*\s*\[D\]' call setline('.', substitute(a:line, '\[D\]<.*>', '[ ]', '')) else call setline('.', substitute(a:line, '\[ \]', '[D]<'.strftime("%Y/%m/%d %H:%M").'>', '')) endif endfunction command! -nargs=0 MyTaskToggle call s:ToggleDone(getline(".")) let &cpo = s:save_cpo unlet s:save_cpo
ããããããã»ã©vimrcã«æ¸ããã³ã¼ããã³ã¡ã³ãã¢ã¦ããããã¯åé¤ãã
Vimãåèµ·åãã¦ã¿ã¦:MyTaskToggleãå®è¡ã§ãããªãOKã§ãã
- autoloadãã£ã¬ã¯ããªã«åãã
autoloadãä½ãã¯ä¸è¨ã®mattnããã®è¨äºãããã㯠:help autoload ã§ãã
ç§ã¯~/.vim/autoloadã®ä¸ã«ç½®ãã¾ããã
/Users/kanno% tree .vim/autoload .vim/autoload âââ vimtask.vim 0 directories, 1 file
autoload/vimtask.vimã«ã¯æ¬¡ã®ããã«æ¸ãã¾ãã
é¢æ°åãå¤ãã¦ãã以å¤ãå¦çã¯ããã¾ã§ã¨åãã§ãã
let s:save_cpo = &cpo set cpo&vim function! vimtask#toggle(line) if a:line =~ '^"*\s*\[D\]' call setline('.', substitute(a:line, '\[D\]<.*>', '[ ]', '')) else call setline('.', substitute(a:line, '\[ \]', '[D]<'.strftime("%Y/%m/%d %H:%M").'>', '')) endif endfunction let &cpo = s:save_cpo unlet s:save_cpo
plugin/vimtask.vimã以ä¸ã®ããã«å¤æ´ãã¾ãã
if exists("g:loaded_vimtask") finish endif let g:loaded_vimtask = 1 let s:save_cpo = &cpo set cpo&vim command! -nargs=0 MyTaskToggle call vimtask#toggle(getline(".")) let &cpo = s:save_cpo unlet s:save_cpo
å
ã»ã©ã¨åãããã«Vimåèµ·åãã¦ãã¡ããã¨åãã°OKã§ãã
çµããã§ãããç²ãæ§ã§ããã
Githubã«ä¸ããå ´å
ãã®å ´åã¯ã以ä¸ã®ããã«æ§æã«ãã¦pushããã°ããããããªããã¨æãã¾ãã
/Users/kanno% tree vimtask vimtask âââ autoload â âââ vimtask.vim âââ plugin âââ vimtask.vim 2 directories, 2 files
ä½ãã«ããã£ã¦ããããããã®èª¿ã¹æ¹
ãµã³ãã«ã§ã¯å®éã«èªåã§ä½ãå§ããã¨æ©ããã¤ã³ããã¹ã«ã¼ãã¾ããã
ããã¯ãå¿
è¦ãªæ©è½ã®å®è£
æ¹æ³ã調ã¹ãæ¹æ³ãåãããªããã¨ãããã¨ã§ãã
- ãã°ã°ããã
- ãã°ã°ã£ã¦ãå¼ã£ããããªããã ãï¼ã
- ãVim scriptã§æ¤ç´¢ããã®ã«Javascriptãå¼ã£ããããã ãï¼ã
- ããªãã§"Vim script æé"ã®ãµã¸ã§ã¹ãã®1ã¤ç®ãããã§ã«Javascriptãªãã ãï¼ã
- ã空ç½ããããªãã®ãã¨æã£ã¦è©°ãããvbscriptã«ãªã£ã¡ãã£ããï¼ï¼ï¼ï¼ã
- ã:helpè¦ãã°æ¸ãã¦ãããããã
- ããªãã¦ãã«ãå¼ãã°ãããåãããªããã ãï¼ã
- ããã«ãè¦ã¦ãåãããªãããå°ã£ã¦ãã ãï¼ãâãã°ã°ããã(以ä¸ç¥
ã¨ãããã¨ã§ãåå¿è
ã«ã¯ãã®ã調ã¹ãããã¨ã®ãã¼ãã«ãããªãé«ãããããªããã¨æãã¾ããã
å
人Vimmerããã°ããåç¡ãã®vim使ãããVim-users.jpãªã©ããããæ
å ±ã¯ãããã§ããããªããªã辿ãã¤ããªããã¨ãããã¾ãã
æ
£ãã¦ããã¨å°ããã¤é¢æ°ãè¦ãã¦ããããæ¢ãæ¹ãä½ã¨ãªãåãã£ããåãããªãã£ãããããã§ããã
ã§ããããã¼ãã¯ã©ããã£ã¦å°ããã¤ãæ
£ãã¦ãã£ããã®ãã
çãã¯ã¾ãæ®éãªãã§ããããã£ã±ããèªããã¨ãã§ãã次ãã§ãæ¸ããã¨ãã§ãã
èªãã®ã¯ãã«ãã§ã¯ãªããä»ã®äººãæ¸ãããã©ã°ã¤ã³ãVim scriptã§ãã
ããã«ã¯æ¬¡ã®3ã¤ã®ã¡ãªãããããã¾ãã
- æ§æã«æ
£ãã
- ãã¯ãããã®è¨èªã«æ £ããã«ã¯ãã®ã³ã¼ããããããèªãã¨ãããã¨ã§ãèªç¶ã«é°å²æ°ã«æ £ãã¦ããã¾ãã
- åãããªãé¢æ°ãåºã¦ããããããã:help
- é¢æ°ãç¥ã
- åãããªãé¢æ°ãåºã¦ããããããã:help
- æ©è½ãç¥ã
- ããããªãã¨åºæ¥ããã ã¼ãã£ã¦ããã®ãç¥ã£ã¦ããã大äºã
ãã®ç©ã¿éããããèªåããã©ã°ã¤ã³ãä½ãæã«
ãä¼¼ããããªæ©è½ããã®ãã©ã°ã¤ã³ãæä¾ãã¦ããã¯ãã ããããã®ã½ã¼ã¹ãèªãã°çããããããã ã
ã¨ãã解決ã¸ã®éæ¨ã«ãªãã¾ãã
ã¾ã¨ãã«Vim scriptãèªãã ã®ã¯ãåãã¦ã ã£ãã®ã§ããããããã§ããåå¼·ã«ãªãã¾ããã
ã§ããã£ã±ããWebä¸ã«éå¼ãWikiã¨ããã£ããããã便å©ã ã¨æãã¾ãã
以åã«ujihisa.vim#2ã®LTã§ãçºè¡¨ãã¾ãããã©ãããã¨ä¾¿å©ã
ãã¶ãä½å¹´ã«ã渡ã£ã¦LingrãTwitterã2ch(ã¯è¦ãªãããç¥ãããã©)ã§ãåããããªè³ªçå¿çãç¹°ãè¿ããã¦ãæ°ããã¾ãã
ããç¡é§ãããªãã§ããã
質åããå´ã¯æ°ã使ãã§ãããããçããå´ã®æéããããã¾ãã
ã¾ããããæããªããåããªããWikiä½ããã£ã¦è©±ã§ããã©â¦ã
ã©ã£ããµã¼ãã¼åãã¦ä½ããããªããã¼ãã
(誰ãä½ã£ã¦ãããªãããª)
:help!
ãã«ãã®è¨å®ã¨ãã
- Vim-users.jp - Hack #45: help を引く
- vimrcã«ä»¥ä¸ã®è¨å®ããã¦ããã°Shift-Kã§ã«ã¼ã½ã«ä¸ã®åèªã§:helpãå³å®è¡ããã¦ä¾¿å©ã§ããã¨ãããå¿ é ã
set keywordpreg=:help
- unite.vimã使ã£ã¦ãã人ã¯tsukkee/unite-help · GitHubã使ãã¨æãããããã¾ãã
ãããã°ã¨ã
ã³ã¬ã ï¼ã¨ãããããã°æ¹æ³ã¯æ¢ãä¸ã§ãã
ã¨ããããä»ã¯echomsgã§ã²ãããåºåçµæã確èªãã¦ãã¾ãã
Javaã§ããSystem.out.printlnãããã°ãPHPã§ããvar_dumpãããã°ãJavascriptã§ããalertãããã°ã§ãã
echomsg å¤æ°å
ã¨ããããã¨ã§å¯¾è±¡ã½ã¼ã¹ã:sourceãã¦:messagesã§ç¢ºèªã§ãã
æ£ç´éå¹çã ãªã¨ã¯æããã§ãããä»ã«ã³ã¬ã¨ãã£ã¦è¦ã¤ãã£ã¦ãããã
ã¡ãªã¿ã«echomsgã®å¼æ°ã¯æååãããªãã¨ãããªãã®ã§listã¨ãã¯echomsg string(list)ã¨ããå¿
è¦ãããã¾ãã
ãã®ä»
å®éã«åä½ç¢ºèªãã¦ããä¸ã§ã¯ä½åº¦ãVimãåèµ·åãããã¨ãããã¾ãã
ãããªæã«ä¾¿å©ãªã®ããã¡ã
- tyru/restart.vim · GitHub
- unite.vimã®UniteSessionSave/UniteSessionLoad
ãããã«
ããã¾ã§æ¥ããããã¨ã¯Githubã«ããã¦å
¬éããã¨ããããããã¾ããã
ãããã¥ã¡ã³ãæ¸ãã¦ãããã¨ããã½ã¼ã¹ã³ã¼ã綺éºã«ãã¦ãããã¨ããã©ãã©ãã¦ããã®ã¯å¿ä½ç¡ãã¨æãã¾ãã
ã¨ããããåããªãå
¬éãã¡ããã°ããããããªããã¨ã
ä»ã®ã¼ããããæãã ãã§ãæ°å¹´å¾ã«ã¯ããã¡ã ãã¡ããã¨ãã¦ããå
¬éãã¦ããã¨ãè¨ãããããã¾ãããã
ãã¨ã¯ããã£ã¨ãµã¯ãµã¯ä½ããããã«ãªãããããªã
ã§ãããã°ã©ãã¨ãã¦ã®æ®éã®åå¼·ããããã
æ°åãããæã«æéã足ããªããæéãããæã«æ°åã足ããªãã