Sublime Text 3 / Emmet – Select both opening & closing tag (via Shortcut) - sublimetext3

Just a quick question in order to optimize my workflow / productivity with Sublime Text 3 & Emmet...
So far I am able to (on Mac)
select the opening and closing tag via CMD + Shift + K
select the nested HTML / text of a wrapping attribute via CMD + Shift + A
But what I haven't found out yet is a way to select the opening and closing tag completely (with all possible values) in order to delete the surrounding tags.
To illustrate...
<span style="color: #660066;"><strong>Lorem ipsum dolor sit amed</strong></span>
Running CMD + Shift + K renders this selection:
...which doesn't allow me to instantly delete the code.
Any ideas / hints / workarounds you can think of? I researched both the web and the Sublime Text docs but to no avail...
Thanks & regards!

Highlight the tag you want to remove the opening and closing tags for and try CTRL + SHIFT + ;
That should delete the selected tag and it's closing partner.
The emmet documentation has this as the remove tag shortcut, but states the shortcut is CTRL + SHIFT + K, when infact (on my setup at least), it's CTRL + SHIFT + ; in Sublime Text 3.
If this doesn't work, you should be able to find what the default key binding is by checking your default key bindings file under Preferences > Package Settings > Emmet > Key Bindings - Default. Run a search in this file for "remove_tag" and see what binding is attached to it.
If for some reason it doesn't exist or you'd like to change the binding, you can do so by editing your user key bindings file under Preferences > Package Settings > Emmet > Key Bindings - User.
Simply add:
[
{
"keys": [
"shift+ctrl+;"
],
"args": {
"action": "remove_tag"
},
"command": "run_emmet_action",
"context": [
{
"key": "emmet_action_enabled.remove_tag"
}
]
}
]

Related

Cant set Ctrl + Shift + E as chrome extension command

I'm trying to register Ctrl + Shift + E as command for my chrome extension, it should work according to my understanding from the rules listed here but it isn't working.
I noticed even the command in the example Ctrl + Shift + Y doesn't work.
They don't perform the necessary action.
I understand these commands are just suggestions but I'm not sure why these combinations aren't working.
When logging with chrome.commands.getAll() the shortcut is replaced by empty string.
Here is my manifest V3 file:
...
"commands": {
"commandName": {
"suggested_key": {
"default": "Ctrl+Shift+E",
"mac": "Command+Shift+E"
},
"description": "description"
}
}
...
Other combinations work for example Ctrl + U or Ctrl + Shift + U

Select media query and contents in Sublime Text

Is there a way to select every media query and its contents using Sublime Text 3? For example I have a CSS file with lots of #media print queries, I'd like to select all of them AND the contents in one go.
#media print {
.app-contact-panel__heading,
.app-prose-scope h3 {
font-size: 18pt;
line-height: 1.15;
}
}
I know I can select one #media print and press CMD + D to select the next one. Or CTRL + CMD + D to select all #media print in the doc, but neither selects the properties as well?
Can anyone help?
One way to do this would be via a plugin. The following plugin highlights all the contents of those media queries that begin with #media print {
import sublime
import sublime_plugin
class HighlightMediaQueryCommand(sublime_plugin.TextCommand):
def run(self, edit):
# This finds all the regions that are #media print {
media_regions = self.view.find_all(r"#media print {")
# This will clear the current Selection object.
self.view.sel().clear()
# We now add the region corresponding to the opening bracket of each media print query.
for regions in media_regions:
self.view.sel().add(sublime.Region(regions.end(), regions.end()))
# Next, we move the selection to the end of the brackets.
self.view.run_command("move_to", { "to": "brackets" })
# Now that we have access to the closing bracket of each media print query, we can construct the Region object for all media print queries with their contents also.
for i, sel in enumerate(self.view.sel()):
self.view.sel().add(sublime.Region(media_regions[i].begin(), sel.end() + 1))
def is_enabled(self):
# Enable the command to work only in a CSS file.
return self.view.settings().get("syntax") == "Packages/CSS/CSS.sublime-syntax"
In order to use this plugin, you'll have to save this code in a .py file in the User directory (go to Preferences -> Browse Packages ... via the top menu). Once saved, you can use this plugin in either of the following ways :-
The quickest & easiest way is to just type view.run_command("highlight_media_query") in the sublime console input and pressing enter while you are in the desired css file (press ctrl/cmd + ` to access the console).
If you do this very often, you can bind it to a keyboard shortcut. To do that, you would have to create a .sublime-keymap file in the User directory (the keymap file name doesn't matter, though as a convention it's generally kept Default (os).sublime-keymap where os = Windows, Linux or OSX based on your OS). Then paste in the following (the key binding is of your choice, it can be anything as long as it doesn't conflict with existing ones):-
[
{ "keys": ["ctrl+alt+m"], "command": "highlight_media_query" }
]
Doing that & pressing the said key binding (you need to have opened the said css file), should now select all #media print queries.

How to disable Shift Ctrl?

I would like to disable Shift Ctrl without disabling other shorcuts like Shift Ctrl A, or Ctrl A, or Shift A.
I have tried multiple combinaison of ^+:: return with and without :
- Up : ^+ Up:: return
- ~ : ~^+ Up:: return
- & : ~^ & ~+ Up:: return
Nothing work. Even when I start my script as admin it doesn work.
I want to rename Shift Ctrl because I have two keyboard languages and pressing Shift Ctrl change it. I already have the shorcut Windows Space so I don't need Shift Ctrl.
I have tried with ahk but I am open to any other way to solve this.
"^" is the modifier symbol for the Control key and "+" for the Shift key.
Modifier symbols are used only in key-combinations for modifying other keys.
Try also
+Ctrl Up:: return
or
Shift & Ctrl Up:: return
EDIT:
You can change or remove the combination that changes the keyboard language on Control panel --> Language, as shown in the comments below.

Ctrl + Alt + V: Disable auto-generation of the keyword "final"

It was not like this in version 1.5, but now that I updated my Android Studio to 2.1.1 whenever I generate a local variable with the Ctrl + Alt + V shortcut, the variable is generated with the keyword "final".
For example, let's say I have the following statements:
Object o = new Object();
o.toString();
Let's highlight the second line and press Ctrl + Alt + V and voila:
final String s = o.toString();
// ^ I'm talking about this.
How do I disable the auto-generaion of the keyword "final"?
This auto-insertion of final is highly annoying as I use this shortcut like every other minute and I have to delete the keyword because most of the time I don't need the variable to be final and would not like to keep my code unnecessarily wordy.
I don't know why you want to turn it off since it is good practice.
Here is how you can do that:

How to auto-format whitespaces in comments using android studio?

My problem is, when I comment out a line using Ctrl + /,
// comment
and then auto-format the code,
// comment
the comment will still contain whitespaces after the "//" that I wouldn't want to keep.
I've already checked the Settings>Editor>Java>Wrapping and Braces options, and also the other tabs.
Thanks in advance.
I have just solved this problem.
Code Style -> Java -> Code Generation
There is a "Comment Code" and deselect the "Line comment at first column"
Code Style -> Java -> Wrapping and Braces
There is a "Keep when reformatting" and deselect the "Comment at first column"
As follows
Code Generation
Wrapping and Braces
I think your problem can be solved.
To apply identation to a document press Ctrl + Alt + L (Option + Command + L in Mac)
But the only way, once you have few comments with that "problem", I guess is to replace ('// ' by '//') (Shortcut to replace: Ctrl + Shift + R)
Hope it hepls.

Resources