roi_saumon
roi_saumon

Reputation: 614

Vim writhing within figure brackets

I am a new vim user and I try to play around a bit. I am trying to have an efficient way to code a block with figure brackets :

{
    blabla;
    ....
    blabla;
}

So the first thing I did is put the following in my .vimrc to get the opening and closing bracket when I write a opening bracket :

noremap <silent> <C-S>          :update<CR>
vnoremap <silent> <C-S>         <C-C>:update<CR>
inoremap <silent> <C-S>         <C-O>:update<CR>

And to start writing within the brackets, I then hit : "i" "enter" "enter" "esc" "ciw"

Seems a bit tedious, what do you think?

Upvotes: 0

Views: 143

Answers (2)

Tinmarino
Tinmarino

Reputation: 4051

inoremap { {}<Left>:
To open a closing } right after the cursor

inoremap { {<cr>}<c-o>O
To open a closing } below the cursor. Maybe you want to set autoindent to.

Upvotes: 1

chrboesch
chrboesch

Reputation: 314

There was already another thread on this topic: Automatic closing brackets for Vim

Alternatively, you can try out a plugin, such as: delimitMate

Upvotes: 2

Related Questions