Fandom

Vim Tips Wiki

Quick way to insert opening and closing braces for programmers

1,624pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Duplicate tip

This tip is very similar to the following:

These tips need to be merged – see the merge guidelines.

Tip 677 Printable Monobook Previous Next

created 2004 · complexity basic · author Yada · version 5.7


This insert-mode map is fairly easy. It will save a lot of keystrokes for opening and closing braces when programming. It works best with cindent on (:set cindent) since vim will automatically indent to the right tabstop. I mapped it to insert-mode Ctrl-F.

Example:

int main() Ctrl-F

will produce:

int main() {
    |
}

insert the following in your vimrc file

" Opening and closing braces
imap <C-F> {<CR>}<C-O>O

CommentsEdit

Also on Fandom

Random Wiki