Coder Social home page Coder Social logo

Comments (12)

aioutecism avatar aioutecism commented on July 30, 2024 1

Answered #166 (comment)

from amvim-for-vscode.

aioutecism avatar aioutecism commented on July 30, 2024

VSCode's API only allows copy selections to system clipboard now.
I can let y to make a selection then copy to clipboard, but this will make selections "blink".

Instead, I'd recommend you create a custom map to call the built-in copy command.
This can be done by:

  1. Open command palette.
  2. Search for Preferences: Open Keyboard Shortcuts.
  3. Create a new map with your favorite key and command editor.action.clipboardCopyAction.

from amvim-for-vscode.

lf94 avatar lf94 commented on July 30, 2024

Is the selections blinking just a UI effect? Maybe we can get the VSCode guys to add a user setting to turn it off?

from amvim-for-vscode.

aioutecism avatar aioutecism commented on July 30, 2024

Instead of turn the effect off, it would be better if they let extensions access system clipboard.

from amvim-for-vscode.

 avatar commented on July 30, 2024

Vim uses the + register to do this. "+y and "+p to copy and paste.

If we support that, we'll need to have some notion of registers, which doesn't exist right now.

from amvim-for-vscode.

jcrben avatar jcrben commented on July 30, 2024

Cross-referencing another clipboard issue: #166

from amvim-for-vscode.

karlhorky avatar karlhorky commented on July 30, 2024

it would be better if they let extensions access system clipboard

I guess VS Code has this ability, since VSCodeVim has this option to use the system clipboard...

Not sure exactly where it is in the codebase, but there are a few references that appear with a search:

https://github.com/VSCodeVim/Vim/search?q=system+clipboard&unscoped_q=system+clipboard

from amvim-for-vscode.

karlhorky avatar karlhorky commented on July 30, 2024

So I've found some keybindings that seem to work here! 🥳

  // Yank (copy) to system clipboard in VISUAL and VISUAL_LINE modes
  {
    "key": "y",
    "command": "editor.action.clipboardCopyAction",
    "when": "editorTextFocus && amVim.mode == 'VISUAL' && !inDebugRepl &&!suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
  },
  {
    "key": "y",
    "command": "editor.action.clipboardCopyAction",
    "when": "editorTextFocus && amVim.mode == 'VISUAL LINE' && !inDebugRepl &&!suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
  },
  {
    "key": "y y",
    "command": "editor.action.clipboardCopyAction",
    "when": "editorTextFocus && amVim.mode == 'NORMAL' && !inDebugRepl &&!suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
  },
  // Delete (cut) to system clipboard in VISUAL modes
  {
    "key": "d",
    "command": "editor.action.clipboardCopyAction",
    "when": "editorTextFocus && amVim.mode == 'VISUAL' && !inDebugRepl &&!suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
  },

Caveats

  • The active selection from the VISUAL modes stays with the yank keybindings

I'm also uncertain why I don't need to match for VISUAL LINE mode with the d keybinding - it just works in both modes. Maybe more mode bugginess?


There is one more binding that I originally wrote to paste from system clipboard in NORMAL mode, but it pastes even in INSERT mode 😳 (I guess there's some issue with the modes):

  // Paste from system clipboard only in NORMAL mode (not working - pastes also in INSERT mode)
  {
    "key": "p",
    "command": "editor.action.clipboardPasteAction",
    "when": "editorTextFocus && amVim.mode == 'NORMAL' && !inDebugRepl &&!suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
  },

@aioutecism can you comment on why the mode check is not working here? I tried looking through the code, but I'm really lost there...

from amvim-for-vscode.

karlhorky avatar karlhorky commented on July 30, 2024

I can let y to make a selection then copy to clipboard, but this will make selections "blink".

@aioutecism Also - would you consider adding this and an option for turning on this mode? I think there must be also a way to do it without the blinking (VSCodeVim achieves this somehow), but even with the blinking, it would be better than no copy to system clipboard (and also better than my hotkeys workaround).

from amvim-for-vscode.

karlhorky avatar karlhorky commented on July 30, 2024

Asked in #166 (#166 (comment)) about having some instructions about how to add this feature (as well as paste from system clipboard):

#166 (comment)

from amvim-for-vscode.

karlhorky avatar karlhorky commented on July 30, 2024

My first shot at a pull request up at #260.

from amvim-for-vscode.

karlhorky avatar karlhorky commented on July 30, 2024

Done in master (#260 was merged)! Will be released soon.

#272 contains documentation of the option.

from amvim-for-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.