This one is hard for me to explain, I'm sorry, but I have pictures!
When I hit ctrl+d twice, it selects the first two foo, like this:
Then I can change those, and all the other foo are still highlighted:
But if I hit ctrl+d again now, it selects both bar because that's where my cursors are. I'm trying to change two foos at a time, as efficiently as possible. How can I get the next two selected? They're still highlighted so I think there has to be a way?
I can think of two ways:
One, use F3 to "Find next" which will highlight the third foo. So, hitting Ctrl + D now will have the next two foo's selected. (⌘ + G instead of F3 for Mac users)
Option two:
Do it manually with the arrow keys, reselecting as you go.
Simply. When u make changes to those first foo, your cursor stays at the end of first foo. Just press arrow-key down, so the cursor goes to second-line foo, than ctrl+d again -> changes -> arrow-key down -> ctrl+d and on and on..
ADDED:
When edited text goes longer, than second line's 'foo', you can always navigate to the line begining. Maybe Home button?
If home is not a solution, you can always make your own keybindings, maybe, this way:
{ "keys": ["ctrl+alt+left"], "command": "move_to", "args": {"to": "bol", "extend": false} },
{ "keys": ["ctrl+alt+right"], "command": "move_to", "args": {"to": "eol", "extend": false} }
This way you will be able to get to lines begining by pressing Ctrl+alt+left.. of course u can change it - code is pretty simple.
Related
Is there any way to remove the mark from gutter. You can set mark with command/shortcut "keys": ["ctrl+k", "ctrl+space"], "command": "set_mark", but I cant find command to remove it. Is there any way to remove it.
Clearing the mark is available from the Edit menu -> Mark -> Clear Mark, which executes:
command: clear_bookmarks {"name": "mark"}
(as can be seen with sublime.log_commands() in the ST console, or by viewing the main menu file in the Default package)
This is bound to Ctrl+K Ctrl+G by default.
Going to Tools > New Snippet everytime I need to create a new Sublime Snippet is starting to become cumbersome. Is there a way to create a shortcut in which I can jump to the new snippet page by pressing Command + i?
Preferences -> Key Bindings - User, then add the below line:
{ "keys": ["ctrl+g"], "command": "new_snippet" }
You can replace the ctrl+g combination with anything of course.
BUT be aware: it might happen that the keyboard layout doesn't send the exact keys that the command is bound to.
To investigate this open the console at View -> Show Console or with CTRL+, and type sublime.log_input(True). Now click in the document and give your key combination a try - if the appropriate output doesn't appear in the console, you better specify another combination.
Finally, if sublime.log_input(True) bothers your coding or debugging process, you can easily disable it by clicking again in the console and using the UP arrow to get the command you typed the last type, change True to False, then hit Enter.
open the command palette, find a item named "Preferences: Key Bindings - User", open it and add this:
{ "keys": ["ctrl+y"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": "Snippet: "}}
You can change the "ctrl+y" for anything you like to be the shortcut.
The only way to make a multiline cursor in Sublime text 3 is Ctrl+Shift+RC+Drag. Is there any way to do this without using a mouse?
Yes, there is. Using Shift↓ or Shift↑, select the lines you want multiple cursors on. Next, hit CtrlShiftL (CommandShiftL on macOS) to split the selection into lines. Finally, hitting ← will put the cursors at the beginning of the lines, while → will put them at the end.
Edit
There is also another, quicker way (thanks to minitech) - CtrlAlt↑/↓ will create multiple cursors without having to do selections first, and you can place the cursors anywhere in the line you wish. However, on Windows these key combos may be mapped to changing the screen orientation. To change this, hit CtrlAltF12 to open the Intel control panel, click Options, and either remap the screen orientation hotkeys, or click Off on the left side to disable all of them.
You can use Middle mouse button for this as well.
Click & Hold Middle mouse button and drag up and down
Standard key bindings not work for me(Ubuntu 16.4 and Win 10), but after redefining works good! To redefine default key bindings use (Preferences->Key Bindings)
{ "keys": ["alt+shift+down"], "command": "select_lines", "args":{"forward": true} } will add cursor below, { "keys": ["alt+shift+up"], "command": "select_lines", "args": {"forward": false} } will add cursor above.
MAC: ctrl ( ^ ) + Shift + up / down arrow
ctrlShiftup arrow
ctrlShiftdown arrow
What works for me on a window 10 Surface Pro is
Ctrl + Alt + up/down
Because Ctrl + Alt + up/down already works for me, there is no need to do another key binding. I have it set up the same way for VS Code as well: Ctrl + Alt + up/down.
Or you can also map it as Yaroslav says (which I voted up), which works as well.
In Ubuntu, the accepted answer works. Also, you can do:
Shift + Alt + Key up/down
It was much simpler for me than any other answers above: Just hold ctrl and click on your mouse placing it where you want to have the second or third cursor.
I want to be able to use the alt key in Sublime Text 2 like I can use it on the command line in iTerm. For example, when I hit alt+f, the cursor moves forward a word, or when I hit alt+b, the cursor moves backward a word.
Instead, what happens is UTF+8 characters corresponding to the keys get inserted (ex: ƒ or ∫). In iTerm on the Mac, I can change the left alt behavior to act like +esc and it seems to do the trick.
This could either be a Mac OS X problem in general (I have the same problem in the web browser) or something specific with Sublime Text 2 so I would appreciate any Mac or Sublime Text 2 expertise. Thanks!
After using Sublemacs Pro for a few days, I realized it does too much for my liking, although it may be fine for more seasoned emacs users.
I come from TextMate and what I really want is the best of all worlds: mostly Sublime shortcuts, a few missing shortcuts from Textmate's ruby library of shortcuts, and a few shortcuts that Textmate stole from emacs.
So, I figured out how to solve the alt+f and alt+b problems:
{ "keys": ["alt+b"], "command": "move", "args": {"by": "subwords", "forward": false} },
{ "keys": ["alt+f"], "command": "move", "args": {"by": "subword_ends", "forward": true} }
If I find some more really useful ones, I'll post them here. Also, if I find a resource that lists all the possible "by" field values, I'll post that, as well.
There is a Sublime Text 2 plugin called Sublemacs Pro that provides emacs-like keybindings and operations, including those that you mentioned pining for. You can find installation instructions and the complete keybinding reference on the Github page.
I have some code like:
testVar = { a: 1 };
testVariable1 = 2;
var c = testVar.a + testVariable2;
var d = testVar;
I want to rename "testVar" variable. When I set multiple cursors with Ctrl+D and edit variable, "testVariable" is also selected and edited.
Is there a way to skip some selections while setting multiple cursors with Ctrl+D?
Just use Ctrl+K, Ctrl+D.
(for OS X: Cmd+K, Cmd+D)
Needs a bit of practice, but gets the job done!
You can press Ctrl+K and Ctrl+D at the same time to skip a selection. If you went too far with your selection, you can use Ctrl+U to return to a previous selection.
Note: Replace Ctrl with Cmd for Mac OS X.
The default configuration for this can be viewed by going to Preferences > Key Bindings-Default in the application menubar, where you will see something like this:
{ "keys": ["ctrl+d"], "command": "find_under_expand" },
{ "keys": ["ctrl+k", "ctrl+d"], "command": "find_under_expand_skip" }
If you want, you can configure the keys as per your needs, by going to Preferences > Key Bindings-User and copy the above code and then change the keys.
If you have the cursor over the word and use Ctrl + D to select the word. The next time you hit Ctrl + D it should select the next highlighted word.
If you double click to select word, Ctrl + D will select the exact string not just the highlighted ones.
In other words, Ctrl + D with nothing highlighted does whole-word search. If you have something highlighted already, Ctrl + D will do substring searching.
I have tested and it works in Sublime Text 2 Version 2.0.1, Build 2217.
Place curser before the variable, do not select the variable, hit Ctrl+D to select every occurence of the variable, not pattern.
Updated answer for vscode in 2020 on windows, in keybindings.json add this line to skip the next selected occurrence easily:
{
"key": "ctrl+alt+d",
"command": "editor.action.moveSelectionToNextFindMatch",
"when": "editorFocus"
},
*yes I know the question is for sublime text, but I found it by googling the same question + vscode, so it might help someone since the mappings are identical.
I think I get why it was confusing to me: This is not skipping, it's unselecting.
You hit Ctrl+D as usual and if you select one by mistake you do Ctrl+K, D where you first press the K and then the D without letting go the Ctrl. This unselects the selection.