08/06/30 18:39:38 QTNpt5Qe0
ついにvim scriptを初めて書いてみた。
ファイルの中のhead_strで始まる単語を重複なくリストに格納し返す関数。
2時間もかかった。ゼロからの挑戦。超疲れた。
function! Get_words_starting_with(head_str)
let words = []
let lines = getline('1','$')
for line in lines
let str = matchstr(line, '\<' . a:head_str . '.\{-}\>')
while str != ""
let line = strpart(line, match(line, '\<' . a:head_str . '.\{-}\>') + 1)
if count(words, str) == 0
call add(words, str)
endif
let str = matchstr(line, '\<' . a:head_str . '.\{-}\>')
endwhile
endfor
return words
endfunction
ところで、昔はvim scriptスレがあったみたいだけど、今はないのね。