03/05/17 22:00
>>369
ありがとうございました。すごく勉強になります。
しかし、行の最後にいるときにうまくいきません。
場合分けしたのですが、最後の\<Right>がうまく機能しません。
function! InsertSpace(chr)
let left = getline(".")[col(".")-2]
let right = getline(".")[col(".")-1]
if strlen(getline(".")) == col(".")
if right == ' '
execute "normal a\<C-V>".a:chr." \<Right>"
else
execute "normal a \<C-V>".a:chr." \<Right>"
endif
else
if left == ' ' && right == ' '
execute "normal i\<C-V>".a:chr."\<Right>"
elseif left != ' ' && right != ' '
execute "normal i \<C-V>".a:chr." \<Right>"
elseif left != ' '
execute "normal i \<C-V>".a:chr."\<Right>\<Right>"
elseif right != ' '
execute "normal i\<C-V>".a:chr." \<Right>"
endif
endif
endfunction