Sublime Test 4; Cancel "Goto Definition" (F12) - sublimetext3

I noticed that the behavior in Sublime Text 4 seems to have changed in the latest release. Previously I could hit F12 to bring up all the definitions of a symbol with a little pop-up showing a list of all instances. I could preview them all using the arrow keys to navigate and then hit ESC to return from where I came.
It seems that since the latest version, hitting escape lands me on whichever page I was previewing. Previously this would require me pressing "enter".
Does anyone know if this is now a setting or how I can get the old functionality back?

I ended up finding one workaround based on koe's suggestion. It seems like if you switch tabs before hitting escape, Sublime exhibits the desired behavior. With this in mind I tried to bind a keystroke to switch tabs and the issue the "cancel" command and it worked.
I bound this command chain to the "escape" key and it has restored my workflow. I'm not sure if this will have implications for using escape in another context but I'll update if I find out anything else.
{ "keys": ["escape"],
"command": "chain",
"args": {
"commands": [
["next_view_in_stack"],
["cancel"],
]
}
},
EDIT: Above version doesn't handle ctrl+p followed by esc. Also doesn't allow find panel to be close by escape. Was able to modify it to be more targeted.
{ "keys": ["escape"],
"command": "chain",
"args": {
"commands": [
["next_view_in_stack"],
["prev_view_in_stack"],
["cancel"],
]
},
"context":
[
{ "key": "overlay_visible", "operator": "equal", "operand": true },
{ "key": "panel_has_focus", "operator": "equal", "operand": false }
]
},

Related

Automatically convert indentation from 2 to 4 spaces in Sublime Text 3

There are a few topics about auto-conversion of the indentation in Sublime Text, but I didn't find the way to do it automatically.
Many files I download have indentation of 2, which I hate, so I want to convert them to 4. What I do is:
Select Tab size: 2
Convert indentation to Tabs
Select Tab size: 4
Convert indentation to Spaces
I don't think I need to mention that it's too much work for every single file. Some people suggest Reindent option, but for my experience, it almost never works correctly.
Is there some build-it way, or perhaps a package to convert indentation in one step?
Converting indentation to a personal preference can be a tedious task in Sublime Text which, as you observe, gets mentioned on StackOverflow quite regularly. In fact 4 years ago I answered a question which lists almost exactly the steps you've listed in your question.
I too have found the 3 Command Pallette reindent commands to be a little temperamental, sometimes working as I think they ought to and sometimes doing (what appears to be) nothing at all. But no matter...
There is of course a way to perform the actions you've listed in one step; use a macro.
Copy and paste the macro code below and save it in your User folder as IndentationTo4Spaces.sublime-macro.
[
{ "command": "set_setting", "args": {"setting": "tab_size", "value": 2} },
{ "command": "unexpand_tabs", "args": {"set_translate_tabs": true} },
{ "command": "set_setting", "args": {"setting": "tab_size", "value": 4} },
{ "command": "expand_tabs", "args": {"set_translate_tabs": true} }
]
You could run the macro from the menu Tools --> Macros --> User --> IndentationTo4Spaces, set up a key binding, or add an entry to the Command Pallette.
// Add keys to: Packages/User/Default (Linux/OSX/Windows).sublime-keymap
{ "keys": ["ctrl+shift+y"], "command": "run_macro_file",
"args": {"file": "res://Packages/User/IndentationTo4Spaces.sublime-macro"} },
// Add command to: Packages/User/Default.sublime-commands
{ "caption": "Convert Indentation To 4 Spaces", "command": "run_macro_file",
"args": {"file": "res://Packages/User/IndentationTo4Spaces.sublime-macro"} },

Sublime text: How to disable automatching 'quotes'

Here's my problem: In common lisp, a 'single quote' is not used for strings and thus doesn't come in pairs with another quote, so sublime text auto-inserting another quote does more harm than good. How do I disable that option just for lisp and just for single quotes?
Just add a keybinding to your keymap (which you can find in preferences, key bindings) and in the user tab paste this:
{
"keys": ["'"], "command": "insert", "args": {"characters": "'"},
"context":
[
{ "key": "selector", "operator": "equal", "operand": "source.lisp" }
]
},
Let me know if you need anything else! I tested it in sublime text (I use it too)
If you go into Preferences > Settings on Sublime Text 3, you should see various preferences that you can control manually. This line controls the auto-pairing of quotes:
// Controls auto pairing of quotes, brackets etc
"auto_match_enabled": true,
To overwrite it, add "auto_match_enabled": false, to the right pane (user prefs) between the brackets and save to update your preferences. If you already have preferences in the right pane, be sure to separate with a ',' like with json properties.

