I'm trying to create snippets without using any plugins. For instance,
nnoremap ,eq :-1read $HOME/.vim/snips/.eq.tex<CR>o<TAB>
inserts the contents of .eq.tex
:
\begin{equation}
\end{equation}
I would like to do the same thing except be able to pass a simple character argument so that ,for i
produces
for (int i = 0; i < n; ++i) { }
while ,for j
gives
for (int j = 0; j < n; ++j) { }
Is something like this possible? One possibility could be to use functions,
function! For(idx)
r$HOME/.vim/snips/.for.c
endfunction
But this takes us back to the same problem. Or should I be defining mappings to :command
functions, as in the 5th answer of this post?