てきとうなメモ

本の感想とか技術メモとか

surround.vim

囲んでいる何かを編集するためのプラグイン

インストールは

NeoBundle 'tpope/vim-surround'


囲んでいるものを削除するときはDelete Surrounding target

ds<target>

囲んでいるものを置換するときはChange Surrounding target with replacement

cs<target><replacement>

新規に囲む場合はYou Surround motion/textobj with target

ys<motion/textobj><replacement>

というように覚えれば良いかな。

ただ、ysより、ヴィジュアルモード(v or V)で選択したものをSで囲む方が使いやすいかも。

target/replacementの所には',",[,],{,},<,>などが使えてtを入力するとタグを入力できる。
括弧は閉じ括弧の場合は空白を含まないが開く方は括弧と囲む対象の間に空白を入れる。