Skip to content
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

Use ssh to connecting Linux, mapped shortcut keys in "mswin.vim" to operate the clipboard is not working. #13809

Closed
znsoooo opened this issue Jan 3, 2024 · 14 comments
Labels

Comments

@znsoooo
Copy link
Contributor

znsoooo commented Jan 3, 2024

Steps to reproduce

  1. Use Moba software to connect to Linux development board by ssh.
  2. Open vim and enter ":source $VIMRUNTIME/mswin.vim"
  3. I can't use the Ctrl-C / Ctrl-X / Ctrl-V hotkeys for clipboard operation. But the Ctrl-Z and Ctrl-Y hotkeys is working.

Expected behaviour

Use the Ctrl-C / Ctrl-X / Ctrl-V shortcut keys for clipboard operation while I'am using "mswin.vim" script.

Version of Vim

9.1.0

Environment

Ubuntu 18.04.6 LTS

Logs and stack traces

No response

@znsoooo znsoooo added the bug label Jan 3, 2024
@znsoooo
Copy link
Contributor Author

znsoooo commented Jan 3, 2024

And I an already fixed this bug: 1d9f46b

Can I pull request into master?

@znsoooo znsoooo changed the title Use ssh to connecting Linux, mapped shortcut keys to operate the clipboard is not working. Use ssh to connecting Linux, mapped shortcut keys in "mswin.vim" to operate the clipboard is not working. Jan 3, 2024
@chrisbra
Copy link
Member

chrisbra commented Jan 3, 2024

You can create a pull request, but using the unnamed register is something very different then using the (system) wide clipboard.

@znsoooo
Copy link
Contributor Author

znsoooo commented Jan 3, 2024

You can create a pull request, but using the unnamed register is something very different then using the (system) wide clipboard.

Yes, so it only takes effect when the system clipboard is not available.

