Git Product home page Git Product logo

Comments (12)

d1egoaz avatar d1egoaz commented on July 22, 2024 1

@99arobe yeah, that will work! that's a better idea actually

from vim-anywhere.

99arobe avatar 99arobe commented on July 22, 2024

I'd love this too.

from vim-anywhere.

d1egoaz avatar d1egoaz commented on July 22, 2024

I did something on my branch, not sure if it will worth it to bring it here, as it'll affect the clipboard contents. (you'll lose your current clipboard content). I haven't found an easy way to do this (I could temporarily copy the current clipboard content to a file and restore it at the end.... <- I might try this idea later)
anyways, this is what I did:

https://github.com/d1egoaz/vim-anywhere/blob/634c9d58bb9c524cf5cf7376a583c25b77207875/bin/run#L90-L92

you could see it in action on the demo gif here: https://github.com/d1egoaz/vim-anywhere/

  osascript -e 'tell application "System Events" to set the clipboard to ""'
  osascript -e 'tell application "System Events" to keystroke "c" using command down'
  pbpaste >> $TMPFILE

from vim-anywhere.

balta2ar avatar balta2ar commented on July 22, 2024

I'm interested in Linux version of this.

from vim-anywhere.

99arobe avatar 99arobe commented on July 22, 2024

@d1egoaz Thanks for this!

You mention that you thought about saving the clipboard contents to a file temporarily. Would it also be feasible in AppleScript to just store them in a variable and then copy them back to the clipboard once the selected contents have been pasted?

from vim-anywhere.

cspeterson avatar cspeterson commented on July 22, 2024

@balta2ar I was too, but realized that with all the different manners of interaction with text selections and different window managers, etc that stepping it back to just using clipboard contents was the more reasonable solution not only for Linux but across platforms

I submitted a pull request to do this:
#99

from vim-anywhere.

st-schneider avatar st-schneider commented on July 22, 2024

I did something on my branch, not sure if it will worth it to bring it here, as it'll affect the clipboard contents. (you'll lose your current clipboard content). I haven't found an easy way to do this (I could temporarily copy the current clipboard content to a file and restore it at the end.... <- I might try this idea later)
anyways, this is what I did:

d1egoaz/vim-anywhere:bin/run@634c9d5#L90-L92

you could see it in action on the demo gif here: d1egoaz/vim-anywhere

  osascript -e 'tell application "System Events" to set the clipboard to ""'
  osascript -e 'tell application "System Events" to keystroke "c" using command down'
  pbpaste >> $TMPFILE

That did the trick for me.
😨 you, you used emacs in your link 😜

from vim-anywhere.

d1egoaz avatar d1egoaz commented on July 22, 2024

😨 you, you used emacs in your link 😜

lol 😈

from vim-anywhere.

rwmitchell avatar rwmitchell commented on July 22, 2024

I had used Vim-Anywhere some time ago and then kinda forgot about it. When trying it again now, was disappointed vim was opening with an empty buffer (OS X). I made a simple change to bin/run and now get the current clipboard:

` *** bin/run.1586528512 2020-04-10 10:21:52.000000000 -0400
--- bin/run 2020-06-18 10:54:18.000000000 -0400
*************** elif [[ $OSTYPE == "arwin" ]]; then
*** 72,77 ****
--- 72,79 ----
"mvim must have been moved or uninstalled.\nPlease make sure it is"
"available in your path and then reinstall vim-anywhere."

  • pbpaste >> $TMPFILE
  • $mvim_path $VIM_OPTS $TMPFILE`

Is there a better/more clever way to do this?

[ my pasted code is getting munged, I only inserted the pbpaste line just before invoking mvim]

from vim-anywhere.

cspeterson avatar cspeterson commented on July 22, 2024

@rwmitchell

that's v close to what I did in PR #99 🙂

been a minute though, and still no movement 😞

from vim-anywhere.

rwmitchell avatar rwmitchell commented on July 22, 2024

To be clear, with my one line change, prior to using:
v to invoke vim-anywhere,

I first use c to copy the highlighted text into the paste buffer.

Every place I use this, I initially get a pop-up window asking if
I want to allow this. Sometimes 2. Safari, then iTerm2.

The other fix I saw for this required using newer/different version of
emacsclient than is found in /usr/bin

Ideally it would be great to not need to manually copy the highlighted
text into the paste buffer. Certainly there is a way to combine two
keyboard shortcuts?

from vim-anywhere.

cspeterson avatar cspeterson commented on July 22, 2024

I have no familiarity with MacOS, so I have no idea what one might do about clipboard permissions or what any of that really even means.

But if I understand you correctly at the end there, you're wondering how to automagically pull a GUI text selection?

I think that would likely be beyond the scope of vim-anywhere and I expect would not even be practically possible to do well across all the supported operating systems.

The ugly duct tape way that comes to mind though on Linux would be to wrap vim-anywhere to use xdotool or equivalent to send ctrl+c (or whatever combo will copy things) as key events before launching vim-anywhere with clipboard reading functionality. Maybe there is an xdotool-equivalentish utility on Mac?

It's an inelegant and fragile solution, and I wouldn't bother with it, but if you're really hurting for that behavior you might give something like it a go.

from vim-anywhere.

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.