Navigate through camel case - sublimetext2

I was working with Eclipse and I want that I can jump between words written in camel-case by pressing STRG. Now I'm working with Sublime and I can't find a shortcut to do so nor a plug-in, which achieves it.
The following example shows my problem
aFunctionName
In Eclipse it jumps from a to the F to the N of aFunctionName, when I press STRG + RIGHTARROW. In Sublime it skips the whole word. Is there a shortcut, a plug-in or can I set an entry into the config?

In Sublime Text, this functionality is bound to alt+right by default. In ST lingo it's referred to as "subwords" rather than having any reference to camelCase.
From the default keybindings:
{ "keys": ["alt+left"], "command": "move", "args": {"by": "subwords", "forward": false} },
{ "keys": ["alt+right"], "command": "move", "args": {"by": "subword_ends", "forward": true} },
{ "keys": ["alt+shift+left"], "command": "move", "args": {"by": "subwords", "forward": false, "extend": true} },
{ "keys": ["alt+shift+right"], "command": "move", "args": {"by": "subword_ends", "forward": true, "extend": true} },

Related

macro extension does not run commands synchronously

I want to make a shortcut which can insert the current date at the 72 position of the line in VScode.
I let the Cursor go to the Pos 72 first and used an extension to get the current date.
But, the customize extension did not wait for the Cursor moving, and the date appeared at the current position.
It seems like Asynchronous happens when the macros run.
Here is my code
"addDate": [
"cursorLineEnd",
{"command": "type", "args": {"text": " "}},
"cursorLineStart",
{"command": "cursorMove", "args": {"to": "right", "by": "character", "value": 72}},
{"command": "type", "args": {"text": "AD"}},
"editor.action.trimTrailingWhitespace",
{"command": "insertDateString.insertDate"},
]
The {"command": "insertDateString.insertDate"}, did not wait the cursorMove finished and worked directly.
Is there any ways like "promise...then" or priority setting that let PG runs by sequence?
Thanks
I suggest using the macro command multi-command. It properly handles synchronous commands. So using multi-command, put this into your settings.josn:
"multiCommand.commands": [
{
"command": "multiCommand.addDate",
"sequence": [
"cursorLineEnd",
{
"command": "type",
"args": { "text": " "
}
},
"cursorLineStart",
{"command": "cursorMove", "args": {"to": "right", "by": "character", "value": 72}},
{"command": "type", "args": {"text": "AD"}},
"editor.action.trimTrailingWhitespace",
{"command": "insertDateString.insertDate"}
]
}
]
and then your keybinding looks like this:
{
"key": "alt+d", // whatever you choose
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.addDate" },
// "when": "editorTextFocus"
},
And it works as expected.

Browse autocomplete results without arrows in Sublime

I'm using Sublime Text 3, and I am trying to not use arrows for anything. However I can't seem to scroll through different results of autocomplete or Ctrl+P without the arrows.
Any suggestions? Thanks!
You probably want something like this in your keymaps file:
// navigation with tab in autocomplete popup
{ "keys": ["tab"], "command": "move", "args": {"by": "lines", "forward": true}, "context": [{ "key": "auto_complete_visible" }] },
{ "keys": ["shift+tab"], "command": "move", "args": {"by": "lines", "forward": false}, "context": [{ "key": "auto_complete_visible" }] },
// navigation with tab in overlay
{ "keys": ["tab"], "command": "move", "args": {"by": "lines", "forward": true}, "context": [{ "key": "overlay_visible", "operator": "equal", "operand": true } ] },
{ "keys": ["shift+tab"], "command": "move", "args": {"by": "lines", "forward": false}, "context": [{ "key": "overlay_visible", "operator": "equal", "operand": true } ] },

Move tab from one column to another in Sublime Text using only keys

