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>.


Maybe something like:

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

autocmd! BufNewFile * silent! call LoadFile()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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