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

Add copy-from/paste-back functionality #31

Open
cknadler opened this issue Jan 9, 2014 · 11 comments
Open

Add copy-from/paste-back functionality #31

cknadler opened this issue Jan 9, 2014 · 11 comments

Comments

@cknadler
Copy link
Owner

cknadler commented Jan 9, 2014

This is a pretty commonly requested feature.

When vim-anywhere is invoked:

  • copy all of the text from whatever is currently selected
  • open a vim buffer containing the copied text
  • once closed, paste the text back into the previous application, replacing whatever text was originally copied

This should be implemented as an alternate keybinding. Something like ctrl+cmd+c (OSX) or ctrl+alt+c (Linux). The current functionality of ctrl+cmd+v shouldn't change at all.

@lavignes
Copy link
Contributor

lavignes commented Jan 9, 2014

As far as the Linux install is concerned we'll have to add xdotool as a dependency. Though I might just use the xclipboard buffer. By default in X any selected text is already in the xclipboard buffer.

The flow will be like so:

  • get window ID with xdotool
  • take the xclipboard buffer with xclip and put into a new vim buffer
  • on quit: refocus window with xdotool
  • xdotool type "file contents"

That's the the best way I know in Linux.

@cknadler
Copy link
Owner Author

cknadler commented Jan 9, 2014

Is xdotool a requirement for invoking keystrokes via the command line?

@lavignes
Copy link
Contributor

lavignes commented Jan 9, 2014

It can simulate any input from the command line. It could also simulate a ctrl+v but that isn't as universal as just simulating typing the entire buffer. There could be some issues. But it needs to be implemented to know for sure.

@cknadler
Copy link
Owner Author

cknadler commented Jan 9, 2014

Neat. Good to know. I'm less inclined to try to support this now that I know it will require external dependencies. Surprisingly, on OSX, it's all possible through AppleScript.

@Hettomei
Copy link

I think that "automatically past buffer in primary app at the end" is a bad idea, why ?

Here is my workflow for wich it fail :

  • starting a comment on a website
  • tell me "hum, it will be too long, switch to vim"
  • having all buffer populated with primary app
  • go throught the internet to improve my comment <-- here is the problem
  • forget to go back to the last selected text <-- and here
  • quit vim
  • lot of text pasted somewhere but not in previous area

That's why I prefere having to type cmd-v at the end.

@cknadler
Copy link
Owner Author

@Hettomei

We would be implementing it under a separate keybinding. The default behavior wouldn't change. I'm with you, I prefer to manually type cmd-v.

@simonweil
Copy link

👍

@Govan
Copy link

Govan commented Feb 27, 2014

I've presently got a rough and ready version of copy-text-from-current-app-into-buffer working for OSX. Do you have any issues with taking pull requests that only work on one platform?

@cknadler
Copy link
Owner Author

@Govan Sorry about the crazy late response.

I'd rather keep the feature set consistent across both platforms. That said, if you have something working on OSX, I bet we can figure it out and port it to Linux. Feel free to post a PR and we'll follow up. ^_^

@anrddh
Copy link

anrddh commented Feb 5, 2017

Has any progress been made with this feature? I would love to contribute but I have no experience with AppleScript :(

@vitaly-zdanevich
Copy link

It is possible to achieve this with a simple companion browser extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants