我最近发现了 Vim Tip n° 1531(文件的词频统计)。
按照建议,我将以下代码放入我的 .vimrc
function! WordFrequency() range
let all = split(join(getline(a:firstline, a:lastline)), '\A\+')
let frequencies = {}
for word in all
let frequencies[word] = get(frequencies, word, 0) + 1
endfor
new
setlocal buftype=nofile bufhidden=hide noswapfile tabstop=20
for [key,value] in items(frequencies)
call append('$', key."\t".value)
endfor
sort i
endfunction
command! -range=% WordFrequency <line1>,<line2>call WordFrequency()
除了口音和其他法语细节(拉丁小连字 a 或 o 等)外,它工作正常。
我应该在此功能中添加什么以使其适合我的需要?
提前致谢