-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Method to suppress the default CTRL+C/CTRL+V mapping specifically for WSL; profile-specific keybindings? #5790
Comments
This issue is somewhat related to: #5641 |
Maybe what we need is profile-specific keybindings. I'm surprised we don't have a workitem for that. |
@DHowett-MSFT This was actually what I had considered as the most obvious solution to this issue, but simply wanted to leave it up to the developers to choose whatever path they were the most comfortable with. Thanks! |
For the vim Ctrl+V use case, would it be possible to do something similar to what we do for Ctrl+C? Proposed BehaviorCtrl+C:
Ctrl+V:
Possible WorkaroundIs there any way to remap the behavior of Ctrl+V in my |
is it possible for terminal to detect if vim is running/current vim mode? |
Not generally, no. We would only be able to detect instances of |
I ended up remapping paste to V because I don't use normal visual mode. Place the following in your nnoremap v <c-v> Replace |
I have found that making use of the Vim Example workaround for Ctrl+v issue within Vim by utilizing the
Hopefully, profile-specific keybindings or some other solution to this issue will be implemented soon. |
My experience:
Asks:
|
I'm confused about this. Terminal doesn't insert key bindings into your settings -- once your settings file is created (at first launch), we aren't going to add new key bindings. |
From settings.json:
I deleted the lines following this, so I don't have reference to them. But they bound copy and paste to ctrl-c and ctrl-v. Prior to clicking Settings, ctrl-v did not paste. Vim visual mode worked. After the first time I clicked "Settings" from the menu (down chevron), ctrl-v then became paste, vim visual mode broke. I did not understand what happened. I came across a comment in another issue that I can't seem to find that said this was intentional as a compromise. I'll try to find it. Maybe I encountered a bug or terminal upgraded in some way to change settings from one day to the next (maybe I got a new build automatically, I have no idea). Edit: here is the thread #5641 (comment)
Clearly its a sore subject for people working on the project. All the settings are there, and I was able to fix it after I actually figured out what happened - great! The user experience part was weird and did not make sense, and sounds like it wasn't intended? |
Wow, that's definitely not supposed to happen. The user settings template is only supposed to be stomped down on disk if your settings file is nonexistent or empty. Did you lose any other settings? We've gotten a couple sporadic reports of settings being nuked on save (!), but we've never had enough to go on. If I had to do some psychic debugging, I might guess that an editor locks the file very briefly when opening, and creates a swap/temp file. The creation of that file forces Terminal to re-scan the directory and when it fails to open the file (we should audit our sharing mode!) it declares all is lost and recreates it? Complete guess, but it could explain settings disappearing when you open them in an editor. Which editor are you using? |
I hadn't ever opened it before, so I was stock settings. vscode was the editor. Probably a more mundane explanation. It sounds like I had a misunderstanding about the defaults. If ctrl-v defaults to paste now, I guess there is a non-zero chance that I just hadn't used ctrl-v in vim+microsoft terminal since it changed. I switch back and forth between vscode/vim mac/windows/linux frequently and I was on the insider's build early on. Sorry about that, disregard. |
how do I disable ctrl+c and ctrl+v all together? I commented them out in settings.json, but now they just don't work at all; well that's not true, they fail in the keyboard handler and prevent further keyboard input for 1.5 seconds (1?). |
@d3x0r What the heck - that's very unexpected. If they're not in your |
I will dig into it; I suspect it's maybe that they were set and are no longer set also... |
I added the following to my keybindings and vertical selection worked fine again:
I didn't have this keybinding in my Windows Terminal settings back in June, so I guess something changed in between that time (or maybe I just never update my software). I think the larger issue is this functionality is almost now undocumented, detailed in the following issue MicrosoftDocs/terminal#211. Who knows what else is now undocumented? |
{
"command": "unbound",
"keys": "ctrl+c"
},
{
"command": "unbound",
"keys": "ctrl+v"
}, seems to work - but I haven't been using terminal because lack of mouse input (I use FAR Manager as a shell on top of the command shell) |
For everyone that still has trouble with unbinding CTRL+V globally in windows-terminal: Put this into your {
"command": "unbound",
"keys": "ctrl+v"
} This will unbind CTRL+V for the terminal itself BUT it still works in powershell. This is because PSReadLine is handling the keyboard shortcut. So if you have this problem you need to remove the binding for it: Remove-PSReadLineKeyHandler -Chord "ctrl+v"
Remove-PSReadLineKeyHandler -Chord "ctrl+v" -ViMode Command |
Hi. Sorry if it's not the correct place! |
@Tomicapo You're more than welcome to add
to your actions to enable pasting on shift+insert |
Again hit by this, I would argue that for WSL profiles, the default should disable Ctrl+V as Vim is very popular.... |
This comment was marked as spam.
This comment was marked as spam.
its not just WSL, I have a text mode app that wants to receive the ctrl-v key stroke. It has its own idea for what that means |
shouldnt it be that if ENABLE_PROCESSED_INPUT is off then ctrl-v should be ignored? Or could we have another mode bit for paste (ENABLE_PASTE) |
Actually, if there was a simple method to My use-case: I use "micro" editor via ssh. And copy-pasting in it is a huge pain in Windows terminal, because it intercepts my input. PS. disabling the default "Ctrl+V" helps, but offering the above option would still be nice |
Using Windows Terminal to run a Cygwin bash shell runs into this problem, the default 'lnext' (literal next character) tty setting is Ctrl-V, which lets you e.g. put control characters into regexps you're typing instead of backslash escapes. |
This specs out a lot of plans for snippets. We've already got these in the sxnui as "tasks", but we can do so very much more. This spec is a few years old now, but it's time for it to get promoted out of my draft branch. References: * #1595 * #7039 * #3121 * #10436 * #12927 * #12857 * #5790 * #15845 --------- Co-authored-by: Dustin L. Howett <[email protected]>
#5790 (comment)
inoremap <C-v> <C-r>+ This will allow to paste copied text in insert mode while keeping its default behavior in normal mode. |
Editor's Note (@DHowett-MSFT): This may be a good place to track profile-specific keybindings?
With the classic Windows terminal, Ctrl+c and Ctrl+v can be used for copy and paste when working within a Windows shell just as I would expect/prefer. However, when using WSL, this is typically not the case and those keys are available for use by Linux applications such as Vim.
How can I replicate this same behavior with the new Windows Terminal?
Background:
When working specifically within the WSL environment, Vim is my primary editor and the presence of any Ctrl+v mapping effectively blocks the use of blockwise Visual mode (http://vimdoc.sourceforge.net/htmldoc/visual.html#CTRL-V).
Removal of these mappings in a global scope is undesirable since I do not want to lose the use of Ctrl+c and Ctrl+v for copy and paste when working within a Windows shell.
I realize that similar issues have been discussed at length and that any choice here is somewhat of a compromise, but the ability to replicate the current behavior of the classic Windows terminal in this regard is a tradeoff that I find acceptable/desirable.
The text was updated successfully, but these errors were encountered: