0

I've been using vim to write html files recently.

I'm so sick of the <...> and <\...>, so I write some inoremap for convenience in a vim file:

autocmd Filetype html inoremap <buffer> <c-i> <><Esc>i
autocmd Filetype html inoremap <buffer> <c-j> <Esc>vi>"xyo<\<Esc>"xpa><Esc>O
autocmd Filetype html inoremap <buffer> <c-l> <Esc>vi>"xyf>a<\<Esc>"xpa><Esc>F<i

I edit a temporary html file to test it. Everything works fine but when I type <C-i> a <C-l>. I thought the result would be <a> <\a>, but it stopped in visual mode, selecting the a, it feels like it just executed <Esc>vi> and stopped.

After many tries, I realized that as long as there is only one character in < >, it works wrong.

I try split the command into

autocmd Filetype html inoremap <buffer> <c-t> <Esc>vi>
autocmd Filetype html noremap  <buffer> <c-y> "xyf>a<\<Esc>"xpa><Esc>F<i

It works.

Is there any hidden problem with vim's visual mode or my vim?

paradoxD
  • 17
  • 5
  • Your `` and `` mappings seem to work fine, here. I suggest you remove the others from your question as they are irrelevant. – romainl Sep 06 '22 at 13:36
  • It works fine in my manjaro computer. It's maybe my windows's problem, should I delete this question ? – paradoxD Sep 06 '22 at 13:46
  • Well, you can keep it open and mention that Manjaro vs Windows discrepancy. – romainl Sep 06 '22 at 13:57
  • Latest discovery, after I upgrade my gvim to 9.0 the problem solved. I used 8.2 before, this question may be a bit too coincidental. – paradoxD Sep 06 '22 at 14:40

0 Answers0