Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode: how to make Ctrl+k kill till the end of line in the terminal?

In Visual Studio Code, the Ctrl-k shortcut is bound to clearing the terminal.

I've configured bash as my terminal in Windows and would like it to behave as the traditional Emacs key bindings, that is, to make it kill the end of the line.

I've tried to disable the default key binding with this configuration in the user settings, but it didn't work:

"commandsToSkipShell": [         "workbench.action.terminal.clear"       ] 

How to make the terminal obey my 20 years trained muscle memory?

like image 356
neves Avatar asked May 28 '18 14:05

neves


People also ask

How do I select till end of line VS Code?

The quickest way to get your cursor to the first or last line of the file is pressing Ctrl + Home (Mac: Control + Home ) to go the beginning and Ctrl + End (Mac: Control + End ) to go to the end.

What is Ctrl K in VS Code?

To launch the Define Keybinding widget, press Ctrl+K Ctrl+K. The widget listens for key presses and renders the serialized JSON representation in the text box and below it, the keys that VS Code has detected under your current keyboard layout.


1 Answers

If you have years of muscle memory of Unix shell and want to prevent VSCode to capture your keyboard shortcuts, turn off allowChords. In newer VSCode version you can simply open File -> Preferences -> User (tab), search for allowChords and uncheck it.

Or you can edit your %APPDATA%\Code\User\settings.json file and put this:

   "terminal.integrated.allowChords": false 

Now a lot of terminal shortcuts will just work:

  • Ctrl+K for killing till the end of the line,
  • Ctrl-Y pastes the killed line from above
  • Ctrl+R searches for your commands in your history,
  • and Ctrl+A goes to the beginning of the line

I have another answer in this thread, but I think this is a better solution. Here is the documentation.

See other answers if you want to fix just the Ctrl-K behavior.

like image 81
neves Avatar answered Oct 20 '22 13:10

neves