I am trying to create a function in vim that is capable of creating mappings for me. This is so I don't have to type out very similar commands over and over in my vimrc.
Take these two mappings as examples...
onoremap <buffer> in( :<c-u>execute "normal! /(\r:noh\rvi("<cr>
onoremap <buffer> in[ :<c-u>execute "normal! /[\r:noh\rvi["<cr>
(these are operator-pending mappings for in paren or square bracket)
What the mappings do is not really important for the question, what I would like to know is if I can create a function to remove all the repetition. I would like it to look something like...
CreateNextIn('(')
CreateNextIn('[')
CreateNextIn('{')
which will create the omap
for me.
Any help will be greatly appreciated :D
:exe
...:exe 'nnoremap <leader>' . mapkey . ' :echo "' . somevar . '"<cr>'