Is it possible to disable this behaviour? It's possible in Visual Studio but I would like to change this also on ST3.
I think that the original question is not about removing the functionality of shift+delete, but only removing the copy function from it. So I'd like to post my answer here in case somebody would be looking for specifically this.
I found right_delete, mentioned in the comments, to be rather inconvenient, because you would need your cursor to be at the beginning of the line in order to work. I found that line deletion is set to ctrl+shift+k by default (on Windows), so I just used its macro for shift+delete.
So here's the line I added to my Preferences > Key Bindings:
{ "keys": ["shift+delete"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
This way you don't need to worry about the position of your cursor, as long as it's within the wanted line.
On Windows/Linux, the Default key bindings map Shift+Delete to the cut command:
{ "keys": ["shift+delete"], "command": "cut" },
In order to disable that behaviour, you can select Preferences > Key Bindings from the menu, and add the following to the binding to the right hand pane:
{ "keys": ["shift+delete"], "command": "noop" },
Alternately you can replace noop with some other command that you would rather perform in this case instead, should you want to use the key for something else.
Related
I've found several topics related to my issue, but they didn't work. In Sublime Text 3, my macOS super+alt+f "find and replace shortcut" (raise the panel of find/replace) doesn't work. I already tried:
running "FindKeyConflicts: All key conflicts":
(super+l,alt+super+f)
latex_fill_all LaTeXTools
[{"operand": "text.tex.latex", "operator": "equal", "key": "selector"}]
an then put the following into Preference > Key Bindings (User):
{"keys": ["super+alt+f"], "command": "show_panel", "args": {"panel": "replace", "reverse": false}}
This is how to resolve your Sublime Text key binding conflict.
Install the BoundKeys package.
Run BoundKeys by selecting List bound keys from the Command Palette.
BoundKeys will create a new buffer (unsaved file) which lists all of your key bindings on a file by file basis, i.e. all the .sublime-keymap files that ST has loaded.
Have a look at this BoundKeys example output. The example has been heavily edited, enough so that you can easily see the essential components.
The keys from each .sublime-keymap file are shown, with the highest precedence (highest priority) file at the top, while those from the file with the least precedence (lowest priority) are shown last.
In the example output have a look at the bottom line in the top .sublime-keymap file, the User package. shift+f10 has been assigned to the context_menu command, the right-hand column shows that there is a conflict with the ChooseWindow package. Look a little down and you'll see the corresponding line in the ChooseWindow package - the shift+f10 line shows a conflict with *User*. The *asterisks* show that this key binding has been overwritten by the one in the User package.
Now search your BoundKeys output for Super+Alt+F. You should be able to tell where the key conflict is and it should be fairly easy to see how to resolve the conflict.
Note that you may have to search for Alt+Super+F as well. It should be clear that Super+Alt+F and Alt+Super+F are the same key binding but not the same text.
I hope this answer will help if you run into the same issue, because it's a bit tricky. The issue is a small App I use which used the shortcut above.
It's clear there is a Shortcut I didn't find at start. With this information I just changed the following within Preferences > Key Bindings:
{
"keys": ["super+shift+alt+f"], "command": "show_panel", "args": {"panel": "replace", "reverse": false}
}
I'm giving Sublimetext 3 a go as a long time VIM user. One thing I'm wondering is if there is a way to bind to multiple sequential keys. In VIM I have used imap hh => which lets me type 2 h's in sequence and get a =>. Is there any way to set this up in ST3?
The keys key in a key binding is a JSON list and can contain multiple keys that must be hit in sequence in order for the binding to activate. For example, the default key binding for opening the Sidebar (on Windows/Linux) is declared as the following, requiring you to press Ctrl+k followed by Ctrl+b:
{
"keys": ["ctrl+k", "ctrl+b"],
"command": "toggle_side_bar"
},
It's also possible to bind unmodified keys as well, such as "h" (although you cannot bind just a modifier by itself like "ctrl"), so for your purposes you can do something like the following:
[EDIT] Starting with ST4, you can indeed bind just a modifier key if desired. [/EDIT]
{
"keys": ["h", "h"],
"command": "insert",
"args": {
"characters": "=>"
},
},
{
"keys": ["h", "i"],
"command": "insert",
"args": {
"characters": "->"
},
},
These use the built in insert command to insert a specific set of text; this command is smart enough to ensure that the insertion happens at all carets in the file. As seen in this example you can have multiple such keys defined if you like as well.
Note however that a key binding such as this sample is somewhat naive in that it will block you from actually typing these characters in a row, such as that second example effectively blocking you from typing the word this without waiting a bit after entering the h to allow Sublime to time out the key chord.
To get around that you can employ a context of some sort that constrains the availability of that key binding.
If you take advantage of some Vim type package for Sublime such as NeoVintageous they would also allow you to use more vi-like bindings directly as well.
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"} }
]
I want to auto-align my code to make it easier to read, in a click. I am working on Sublime Text 3 and want to know about a method through which I can enable auto-indent of the code in just a click.
I'd recommend the AlignTab extension: https://github.com/randy3k/AlignTab (with Demo)
By using the https://github.com/randy3k/AlignTab package, you can activate the Table Mode which constantly aligns the code for you, until you run the command Exit Table Mode, for example:
{"keys": ["f12"], "command": "reindent", "args": {"single_line": false}}
In the title bar, go to Preferences > Key Bindings, then add this binding to "Key Bindings - User" file.
{"keys": ["alt+shift+f"], "command": "reindent", "args": {"single_line": false}}
Now whenever you want to auto-align your code, just highlight the desired code and press alt+shift+f
Source: https://coderwall.com/p/7yxpdw/auto-indenting-on-sublime-text-3
Note: This was the original answer from the OP #Utkarsh (with score 18) that OP deleted and edited into the question.
I am trying to build a new key binding on Sublime Text to show or hide the line numbers.
Do somebody know how to do it?
The setting used to show or hide line numbers is line_numbers. For instance, setting line_numbers: false in your User preferences file would permanently hide line numbers.
Now to answer your question, to toggle a setting, you can add the following to your User keybindings file:
{
"keys": ["ctrl+l"],
"command": "toggle_setting",
"args":
{
"setting": "line_numbers"
}
}
You can change ctrl+l to whatever keys you want.
If you ever want to toggle any other setting in the future, you can just use this exact code, but you would just have to change the "line_numbers" to the name of the setting you want to toggle.