1

To take a short cut in writing markdown files I need an abbreviation which can combine these abbreviations,

autocmd FileType * iabbrev pythoncode ```python```<left><left><left><cr>jjO<C-R>=Eatchar('\s')<cr>    
autocmd FileType * iabbrev vimcode ```vim```<left><left><left><cr>jjO<C-R>=Eatchar('\s')<cr>    
autocmd FileType * iabbrev bashcode ```bash```<left><left><left><cr>jjO<C-R>=Eatchar('\s')<cr>

into one,

autocmd FileType * iabbrev [aLanguage]code ```[aLanguage]```<left><left><left><cr>jjO<C-R>=Eatchar('\s')<cr> 

I don't know how to start with. In the input the "code" can be put ahead, resulting in the command being code[aLanguage], if it is more eligible.

2

You could use a loop and exec:

for l in ["python", "vim", "bash"]
    exec 'autocmd FileType * iabbrev' l."code ```" l."```<left><left><left><cr>jjO<C-R>=Eatchar('\s')<cr>"
endfor
| improve this answer | |

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.