Shortened Sublime Text 3 shortcut for bold

I can’t find for life how to make a key combination to wrap the selected element with strong tags.

I know that I can do Alt + Shift + w to wrap something in any html tag, but you still have to type the tag. I want to be able to write my own shortcut for Ctrl + b , for example, and which would wrap the element in tags

Any ideas?

+6
source share
3 answers

You can do this with custom key mapping. Go to Preferences -> Key Bindings-User and add the following:

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

If the file is empty when you open it, put the first square bracket [ in the first line and the closing bracket ] in the last line. I used Ctrl Super B as a key binding because Ctrl B is already bound to the build command. ( Super is a Windows key or command key, depending on your OS and keyboard.)

To use this command, you can select what you want in the <strong> tags and press Ctrl Super B. The selection will remain selected - if you want to remove the selection and have the cursor after the closing tag, change the "contents" to this:

 "<strong>$SELECTION</strong>" 

Finally, after starting the key combination, you can save the selection, then press Tab to go to the end of the closing tag:

 "<strong>${1:$SELECTION}</strong>$0" 
+19
source

If by strong you mean bold, you can also use the "LatexTools" plugin for Sublime Text. Available through the Github website or through package management. After proper installation, it allows you to wrap the selected text, as shown below:

  • cmd-l, cmd-b for \textbf{blah}
  • cmd-l, cmd-u for \underline{blah}
  • cmd-l, cmd-t for \texttt{blah}

were cmd = command key on mac or control key in windows. Hold cmd for both keystrokes. It will save me a lot of time.

0
source

if you also want to use SHORTCUTS COMBINATION KEYS, you can add a comma at the end of each line, in my case I use BOLD and UNDERLINE.

(I had the problem of adding multiple key bindings in Sublime for bold and underlined)

As Matt said

If the file is empty when you open it, put the square opening bracket [in the first line and closing bracket] on the last line.

 { "keys": ["ctrl+super+a"], "command": "insert_snippet", "args": {"contents": "<b>${0:$SELECTION}</b>" } }, { "keys": ["ctrl+super+s"], "command": "insert_snippet", "args": {"contents": "<u>${0:$SELECTION}</u>" } } 
0
source

Source: https://habr.com/ru/post/975999/


All Articles