VSCode OSX TERMINAL Delete Right From Cursor - macos

Does anyone know how to delete a word going to the end of the line (right) in the VSCode Terminal (not editor)?
This works fine doing shift+ctrl+rightArrow in the Editor and I've mapped the same key-binding in iterm2 which labels this behavior I'm looking for as "Move End of Selection Right By Word".
I would love to shift+ctrl+arrow in the TERMINAL to select my text like I can in iterm2.
I've searched and searched and have come up short. I'm using iterm.app in VSCode as well as setting my defaultProfile.osx to zsh.

Try these keybindings that I know work in Git Bash (in keybindings.json):
{
"key": "alt+delete", // whatever keybinding you want
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u001b\u007f" // delete from cursor to word left start
},
"when": "terminalFocus"
},
{
"key": "ctrl+delete",
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u001bd" // delete from cursor to word end right
},
"when": "terminalFocus"
}
These are sending controls sequences to the terminal. I don't think there is any built-in commands to do this.

Related

JupyterLab - How to add Command(⌘) + Enter for running a cell in macOS ? (How is ⌘ called?)

In MacOS, the default shortcuts for running a Notebook are Shift + Enter or CTRL + Enter,
But I would like to use Command (⌘) + Enter to run a cell.
In Settings I see the list of commands, but how is ⌘ called?
The (⌘) is called Accel, not sure if it is a JupyterLab specific or a general usage of the word.
In anycase, adding the following under Settings -> Keyboard Shortcuts -> User Preferences, allows me to run cells with ⌘ + enter:
{"shortcuts":
[
{
"command": "notebook:run-cell",
"keys": [
"Accel Enter"
],
"selector": ".jp-Notebook.jp-mod-editMode"
},
{
"command": "runmenu:run",
"keys": [
"Accel Enter"
],
"selector": ".jp-Notebook:focus"
},
]
}

Comment out code by highlighting and simultaneously right clicking in Sublime Text

Rather than taking my hand of the mouse to use Ctrl + Shift + /, I'd like to be able to comment code by highlighting it, and then while keeping the left mouse button held down, simultaneously right click and have it comment out - though I don't know if that's possible with Sublime Text keybinds.
If not, I'll just use a custom keyboard shortcut, but I'd prefer the mouse method.
You can customize mousebinds by creating a file named Default (Windows).sublime-mousemap, Default (OSX).sublime-mousemap, Default (Linux).sublime-mousemap or (for any OS) Default.sublime-mousemap in your settings folder \Packages\User and then creating your custom bind inside that file
You can read more here (it's actually about keybinds but the process of creating mousebinds is the same.)
I came up with something similar to what you are trying to achieve but could not bind mouse1 as modifier so the snippet below is working different.
After you've made a selection, click and hold right mouse button and then click left mouse button to toggle comment block on selected area.
[
{
"button": "button1", "count": 1, "modifiers": ["button2"],
"command": "toggle_comment", "args": {"block": true},
"press_command": "drag_select_callback"
}
]
This might be annoying if you comment something by accident, so you can change click to double click, by changing count value to 2 or 3 for triple click etc.
Block comment is defined by {"block": true}, if you would like line comments just change it to false
[
{
"button": "button1", "count": 1, "modifiers": ["button2"],
"command": "toggle_comment", "args": {"block": false},
"press_command": "drag_select_callback"
}
]

Sublime Text 3 indentation driving me nuts

I'm using Sublime Text 3 as my code editor. I would like some help/explanation as to why the indentation misbehaves so much:
Is there any way to force the indentation when you open a file (I like it set to tabs, tabs_size = 4)?
Whenever I save a file, it automatically reverts the indentation to spaces... How would one go about avoiding that?
Any help is appreciated, I've been pulling my hair because of these tiny issues.
P.S.: Here are my settings
{
"color_scheme": "Packages/User/base16-ocean.dark (SL).tmTheme",
"detect_indentation": false,
"tab_size": 4,
"translate_tabs_to_spaces": false,
"font_face": "Source Code Pro",
"font_size": 15.0,
"ignored_packages":
[
"SideBarEnhancements",
"Vintage"
],
"theme": "Spacegray.sublime-theme",
"word_wrap": true
}

Select only white characters in Sublime Text 3

Currently, when you press Ctrl + Shift + Right Arrow or Ctrl + Shift + Left Arrow, Sublime Text 3 will select all spaces (all white characters) from current position until next word including this word.
Is there any way (probably yes) to modify ST3's config file or key bindings file to force it to select only spaces (white characters) only, so excluding next word? I'm really not comfortable with default behaviour.
By default these shortcuts are defined like this:
{ "keys": ["ctrl+shift+right"], "command": "move", "args": {"by": "word_ends", "forward": true, "extend": true} },
{ "keys": ["ctrl+shift+left"], "command": "move", "args": {"by": "words", "forward": false, "extend": true} }
The important part is the by argument. What the above basically means is that the forward selection should select up to word end (whitespace + next word) and the backwards selection should select up to a word start (white space + beginning of the previous words).
Now to get the result you want you might switch the by for the forwards selection to words and for the backwards selection to word_ends. That way if you do forward selection only space up to beginning of the next word will be selected and in the case of a backwards selection the whitespace up to the end of previous word will be selected.
To customize it like this, put the following in Preferences/Keybindings - user to override the defaults.
{ "keys": ["ctrl+shift+right"], "command": "move", "args": {"by": "words", "forward": true, "extend": true} },
{ "keys": ["ctrl+shift+left"], "command": "move", "args": {"by": "word_ends", "forward": false, "extend": true} }
Try it and let me know in the comments if this works for you :)

CTRL + Click Binding in Sublime Text 2

One very long standing habit I have with my IDE of many years is that the CTRL (or command) + Click selects a full word. It is the equivalent of doing a double click on a word currently in ST2. I am hoping to be able to restore this ability in ST2. Would I go about it with a key-binding or a plugin?
If you create a sublime-text-2/Packages/User/Default (Linux).sublime-mousemap file (assuming you are on Linux) and put this in it (If the file is already there then put it at the end of the file within the square brackets already present):
[
{
"button": "button1", "count": 1, "modifiers": ["ctrl"],
"press_command": "drag_select",
"press_args": {"by": "words"}
}
]
It will override the standard Ctrl+Click behaviour, and do what you want. However the default Ctrl+Click behaviour is very cool - allowing for simultaneous multiple selections and cursors (try Ctrl+Clicking in different places in a file), so you may want to reassign that functionality elsewhere. If you wanted to change the multi-select feature to Ctrl+Alt+click, you can do this by also adding, inside the square brackets:
{
"button": "button1", "count": 1, "modifiers": ["ctrl", "alt"],
"press_command": "drag_select",
"press_args": {"additive": true}
}
It Works for st3, i think works in st2
Linux - create "Default (Linux).sublime-mousemap" in ~/.config/sublime-text-3/Packages/User
Mac - create "Default (OSX).sublime-mousemap" in ~/Library/Application Support/Sublime Text 3/Packages/User
Win - create "Default (Windows).sublime-mousemap" in %appdata%\Sublime Text 3\Packages\User
[
{
"button": "button1",
"count": 1,
"modifiers": ["ctrl"],
"press_command": "drag_select",
"command": "goto_definition"
}
]

Resources