mattn / vim-sonictemplate

Easy and high speed coding method
http://mattn.github.com/vim-sonictemplate
333 stars 42 forks source link

Update the method of removeing {{_cursor_}} #33

Closed mityu closed 4 years ago

mityu commented 5 years ago

feedkeys() takes some time by evaluating keys. feedkeys() does only adding characters to the queue of key inputs.

mattn commented 5 years ago

Could you please try to add 'n' for second argument of feedkeys?

mityu commented 5 years ago

I'm sorry, I forgot to write a example of the problem.

Preparation

A snippet file, snip-func.vim:

function! {{_cursor_}}()
endfunction

and following mapping:

:imap <C-k> <Plug>(sonictemplate)func<CR>a

Operation

Type <C-k> on a buffer for vimscript.

Output

('|' is the cursor.)

function! a|()
endfunction
function! {|()
endfunction

I think that <bs> inputs by feedkeys() are evaluated after evaluating 'a' in the rhs of <C-k>, so <bs> deletes {_cursor_}}a and { stays on the buffer.

Note that I found this problem with this my asyncomplete source for sonictemplate's snippets: https://github.com/mityu/dotfiles/blob/53098561a690d01978f9984dc43fcdb2704bbb56/dot_vim/vimrc#L1064-L1108

Could you please try to add 'n' for second argument of feedkeys?

I tried it, but adding 'n' didn't fix this problem. (also, adding 'x' or 'nx' didn't fix this problem.)

mityu commented 5 years ago

Oh, the commit message isn't right... I'll change it.

mattn commented 4 years ago

Sorry my delay. Probably, this PR does not work with insert-mode.

mityu commented 4 years ago

Sorry for my delay too. Fixed this PR doesn't work with insert-mode.

mattn commented 4 years ago

LGTM, Thank you.