clason added a commit to clason/neovim that referenced this issue Mar 4, 2024
runtime(mswin): Use unnamed register when clipboard not working (vim/vim#13813)

* Use unnamed register while clipboard not exist
* Do not need to specify the unnamed register explicitly
fixes: vim/vim#13809

vim/vim@d9ebd46

Co-authored-by: Shixian Li <34830785+znsoooo@users.noreply.github.com>
clason added a commit to neovim/neovim that referenced this issue Mar 4, 2024
runtime(mswin): Use unnamed register when clipboard not working (vim/vim#13813)

* Use unnamed register while clipboard not exist
* Do not need to specify the unnamed register explicitly
fixes: vim/vim#13809

vim/vim@d9ebd46

Co-authored-by: Shixian Li <34830785+znsoooo@users.noreply.github.com>
@ciupicri
Copy link

ciupicri commented Mar 12, 2024

@clason the patch breaks gvim (vim-X11-9.1.158-1.fc39.x86_64) when running under X11 (XFCE) on Fedora Linux. The keyboard shortcuts don't work anymore.

@chrisbra
Copy link
Member

what exactly does not work?

@ciupicri
Copy link

For example if I select some text in gvim and press Control+C , then Control+V in say Firefox the old content of the clipboard gets pasted. This means that the copy operation didn't put something new into the clipboard, i.e. it doesn't work.

On the other hand, select, right click → Copy works fine.


$ cat ~/.vim/vimrc
source $VIMRUNTIME/mswin.vim

@chrisbra
Copy link
Member

Please give more information.
So you are visual selecting anything and press <c-c>? What does :vnoremap <c-c> give you? What about :echo has("clipboard_working")?

If you change line 27 from:

if has("clipboard_working")

to

if has("clipboard")

Does it start working?

@ciupicri
Copy link

So you are visual selecting anything and press <c-c>?

Yes. Either with the mouse or the keyboard by pressing Shift.

What does :vnoremap <c-c> give you?

v  <C-C>       * y

What about :echo has("clipboard_working")?

1

If you change line 27 […] does it start working?

Yes.

--- /usr/share/vim/vim91/mswin.vim	2024-03-08 02:00:00.000000000 +0200
+++ mswin.vim	2024-03-13 15:56:52.316998206 +0200
@@ -24,7 +24,7 @@
 " backspace in Visual mode deletes selection
 vnoremap <BS> d
 
-if has("clipboard_working")
+if has("clipboard")
     " CTRL-X and SHIFT-Del are Cut
     vnoremap <C-X> "+x
     vnoremap <S-Del> "+x

@ciupicri
Copy link

P.S. Pressing Control+V outputs ^ and then vim waits for another key press.

The Paste from the right click menu works fine.

@chrisbra
Copy link
Member

v * y

Wait what? Where does that come from? Do you have this in your runtime file? Please show the output of :verbose :vmap <c-c>

:echo has("clipboard_working")
1

Hm, perhaps clipboard is not yet working when sourcing mswin.vim ? Maybe this should be defered until the gui has started up?

P.S. Pressing Control+V outputs ^ and then vim waits for another key press.

That is expected. See :h i_CTRL_V (this also works similar in other modes).

@ciupicri
Copy link

Please show the output of :verbose :vmap <c-c>

Seen modifyOtherKeys: true
x  gx            <Plug>NetrwBrowseXVis
        Last set from /usr/share/vim/vim91/plugin/netrwPlugin.vim line 89
x  <Plug>NetrwBrowseXVis * :<C-U>call netrw#BrowseXVis()<CR>
        Last set from /usr/share/vim/vim91/plugin/netrwPlugin.vim line 91
   <C-F>       * has("gui_running") ? ":promptfind\<CR>" : "/"
        Last set from ~/.vim/mswin.vim line 127
nv <C-F4>      * <C-W>c
        Last set from ~/.vim/mswin.vim line 120
nv <C-Tab>     * <C-W>w
        Last set from ~/.vim/mswin.vim line 114
x  <C-A>       * <C-C>ggVG
        Last set from ~/.vim/mswin.vim line 111
s  <C-A>       * <C-C>gggH<C-O>G
        Last set from ~/.vim/mswin.vim line 110
   <M-Space>   * :simalt ~<CR>
        Last set from ~/.vim/mswin.vim line 100
   <C-Y>       * <C-R>
        Last set from ~/.vim/mswin.vim line 95
   <C-Z>       * u
        Last set from ~/.vim/mswin.vim line 91
v  <C-S>       * <C-C>:update<CR>
        Last set from ~/.vim/mswin.vim line 81
   <C-Q>       * <C-V>
        Last set from ~/.vim/mswin.vim line 76
v  <S-Insert>    <C-V>
        Last set from ~/.vim/mswin.vim line 73
   <C-V>         "+gP
        Last set from ~/.vim/mswin.vim line 37
v  <C-Insert>  * "+y
        Last set from ~/.vim/mswin.vim line 34
v  <C-C>       * "+y
        Last set from ~/.vim/mswin.vim line 33
v  <S-Del>     * "+x
        Last set from ~/.vim/mswin.vim line 30
v  <C-X>       * "+x
        Last set from ~/.vim/mswin.vim line 29
v  <BS>        * d
        Last set from ~/.vim/mswin.vim line 25

Control+V used to work as on Windows (Notepad).

@chrisbra
Copy link
Member

Ah, so this must be your patched/working version.

@ciupicri
Copy link

Yeah, with the patch proposed by you.

chrisbra added a commit that referenced this issue Mar 13, 2024
Commit d9ebd46 changed the condition to
check if the clipboard is available from:
```
has('clipboard')
```
to
```
has('clipboard_working')
```
Assuming that is the more accurate test because even when clipboard
support is enabled at compile time it may not be actually working (e.g.
if no X11 environment is available, or when working on a remote server).

However it seems that condition does not evaluate to true, when the GUI
has not been started up yet (and there was no X11 Connection yet possible).

So let's just revert back the check to `has('clipboard')`, since that
has been proven to be working well enough.

related: #13809

Signed-off-by: Christian Brabandt <cb@256bit.org>
@chrisbra
Copy link
Member

I reverted back the check. Please next time create a new issue

zeertzjq added a commit to zeertzjq/neovim that referenced this issue Mar 14, 2024
runtime(mswin): revert back the check for clipboard_working support

Commit d9ebd46bd090c598adc82e6 changed the condition to
check if the clipboard is available from:
```
has('clipboard')
```
to
```
has('clipboard_working')
```
Assuming that is the more accurate test because even when clipboard
support is enabled at compile time it may not be actually working (e.g.
if no X11 environment is available, or when working on a remote server).

However it seems that condition does not evaluate to true, when the GUI
has not been started up yet (and there was no X11 Connection yet possible).

So let's just revert back the check to `has('clipboard')`, since that
has been proven to be working well enough.

related: vim/vim#13809

vim/vim@760f664

Co-authored-by: Christian Brabandt <cb@256bit.org>
zeertzjq added a commit to zeertzjq/neovim that referenced this issue Mar 14, 2024
runtime(mswin): revert back the check for clipboard_working support

Commit d9ebd46bd090c598adc82e6 changed the condition to
check if the clipboard is available from:
```
has('clipboard')
```
to
```
has('clipboard_working')
```
Assuming that is the more accurate test because even when clipboard
support is enabled at compile time it may not be actually working (e.g.
if no X11 environment is available, or when working on a remote server).

However it seems that condition does not evaluate to true, when the GUI
has not been started up yet (and there was no X11 Connection yet possible).

So let's just revert back the check to `has('clipboard')`, since that
has been proven to be working well enough.

related: vim/vim#13809

vim/vim@760f664

Co-authored-by: Christian Brabandt <cb@256bit.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants