Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML keyboard shortcuts in Sublime Text 2?

I switched from Textmate to Sublime in the past few months and have been busy trying to re-train my brain and fingers to use the new shortcut keys.

In Textmate, when editing an HTML documents, I could highlight text and do Command+b to wrap the selected text in <b></b> tags or Command+i to wrap in <i></i>...among various other commands/tags.

So, is there a way to do that in Sublime? I know I can type b, TAB to create an empty set of <b></b> tags, but I want to be able to wrap selected text in various tags.

like image 626
Shpigford Avatar asked Aug 14 '12 11:08

Shpigford


People also ask

How do I start HTML in Sublime Text?

To start a new HTML page, first create a new file in Sublime Text and save it with the . html extension. This will set the syntax of your document to HTML. Then type !

How do I use keyboard shortcuts in HTML?

You can add keyboard shortcuts to your page through HTML with the global accesskey attribute and trigger it with Alt + Shift + key in Chrome and Firefox on Windows, or use Control + Alt + key on Mac.

How do I use shortcuts in Sublime Text?

Sublime Text works with all the standard Windows shortcuts: In addition to the arrow keys, home, end, page up, etc, there is: Ctrl+Left / Ctrl+Right: Move by words. Ctrl+Home / Ctrl+End: Move to the beginning / end of the file. Ctrl+L: Expand selection to line.

What is Ctrl D in sublime?

Ctrl + D in SublimeText is "Quick Add Next." This appears to be equivalent to Ctrl + B in Brackets, which is "Add next match to Selection" on the Find menu.


2 Answers

Mac:
Ctrl+Shift+W

Windows/Linux:
Alt+Shift+W

Then type which tag you want (i, b, etc.).

like image 182
Matt York Avatar answered Oct 11 '22 09:10

Matt York


    { "keys": ["super+alt+b"], "command": "insert_snippet", "args": {"contents": "<strong>${0:$SELECTION}</strong>" } },
{ "keys": ["super+alt+i"], "command": "insert_snippet", "args": {"contents": "<em>${0:$SELECTION}</em>" } }

Above can be added to user key bindings file to have selection surrounded by strong tags upon pressing Cmd+Alt+b and by italic tags upon pressing Cmd+Alt+i (on Mac).

Source: https://gist.github.com/3436510

like image 22
Sridhar Katakam Avatar answered Oct 11 '22 09:10

Sridhar Katakam