27
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

vimでhtml.erbファイルを書く時に便利なプラグイン

Posted at

railsでhtml.erbを書く時に、タグの入力を書く手間を減らすにはsurround.vimrails.vimの組み合わせがいい感じのようです。

インストール
neobundle.vimを使います

.vimrc
NeoBundle 'tpope/vim-rails'
NeoBundle 'tpope/vim-surround'

利用方法

まず以下の1行を<div>タグで囲んでみます。

hoge.html.erb
タイトルは@titleです。

ビジュアルモードで1行全てを選択後、S<div>と入力すると以下のように<div>...</div>タグで囲んでくれます。

hoge.html.erb
<div>タイトルは@titleです。</div>

次に@title<%= %>で囲みます。
ビジュアルモードで@titleを選択後、S=と入力すると、選択部分を<%= %>で囲んでくれます。
(この機能を使うにrails.vimを導入する必要があります。)

hoge.html.erb
<div>タイトルは<%= @title %>です。</div>
27
28
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
27
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?