Does anyone know this shortcut? I'm looking for it online, but I can't seem to find it
To move it is CTRLSHIFT1 to move to Group 0, CTRLSHIFT2 to Group 1, and so on - that's on Linux, Windows, and OSX.
Text buffers can also be moved to their neighbouring groups:
Linux, Windows:
CTRLk + CTRLSHIFTLEFT
CTRLk + CTRLSHIFTRIGHT
OSX
SUPERk + SUPERSHIFTLEFT
SUPERk + SUPERSHIFTRIGHT
Here's the whole group section of my Default (Linux).sublime-keymap - the Windows keys are all exactly the same, while the OSX keys are the same in the top section but differ in the bottom section, below where I have placed an explanatory comment.
// The keys BELOW are for Linux, Windows, and OSX.
{ "keys": ["ctrl+1"], "command": "focus_group", "args": { "group": 0 } },
{ "keys": ["ctrl+2"], "command": "focus_group", "args": { "group": 1 } },
{ "keys": ["ctrl+3"], "command": "focus_group", "args": { "group": 2 } },
{ "keys": ["ctrl+4"], "command": "focus_group", "args": { "group": 3 } },
{ "keys": ["ctrl+5"], "command": "focus_group", "args": { "group": 4 } },
{ "keys": ["ctrl+6"], "command": "focus_group", "args": { "group": 5 } },
{ "keys": ["ctrl+7"], "command": "focus_group", "args": { "group": 6 } },
{ "keys": ["ctrl+8"], "command": "focus_group", "args": { "group": 7 } },
{ "keys": ["ctrl+9"], "command": "focus_group", "args": { "group": 8 } },
{ "keys": ["ctrl+shift+1"], "command": "move_to_group", "args": { "group": 0 } },
{ "keys": ["ctrl+shift+2"], "command": "move_to_group", "args": { "group": 1 } },
{ "keys": ["ctrl+shift+3"], "command": "move_to_group", "args": { "group": 2 } },
{ "keys": ["ctrl+shift+4"], "command": "move_to_group", "args": { "group": 3 } },
{ "keys": ["ctrl+shift+5"], "command": "move_to_group", "args": { "group": 4 } },
{ "keys": ["ctrl+shift+6"], "command": "move_to_group", "args": { "group": 5 } },
{ "keys": ["ctrl+shift+7"], "command": "move_to_group", "args": { "group": 6 } },
{ "keys": ["ctrl+shift+8"], "command": "move_to_group", "args": { "group": 7 } },
{ "keys": ["ctrl+shift+9"], "command": "move_to_group", "args": { "group": 8 } },
{ "keys": ["ctrl+0"], "command": "focus_side_bar" },
// The keys BELOW are for Linux and Windows only.
//
// The OSX keys all use 'super' instead of 'ctrl'.
//
// e.g. In the top command use: ["super+k", "super+up"]
// e.g. In the bottom command use: ["super+k", "super+shift+right"]
{ "keys": ["ctrl+k", "ctrl+up"], "command": "new_pane" },
{ "keys": ["ctrl+k", "ctrl+shift+up"], "command": "new_pane", "args": {"move": false} },
{ "keys": ["ctrl+k", "ctrl+down"], "command": "close_pane" },
{ "keys": ["ctrl+k", "ctrl+left"], "command": "focus_neighboring_group", "args": {"forward": false} },
{ "keys": ["ctrl+k", "ctrl+right"], "command": "focus_neighboring_group" },
{ "keys": ["ctrl+k", "ctrl+shift+left"], "command": "move_to_neighboring_group", "args": {"forward": false} },
{ "keys": ["ctrl+k", "ctrl+shift+right"], "command": "move_to_neighboring_group" },
Hope this helps.
If you mean rearranging the tabs within the same group, there's a good plugin called MoveTab
My keybindings Sublime Text --> Preferences --> Key Bindings (User) -->
{
"keys": ["super+alt+shift+["],
"command": "move_tab",
"args": { "position": "-1" }
},
{
"keys": ["super+alt+shift+]"],
"command": "move_tab",
"args": { "position": "+1" }
}
Allows CMD+Shift+Option+[ and CMD+Shift+Option+]
If you have Package Control you can install via CMD+Shift+P --> Install Package --> MoveTab
import sublime, sublime_plugin
class DualViewMoveTo(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command('set_layout', { "cols": [0.0, 0.5, 1.0], "rows": [0.0, 1.0], "cells": [[0, 0, 1, 1], [1, 0, 2, 1]] })
self.window.run_command('focus_group', { "group": 0 })
self.window.run_command('move_to_group', { "group": 1 })
There's an excellent plugin offered by Sublime Text itself called Origami, it allows you to create new panes(Columns), delete panes, move and clone views(Tabs) from pane to pane. You can easily shift tabs between a split view using this plugin. Also if you just reorder the tabs in a single pane then Sublime Text offers another good plugin called Move​Tab.

sublime text 2 - add visual mode without vintage mode

My problem is that I would like to be able to use a visual selection without being in vintage mode. Here are my key bindings:
[
{ "keys": ["ctrl+k"], "command": "move", "args": {"by": "lines", "forward": false} }
, { "keys": ["ctrl+j"], "command": "move", "args": {"by": "lines", "forward": true} }
, {"keys":["ctrl+h"], "command": "move", "args": {"by": "characters", "forward": false}}
, {"keys":["ctrl+l"], "command": "move", "args": {"by": "characters", "forward": true}}
, {"keys":["ctrl+e"], "command": "move", "args": {"by": "characters", "forward": true}}
,{ "keys": ["ctrl+e"], "command": "move_to", "args": {"to": "eol", "extend": false} }
,{ "keys": ["ctrl+a"], "command": "move_to", "args": {"to": "bol", "extend": false} }
, {"keys": ["ctrl+y"], "command": "copy"}
, {"keys": ["alt+y"], "command": "paste"}
, { "keys": ["ctrl+v"], "command": "enter_visual_mode"}
]
As you can see I have vi-like commands except with ctrl modifier. I want it this way. I would like ctrl+v to enter visual mode. I saw in the Vintage mode default key bindings file, the command was defined like I have it defined. Obviously "enter_visual_mode" is a command defined somewhere else in Vintage mode, but I don't know how to include that into my default editor. If anyone could give some guidance on setting this up it would be appreciated!
You will need to use a plugin to support the behavior you want. I don't know of one that is fully flushed out, but I know this was a start to define different keyboard modes (like visual). Take a look at https://github.com/KonTrax/MultiBind. Untested but add the following to your key binding file should work.
// Toggle "visual" layout
{ "keys": ["ctrl+v"],
"command": "multibind_toggle",
"args" : { "layout": "visual" }
},
// Show current layout in statusbar
{ "keys": ["ctrl+shift+\\"],
"command": "multibind_show",
"args" : { }
},
{ "keys": ["ctrl+k"], "command": "move", "args": {"by": "lines", "forward": false, "extend": true}, "context": [{ "key": "multibind.visual" }]},
{ "keys": ["ctrl+j"], "command": "move", "args": {"by": "lines", "forward": true, "extend": true}, "context": [{ "key": "multibind.visual" }] },
{"keys":["ctrl+h"], "command": "move", "args": {"by": "characters", "forward": false, "extend": true}, "context": [{ "key": "multibind.visual" }]},
{"keys":["ctrl+l"], "command": "move", "args": {"by": "characters", "forward": true, "extend": true}, "context": [{ "key": "multibind.visual" }]},
{"keys":["ctrl+e"], "command": "move", "args": {"by": "characters", "forward": true, "extend": true}, "context": [{ "key": "multibind.visual" }]},
{ "keys": ["ctrl+e"], "command": "move_to", "args": {"to": "eol", "extend": true}, "context": [{ "key": "multibind.visual" }]},
{ "keys": ["ctrl+a"], "command": "move_to", "args": {"to": "bol", "extend": true}, "context": [{ "key": "multibind.visual" }] }
You have ctrl+e defined twice, so I'm not sure which behavior you want.

Sublime Text 2 move cursor out of parenthesis, quotes, or brackets

I need a fast way to make the cursor jump outside the auto wrap qoutes or other syntax elements. I don't want to have to reach down to my arrow keys each time, and definitely don't want to go to my mouse.
Is there a quick and easy way to solve this for my workflow?
You can use a shortcut (shift+space, or whatever you like) to move the cursor.
In your Key Bindings - User:
{ "keys": ["shift+space"], "command": "move", "args": {"by": "characters", "forward": true} }
I made a few key bindings out of macros as well.
You must make a macro for these, unless you want to spend more time building them, but it's really easy. Just go to Sublime Text, Tools > Record Macro, or hit ctrl Q. Save the file in Packages/User/ and then hit ⌘ , to open up your User Settings. Paste the settings below in there and boom. ( The | below represents my cursor )
Here are the one's I chose:
Function auto-bracketizer
When the cursour is here:
totallyAwesomeness(|)
Use the option + tilda shortcut.
⌥ ~
This prefills the function with brackets and the text ' # code... ' highlighted. It only works when inside the parenthesis.
Sublime User Settings
{
"keys": ["option+`"], "command": "run_macro_file", "args": {"file": "Packages/User/superBracketizeFunction.sublime-macro"}
},
Download Macro
Auto-End Line With Semicolon
When the cursour is here:
echo 'say what!!??|'
Use the command + semicolon shortcut.
⌘ ;
This adds a closing ; at the end of current line and moves you to the line below it. It actually works wherever you are on the line.
Sublime User Settings
{
"keys": ["super+;"], "command": "run_macro_file", "args": {"file": "Packages/User/superEndLineWiSemiColin.sublime-macro"}
},
Download Macro
Exit Argument & Exit Function
When your cursor is anywhere inside the function it will end up here:
public function totallyAwesomeness()
{
echo 'say what!!??';
} |
echo 'yep... that just happened';
Use the command + enter shortcut.
⌘ Enter
This will let you jump outside the argument and a space to the right as well as anywhere from within the function it will jump you out of it just being the closing bracket.
Sublime User Settings
{
"keys": ["option+enter"], "command": "run_macro_file", "args": {"file": "Packages/User/superExitFunctionArg.sublime-macro"}
},
Download Macro
Just in case you don't know what the path is to your User folder is, it is shown below.
/Users/alexcory/Library/Application Support/Sublime Text 3/Packages/User/
Also the Library folder is usually hidden, so you can download a program called Revealer that will allow you to toggle those hidden files.
If you want to know how I made these just hit me up and I'll show you! :D
Best solution for this is recording a macro on Sublime Text and then assigning it to a keyboard shortcut. Follow these steps:
Create a line such as alert('hello') and leave the cursor right
after letter 'o'.
Then go to Tools > Record a Macro to start recording.
Press Command+→ to go to the end of line.
Press ; and hit Enter
Stop recording the macro by going to Tools > Stop Recording Macro
You can now test your macro by Tools > Playback Macro (optional)
Save your macro by going to Tools > Save Macro (ex: EndOfLine.sublime-macro)
Create a shortcut by adding this between the square brackets in your
in your Preferences > Key Bindings - User file:
{
"keys": ["super+;"], "command": "run_macro_file", "args": {"file": "Packages/User/EndOfLine.sublime-macro"}
}
Now, every time you hit Command+;, it will
magically place the semicolon at the end of current line and move the cursor to the next line.
Happy coding!
A more complete way to make a key binding would be:
{ "keys": ["shift+space"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)\"\\]]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
},
Assuming you want shift+space as the shortcut. Or you can change it to tab as well
As found in http://www.sublimetext.com/forum/viewtopic.php?f=3&t=5174#p23086
Following Riccardo Marotti's post;
If you would like to bypass the bracket on the next line, you can replace "characters" with "lines" in the args section.
{ "keys": ["shift+space"], "command": "move", "args": {"by": "lines", "forward": true} }
on a Dell XPS, Ctrl Enter does the trick for me
I just have this feature partially implemented with the help of a plugin named run_multiple_commands.py (see below)
(only tested on ST3, but the plugin is earlier than the first version of ST3 and should work on ST2 too).
Shortcut configuration is as below:
{
"keys": ["shift+space"],
"command": "run_multiple_commands",
"args": {
"commands": [
{"command": "move", "args": {"by": "characters", "forward": true} }
]
},
"context":
[
{ "key": "preceding_text", "operator": "regex_contains", "operand": "[)\\]}'\"]$", "match_all": true},
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
},
{
"keys": ["shift+space"],
"command": "run_multiple_commands",
"args": {
"commands": [
{"command": "move", "args": {"by": "characters", "forward": true} },
]
},
"context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)\\]}'\"]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
},
{
"keys": ["shift+space"],
"command": "run_multiple_commands",
"args": {
"commands": [
{"command": "move_to", "args": {"to": "brackets"} },
]
},
"context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[(\\[{]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
},
{
"keys": ["shift+space"],
"command": "run_multiple_commands",
"args": {
"commands": [
{"command": "move_to", "args": {"to": "brackets"} },
{"command": "move", "args": {"by": "characters", "forward": true} },
]
},
"context":
[
{ "key": "following_text", "operator": "not_regex_contains", "operand": "^[)\\]}'\"]", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "[)\\]}'\"]$", "match_all": true},
{ "key": "following_text", "operator": "not_regex_contains", "operand": "^[(\\[{]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
},
One shortcut (shift+space) for four conditions:
cursor is just after quotes or closing parentheses/bracket:
move one character forward
cursor is just before quotes or closing parentheses/bracket:
move one character forward
cursor is just before opening parentheses/bracket:
move to closing parentheses/bracket
!1 && !2 && !3:
move to closing parentheses/bracket
and move one more character forward
To use this configuration in your ST, you should first add a file named run_multiple_commands.py to your .../Package/User/ directory, and the content of which is the second code piece of This Article
This solution is just fine for everyday use but is not perfect because:
the cursor is unable to jump out of quotes (just step over it when the cursor is directly followed by one).
the cursor is unable to jump out of the nearest parenthesis, quotes, or brackets when the code block is commented.
Ctrl + M is the default one that I have on windows machine.
Just do it
Perhaps the home and the end key are near to your fingers.
I use ctrl+f to move cursor one space forward. Also, on mac, I interchanged caps lock with ctrl. caps lock+f is much easier to reach. It works fairly well for me.
I found another way which lies within sublime keybindings itself. Basically, I just modify the keybindings for auto closing parens, that is, I replace "contents": "($0)" with "contents": "($1)$0". Then just hit Tab to get out of the parenthesis. So I add in my keybindings the following:
{ "keys": ["("], "command": "insert_snippet", "args": {"contents": "($1)$0"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|;|\\}|$)", "match_all": true }
]
},
And similar for square brackets, curly brackets, and single and double quotes.
Ctrl + PgUp Cycle up through tabs
Ctrl + PgDn Cycle down through tabs
This can go to the end of brackets