Meino Christian Cramer schrieb:

Hi,

in the beginning I often wrote shell scripts, which uses

        $variable

instead of the better
   ${variable}

. So I would like to write a short vim script which inserts the "{}"
around the name of the variable. It should work, when the cursor is
somewhere over the name of the variable.

The first step is done: The script can select the word with
         viw

...

But what then ?

Thank you very much for any help in advance!
Happy editing and have a nice weekend!
mcc

I use the following mappings anyway (in .vimrc):

" autocomplete parentheses and brackets (insert mode)
imap ( ()<Left>
imap [ []<Left>
imap { {}<Left>
"
" autocomplete parentheses and brackets (visual mode)
" uses the above insert mode mappings vmap ( s(<Esc>p
vmap [ s[<Esc>p
vmap { s{<Esc>p

Now mark the word with viw
and type {

Regards,
F. Mehner



Reply via email to