Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 3 "wrap selection with tag" and HTML autocomplete do not work properly

I try to select a piece of text and wrap it with <strong> tag.

After I highlight some text and hit Alt+Shift+W (same as using Edit > Tag > Wrap Selection with Tag) my text is surrounded by <p> and </p>. I then start to type the word strong which replaces both p's simultaneously. If I complete typing the word it's ok, but if I use auto completion and hit Enter after I've typed st for example I get something like: <strong></strong>>word</st>

Tested it with/without Emmet plugin and does the same.

like image 890
tgogos Avatar asked Aug 15 '14 16:08

tgogos


2 Answers

You can use an emmet alternative shortcut: Ctrl+Shift+G

It asks you for a wrap abbreviation in the bottom of the frame, so just insert strong and click Enter. It will just wrap all the content highlighted.

like image 62
Birei Avatar answered Sep 27 '22 22:09

Birei


Solution without emmet :

Go to Packages/User Add a folder Snippets

Creat in it a file named : wrapstrong.sublime-snippet which contain :

<snippet>
    <!-- $SELECTION peut être appelé plusieurs fois -->
    <content><![CDATA[<strong>$SELECTION</strong>]]></content>
    <!-- Facultatif: Description affichée dans le menu -->
    <description>Wrap in strong</description>
</snippet>

And finally bind it to a Key in Key Binding User ->

{"keys": [ "super+b" ], "command": "insert_snippet", "args": { "name": "Packages/User/Snippets/wrapstrong.sublime-snippet"} }

Relaunch Sublime Text and there you are !

like image 21
Baldráni Avatar answered Sep 27 '22 23:09

Baldráni