Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm using a file template directory for newly created files,

autocmd! BufNewFile * silent! 0r ~/.vim/skel/tmpl.%:e

Now I want to add another function, that move the cursor to somewhere (defined in each ~/.vim/skel/tmpl.%), i.e the first location of text <CURSOR>, is that possible?

In summary, when a new file is created, use the template, and jump to <CURSOR>.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Maybe something like:

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

autocmd! BufNewFile * silent! call LoadFile()
share|improve this answer
    
Hi Stephane, perhaps you can take a look at this question as well unix.stackexchange.com/questions/69296/… –  warl0ck Mar 27 '13 at 8:27

Your Answer

 
discard

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.