Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Still related to the previous question, but switching mode with exe "a" doesn't seem to work, I still have to press the a button manually

Here upon opening a newly created a file, a template is in use and the cursor will be moved to the right position, then erase the tag, and switch to the appending (editing) mode.

function LoadFile()
  0r ~/.vim/skel/tmpl.%:e
  exe "normal /<CURSOR>\<Cr>"
  exe "s#<CURSOR>##"
  exe "a"

autocmd! BufNewFile * silent! call LoadFile()

Any ideas?

share|improve this question
You might want to link to "the previous question" so it is clear what you are refrring to (if it is relevant to this question)... – jasonwryan Mar 27 '13 at 8:12
@jasonwryan added – warl0ck Mar 27 '13 at 8:27
:help startinsert – Runium Mar 27 '13 at 9:08
Add d% ot df> after the \<Cr> there. You don't need exe for the other ones mine was just to expand \<Cr>. I'm not sure it's even necessary there. – Stéphane Chazelas Mar 27 '13 at 9:53
up vote 3 down vote accepted

First, that would be :normal! a instead of :exe "a"; this is a normal-mode command.

Second, for implementation reasons, that does not work; you have to use the special :startinsert! command.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.