strpart(getline('.'), col('.') - 1, 1)
substitute('foooooboooooo','o\+','o','g') " fobo
getline('.')
foo を bar に置換
setline(line('.'),substitute(getline('.'), 'foo', 'bar',''))
let str = 'foobar' echo str[1:2] " oo echo str[:2] " foo echo str[3:] " bar
もっとスマートな方法があったら教えてplz
function! CursorInsert(str) let line = getline('.') let col = col('.') let pos = getpos('.') if col != strlen(line) call setline(line('.'), line[:col -2] . a:str . line[col - 1:]) let pos = getpos('.') else call setline(line('.'), line . a:str) endif let pos[2] = pos[2] + strlen(a:str) call setpos('.', pos) endfunction