Sublime: How can I jump n lines with the keyboard arrows?

I feel very tedious when I have to percor the text file with the arrow, line by line, but I feel that PageDown/PageUp makes me lose where I was.
Is there a way that I can simply jump n lines using a simply shortcut (like ctrl+arrow down/up)? I think that 5 lines would fits me very well.
The built in movement commands allow you to move in a variety of ways, but only one move at a time (e.g. one line up, one word left, one page down, etc).
As Ben mentions in his answer, one way around that is to create macros that make the movements that you want, bind keys to run the macros, and you're good to go.
Another alternative is to use a simple plugin such as the following (originally from this forum post), which you can use by selecting Tools > Developer > New Plugin... from the menu, replacing the stub code with this code, and then saving in the default location as something like move_amount.py:
import sublime
import sublime_plugin
class MoveAmountCommand(sublime_plugin.TextCommand):
def run(self, edit, amount=1, **kwargs):
for _ in range(amount):
self.view.run_command("move", args=kwargs)
This creates a command named move_amount that wraps the internal move command, providing an extra argument of amount to indicate how many times to take the move action. This can be handy if you have a few such bindings to make as it cuts down on the number of macros that you have to make and it's easier to customize them.
With that in place you can use the following key bindings, modifying the amount as desired:
{
"keys": ["ctrl+up"], "command": "move_amount",
"args": {"by": "lines", "amount": 5, "forward": false}
},
{
"keys": ["ctrl+down"], "command": "move_amount",
"args": {"by": "lines", "amount": 5, "forward": true}
},
Note that these keys are already bound to the scroll_lines command, which scrolls the viewport but leaves the caret alone, so if you use that functionality as well you may want to select different bindings.
From what I can tell there isn't an actual keyboard shortcut that will let you combine a move lines command with an amount to move.
Instead you can record & save two different macros. One moving up 5 lines, the other moving down 5 lines - (start recording macro, then hit the up or down arrow x number of times. stop recording, then save.).
Then you can create a binding to call them from your preferences file:
[
{ "keys": ["shift+alt+up"], "command": "run_macro_file", "args": {"file": "res://Packages/User/up-five-lines.sublime-macro"} },
{ "keys": ["shift+alt+down"], "command": "run_macro_file", "args": {"file": "res://Packages/User/down-five-lines.sublime-macro"} }
]

Sublime 3 abbreviation expander

I'm having an annoying problem on Sublime 3 while working on SASS files. After I type a colon : and then hit tab, it outputs another colon plus a semicolon ::;. Also it changes my declarations with what seems to be recommendations or something. For instance if I type in width: and then hit the tab, it changes width: to windows:.
I've been researching around to see what could cause this. I added "tab_completion": false and "auto_complete": false to my User sublime settings but that didn't fix it. Then I found that it might be the Emmet package that is causing this so I added "disable_tab_abbreviations_for_scopes": "source.scss, source.css" to my Emmet User settings but that didn't fix it either. Each time I've made a settings change I've closed Sublime and restarted.
I know I can use shift + tab, but I really would like to find out what is causing this as I'm starting a big SASS project and this is getting really annoying. Any help would be appreciated.
Thanx
I think the easiest way to do this is to add a keybinding to force ST to the desired behavior instead of changing the settings to entries you might not want.
Just add this to your keymap and a tab will be inserted in the described scenario:
{
"keys": ["tab"],
"command": "insert",
"args": {"characters": "\t"},
"context":
[
{ "key": "selector", "operator": "equal", "operand": "source.css, source.sass" },
{ "key": "preceding_text", "operator": "regex_contains", "operand": ":$" }
]
},

How to binding `space` key in Sublime Text Editor using `Vintageous` plugin

I want to know how to bind space key in command-mode using Vintageous plugin.
For example, I have the following keybinding to activate command palette:
{
"keys": ["super+shift+alt+ctrl+space"],
"command": "show_overlay",
"args": {
"overlay": "command_palette"
},
"context": [{
"key": "vi_command_mode_aware"
}]
}
As you can see, I use meta key with space. But my purpose is just to only use space key. Is it possible to do so. If I changed to "keys": ["space"], the binding is defective.
I'm using Sublime Text 3 build 3095 on OSX 10.11.2
Never mind, I eventually get it done, use " " could do the trick
Maybe you want to use <space>, defined here
#plugins.register(seqs.SPACE, (modes.NORMAL, ))

Resources