I'm using vim to edit my latex files and I'm trying to automate some aspects of it.
I want a command that inserts the following:
\begin{env}
\end{env}
Where env
is an user input. So I came up whit this
function Begin()
call inputsave()
let env = input("env = ")
call inputrestore()
execute "normal! i\begin{" . a:env . "}\n\n\end{" . a:env . "}<esc>k"
endfunction
The last part , <esc>k
, is meant to put the cursor above the last line.
But unfortunaly I can make it work, it tells me E121 a:env not defined
. I create a custom command to call the function
nnoremap ,b :call Begin()<CR>
What am I missing?