I have a lot of php/html files with many strings that should be internationalized with gettext.
Therefore, I have to go through each file, spot the “message” strings and replace each one by
<?= _("<my string>") ?>
I use vim and would like to setup a shortcut (map) to do it easily in insert mode (With CtrlR for instance).
Do you know how to achieve that ?
I would use Tim Pope’s wonderful surround plugin to accomplish this.
Add the following to your
~/.vim/after/ftplugin/php.vimfile:Now you can select some via visual mode then surround. e.g
vitS_If you are in insert mode you can surround text via
<c-s>_and you cursor will be inserted in between the double quotes.As a bonus if you want to do the delete the surrounding
<?= _("<text here>") ?>and only leave<text here>you can add the following to your~/.vim/after/ftplugin/php.vimas well:Tim Pope has many great plugins I highly suggest you take a look some of them.
For more help see: