MrPizzaFace
MrPizzaFace

Reputation: 8086

Automatically update the closing tag when open tag changes with Sublime Text 2 on Mac OS X

enter image description here

See the H2 tags? How can I change them all to p tags without manually going from line to line. cmd+d is not viable because of the varying lengths of the inner content.

I found something called Emmet Plugin which I installed but can't get it to work. (Followed steps and confused by docs http://docs.emmet.io/actions/go-to-pair/).

Thanks for the help.

--UPDATE--

Not using a regex. Just to clarify I want something that will automatically update the closing tag if I change the open tag.

Upvotes: 5

Views: 8918

Answers (6)

jberg7777
jberg7777

Reputation: 391

If you have emmet installed: Cmd+Shift+K on mac, Ctrl+Shift+ on windows

Upvotes: 0

Harry
Harry

Reputation: 1742

Here are some solutions which does not require any plugins. All solutions works on sublime2, sublime3 and atom

Using Multiple Cursors (press shift-alt and down arrow)

  • enter image description here

Using Ctrl-D (if you want to restrict the update to some elements only)

  • enter image description here

Using ALT-F3 (to update all instances of h2 -> p)

  • enter image description here

PS: For those who does not have the tags in same line, of they do have then all the contents are of different number of lines method 1 will not work both other methods will still work

Upvotes: 1

Tonatio
Tonatio

Reputation: 4198

I use Emmet and CTRL+SHIFT+' does not work for me.

I changed the key shortcut of the command.

Preferences -> Key Bindings -> User

Content:

[
    { "keys": ["ctrl+shift+;"], "command": "rename_tag" }
]

Upvotes: 3

Sergey Chikuyonok
Sergey Chikuyonok

Reputation: 2691

You need “Rename Tag” action: https://github.com/sergeche/emmet-sublime#available-actions

Upvotes: 10

Mikkel Winther
Mikkel Winther

Reputation: 597

Alt + F3 works for me. I'm using the Emmet plugin, though.

Upvotes: 7

Artur
Artur

Reputation: 384

Just use regexp. They are supported by Sublime Text 2 (in the CTRL + H).

Upvotes: -1

Related Questions