LoginSignup
69
66

More than 5 years have passed since last update.

Vimで括弧の補完→改行してインデント

Last updated at Posted at 2014-06-01

Vimで閉じ括弧補完といえば inoremap { {}<Left> のようにやると思うけど、

俺は 某崇高なテキストエディタ のような括弧補完がやりたいんだ!

というわけで、以下を .vimrc に書けばOK

.vimrc
inoremap {<Enter> {}<Left><CR><ESC><S-o>
inoremap [<Enter> []<Left><CR><ESC><S-o>
inoremap (<Enter> ()<Left><CR><ESC><S-o>

これで、

<?php
function test() <カーソル>

<カーソル>位置で { + Enter を押せば

<?php
function test() {
    <カーソル位置>
}

となる。
1年ほどSublimeに浮気して戻って来たけどやっぱVimたんかあいいよ(最低)

69
66
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
69
66