Vim: Annotate strings with gettext (the macro way)
If your application does not use gettext strings then you must do a lot of rewrites of following form:
Doing this over huge codebase is a pain in the ass and automating it can be error prone. Luckily we can write a couple of Vim macros that can help with this job! The basic ideas is to select text and press si to annotate it with gettext function. To implement this simply pass this to your vimrc:
vmap si s(i_<esc>f)
au FileType mako vmap si s"i${ _(<esc>2f"a) }<esc>
You use it in a following manner:
The above snippet requires surround.vim plugin! The above reason is why I love to use Vim. I can spend 10 minutes on creating a macro that saves me hours of manual labor!
8. Feb 2012
•
Tips
·
VIM Editor
|
|