Git Product home page Git Product logo

vim-anywhere's Introduction

vim-anywhere

Sometimes, you edit text outside of Vim. These are sad times. Enter vim-anywhere!

demo

Once invoked, vim-anywhere will open a buffer. Close it and its contents are copied to your clipboard and your previous application is refocused.

Installation

Requirements

OSX:

  • MacVim (brew install --cask macvim)

Linux:

  • Gnome (or a derivative)
  • gVim

Install

curl -fsSL https://raw.github.com/cknadler/vim-anywhere/master/install | bash

Update

~/.vim-anywhere/update

Uninstall

~/.vim-anywhere/uninstall

Keybinding

OSX: ( default = ctrl+cmd+v )

You can adjust the shortcut via system preferences.

System Preferences > Keyboard > Shortcuts > Services > Vim Anywhere

Linux: ( default = ctrl+alt+v )

Gnome

$ gconftool -t str --set /desktop/gnome/keybindings/vim-anywhere/binding <custom binding>

I3WM

$ echo 'bindsym $mod+Alt+v exec ~/.vim-anywhere/bin/run' >> ~/.i3/config # remember to reload your config after

Adjust in case $mod is not set to ctrl.

History

vim-anywhere creates a temporary file in /tmp/vim-anywhere when invoked. These files stick around until you restart your system, giving you a temporary history.

View your history:

$ ls /tmp/vim-anywhere

Reopen your most recent file:

$ vim $( ls /tmp/vim-anywhere | sort -r | head -n 1 )

Why?

I use Vim for almost everything. I wish I didn't have to say almost. My usual workflow is to open Vim, write, copy the text out of my current buffer and paste it into whatever application I was just using. vim-anywhere attempts to automate this process as much as possible, reducing the friction of using Vim to do more than just edit code.

Bugs

First, make sure to read the FAQ. If you don't find the answer you're looking for there, feel free to open an issue.

Pull requests, suggestions and issues of any kind are welcome. Make sure to check out the contribution guidelines before you submit a pull request.

License

MIT.

vim-anywhere's People

Contributors

cknadler avatar dmd avatar edthedev avatar exhuma avatar jtheoof avatar jwilk avatar lavignes avatar maxpblum avatar mlr avatar mmai avatar raybb avatar rozzy avatar ryanguest avatar soli avatar vitalk avatar wilmoore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-anywhere's Issues

Add debug flags

All scripts should accept a debug flag such as:

--debug

to pipe all output to stdout for debugging purposes.

Related: #9

Does not work on kubuntu 13.10

First, the install script gave me a bunch of errors. Here's the transcript:

$ curl -fsSL https://raw.github.com/cknadler/vim-anywhere/master/install | sh
sh: 22: [: -a: unexpected operator
sh: 30: [[: not found
sh: 53: [[: not found
Installing vim-anywhere...
Cloning into '/home/michel/.vim-anywhere'...
remote: Counting objects: 165, done.
remote: Compressing objects: 100% (93/93), done.
remote: Total 165 (delta 87), reused 138 (delta 60)
Receiving objects: 100% (165/165), 242.88 KiB | 0 bytes/s, done.
Resolving deltas: 100% (87/87), done.
Checking connectivity... done
sh: 84: [[: not found
sh: 91: [[: not found
vim-anywhere has been successfully installed!

After running that, it was installed, but running it first gave me this error:

./.vim-anywhere/bin/run
chmod: cannot access ‘/tmp/vim-anywhere/doc-131230173218’: No such file or directory
./.vim-anywhere/bin/run: line 16: xclip: command not found

So I installed xclip and was left with this:

./.vim-anywhere/bin/run
chmod: cannot access ‘/tmp/vim-anywhere/doc-131230173243’: No such file or directory

I tested it later using bash:

$ curl -fsSL https://raw.github.com/cknadler/vim-anywhere/master/install | bash
Cleaning up previous installation...
vim-anywhere requires gconftool to function.

Now it's gone? :'(

On a side-note: this was written in vim :) I use it to edit about anything...

cyrillic problem

Hello!
When i use cyrillic and then paste it, i have a problem.
For example, i write:
Привет, test
And then paste:
–ü—Ä–∏–≤–µ—Ç, test

Not working with ubuntu 12.10

Hi,

I tried using vim-anywhere but I haven't been successful so far. How do I debug ?
If I try to run ~/.vim-anywhere/bin/run manually I am presented with an error 👍 'chmod: cannot access `/tmp/vim-anywhere/doc-131231154454': No such file or directory', however gvim does open.

Add copy-from/paste-back functionality

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.

Can't use in Mail

When I try to use vim-anywhere in the Mail app on OS X 10.11 El Capitan, I get an error dialog saying

"The action “Run Shell Script” encountered an error."

Let me know if you need more information.

Am I missing something, but what's the point?

Sorry, I probably miss something very obvious but anyway:

  1. vim-anywhere doesn't get the "original" text from the source input (like quoted email), you have to do this manually (like copying there and pasting in vim;
  2. it also doesn't pastes the resulting text, just copies it to clipboard, and once again, you have to paste it manually.

So, that's the point then? :) Sure, I can assign a system-wide hotkey to open a new Vim buffer, paste there anything I want, edit, copy to clipboard, and paste the anywhere I want. vim-anywhere seems to save me just one keypress, am I wrong?

Is it possible to populate buffer with text already in primary app ? (enhancement)

Hi,

Thank you a lot for this little app :)

Is it possible, just before opening Vim to do a "select all, copy, then paste in buffer" all contents present in the field of "primary apps" ?

For example, I start what I think it will be a simple comment on a website.
After 5 lines I realize that I will be more confortable on Vim.
I want all this previous text to be in Vim.

Good bye.

Add support for dconf in Gnome 3

gconf has been deprecated in Gnome 3.

So basic install on Gnome 3.10 results in:

▸ curl -fsSL https://raw.github.com/cknadler/vim-anywhere/master/install | bash
vim-anywhere requires gconftool to function

It would be nice to add support for dconf, I'll see if I can make a patch.

Keybinding in i3wm

In case there's any interest in including documentation for configuring the key binding in other window managers, here's how to set up the key-binding in i3wm.

Add the following line to ~/.i3/config:

bindsym $mod+Alt+v exec ~/.vim-anywhere/bin/run

Remember to reload i3wm, for the new configuration to take effect. This is bound to $mod+shift+r, by default.

If interested in including this information, feel free to assign this ticket to me, and I can submit a patch to the README.

Better GIF and Pictures

The GIF and pictures could use a bit of a high res update. If anyone is interested in re-creating them but at a higher resolution, I'd happily accept a pull request.

Add guides for systems where automatic install isn't possible

If an operating system is supported by the installer, the install script must:

  • use only software that ships with the OS
  • completely install vim-anywhere and set the default keyboard shortcuts

There are several operating systems where it seems like this isn't really possible. So far, these are:

  • KDE
  • Windows

There should be a link from the README to documents describing how to get vim-anywhere working on operating systems not supported by the installer.

Umlaut problems

The copy-paste process b0rks Umlauts.

When I use vim-anywhere to write some text (see this short screencast) the umlauts are not returning correctly from the buffer.
On pasting I get √§ for ä, √∂ for ö and √º for ü.
In the corresponding file in /tmp/vim-anywhere the characters are saved correctly...

OS X "10.10.2 (14C109)", MacVim "Custom Version 7.4 (73)" installed via brew install macvim and vim-anywhere installed immediately after reading about it on one thing well.

Text not getting to the clipboard in Ubuntu Gnome 14.04

Just installed and updated in Ubuntu Gnome 14.04, I have gvim installed and am running the clipboard manager Parcellite.

When writing in vim-anywhere everything works well. When I write and exit the /tmp/vim-anywhere directory is updated but the text is not seen on the clipboard and is not available for pasting.

When using vim-anywhere in the past (with Ubuntu 13.10 and KDE) it worked well with Parcellite. Now I can't seem to get the text from vim-anywhere onto the clipboard. Any thoughts?

Not Working With Ubuntu 12.04

Just installed it but doesn't seem to be working with Ubuntu 12.04. The shortcut works and the window pops open. I write something, run ":wq" but my text does not get copied over.

Newline not being copied/pasted properly in some windows

If I were to type in vim-anywhere:

"First
Second
Third"

This will copy/paste correctly on the command line as 3 different commands, it copy/paste fine in this issue box as well as 3 lines. But it did not work in gmail when writing email, which is showed up all on the same line. So I'm not sure if this is an issue with vim-anywhere or maybe how different text boxes handle newline characters.

Breaks Ubuntu 17.10

As soon as the install script is executed my current session crashes and when I try to login it crashes again. I have a pretty much fresh install of Ubuntu 17.10 so hopefully it's not just some weird setup of mine that produced the error.

Here is a relevant excerpt from /var/log/syslog:

Nov 14 23:20:49 coffee gnome-session[6082]: gnome-session-binary[6082]: WARNING: App 'org.gnome.SettingsDaemon.MediaKeys.desktop' respawning too quickly
Nov 14 23:20:49 coffee gnome-session-binary[6082]: WARNING: App 'org.gnome.SettingsDaemon.MediaKeys.desktop' respawning too quickly
Nov 14 23:20:49 coffee gnome-session-binary[6082]: Unrecoverable failure in required component org.gnome.SettingsDaemon.MediaKeys.desktop
Nov 14 23:20:49 coffee gnome-session[6082]: gnome-session-binary[6082]: CRITICAL: We failed, but the fail whale is dead. Sorry....
Nov 14 23:20:49 coffee gnome-session-binary[6082]: CRITICAL: We failed, but the fail whale is dead. Sorry....
Nov 14 23:20:49 coffee org.a11y.atspi.Registry[1301]: XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
Nov 14 23:20:49 coffee org.a11y.atspi.Registry[1301]:       after 21 requests (21 known processed) with 0 events remaining.
Nov 14 23:20:49 coffee kernel: [ 2291.925365] rfkill: input handler enabled
Nov 14 23:20:49 coffee gdm3: GdmDisplay: display lasted 2.453852 seconds
Nov 14 23:20:49 coffee nautilus[6292]: Error reading events from display: Broken pipe
Nov 14 23:20:49 coffee org.gnome.Shell.desktop[6113]: could not connect to wayland server
Nov 14 23:20:49 coffee org.gnome.Shell.desktop[6113]: (EE)
Nov 14 23:20:49 coffee org.gnome.Shell.desktop[6113]: Fatal server error:
Nov 14 23:20:49 coffee org.gnome.Shell.desktop[6113]: (EE) Couldn't add screen
Nov 14 23:20:49 coffee org.gnome.Shell.desktop[6113]: (EE)

The install script changes this MediaKeys variable:

    media_keys=org.gnome.settings-daemon.plugins.media-keys
    custom_kbd=org.gnome.settings-daemon.plugins.media-keys.custom-keybindings
    kbd_path=/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/vim-anywhere
    gsettings set $media_keys custom-keybindings "['others', '$kbd_path']"
    gsettings set $custom_kbd:$kbd_path name $name
    gsettings set $custom_kbd:$kbd_path binding $binding
    gsettings set $custom_kbd:$kbd_path command $action

I fixed my issue with the following:

media_keys=org.gnome.settings-daemon.plugins.media-keys
gsettings reset $media_keys custom-keybindings

So I was unable to test out vim-anywhere. I would love to try again at some point, it looks great! 😄
I would love to know if the bug is reproducible by others.

Wishlist: Windows/Cygwin port.

Hi, great work! However, it is Windows that needs VIM integration the most. After all, Windows doesn't even COME with a decent editor or shell. It would be neat to have Vim-Anywhere work with the Mobaxterm/Cygwin package, which by extension, includes vim. Anyway, that is how I endure the corporate Win7 "development" laptop at my day job.

Looks like the trickest part of doing this in Windows will be setting up the keybinding. Likely it will be a manual step similar to how you have to set it up in the Apple system settings. Perhaps a Windows installer would create a desktop icon with a "Shortcut Key" defined, and then that would launch the bin/run file (or a *.bat equivalent if we want to avoid the Cygwin dependency) to get things going. Just some ideas, I'll look around!

add abilty to keep your previous cliboard

Hi,

great work on this app :)

I had an idea, wouldn't it be great if vim-anywhere copied the clipboard of the user just before overwriting it with the text entered in vim. So that after a 10 second configurable timeout starting when the vim file is closed the clipboard could be re copied from its backup.

I hope I'm clear. What do you think ?

PS : I'm guessing you'll have to pay attention to the behavior when multiple vim-anywhere session are open at the same time, and if one is reopen before the end of the timeout. :)

How to change a file name and use :Gist

I used to :sav ~/path/to/filename.rb and then :Gist to upload it to githubgist. But it does not change the file name and used doc-140503064838.

Is there anyway I can change the file name?

Thanks in advance.

Why?

Sorry if i bother you guys but i have some questions.

  • Why anyone would want to use a 30-ish year old, console based editor when filling an online form?
  • Do you guys feel uncomfortable when anyone talks about new technologies or IDEs around you?
  • Do you also live out-of-technology in your "normal" lives?

Thanks

It does not paste back to the web browser

Am I right to expect that when you have completed editing text and put :wq to quit the macvim, then in the web page editor I can see the pasted back text?? I am not seeing anything after I issued :wq to quit editing.

How to fix the issue?

Stephen

Any reason to don't set filetype to some value?

Any way to set default filetype for new files? For example, I mostly use
vim-anywhere to write in markdown and need to set ft=markdown any time
a new Vim window opened.

For now I use the custom autocommand in my .vimrc to force set filetype for
vim-anywhere files:

augroup ft_vim_anywhere
  au!
  au BufNewFile,BufRead **/vim-anywhere/doc-** setl ft=markdown
augroup END

Why not set filetype to text or markdown by default?

Content of text fields for editing are not loaded into vim

For example, if I wanted to edit this issue with vim, I would use the shortcut I set up and I expect this text to be present in editor when it starts; however, it is not, the buffer is empty.

Not to be a complainer (I love the idea of this), I realize this will be difficult to make work for all input fields. Various system's accessibility apis expose this information, so maybe something could be done with that?

I do realize that a trivial workaround is to to select the entire text field, copy, activate vim anywhere, and paste, but this is many steps, and context–such as cursor position–is lost.

  1. Be in app, see something that needs editting
  2. ctrl+a
  3. ctrl+c
  4. ctrl+alt+v
  5. p
  6. find thing that needs editting again
  7. place cursor

versus

  1. Be in app, see something that needs editing
  2. place cursor
  3. ctrl+alt+v

Potentially, the same accessibility apis may allow the original text field to be populated simultaneously with the vim buffer (I recall a browser plugin+editor plugin that required this sort of information exchange to update css live as it was editted in vim or sublime).

Clarification if Vimperator has the same feature you offer

Hi Chris,

thanks for taking your time to enhance Vim's ecosystem with such a useful plugin. What nags my mind is that such a feature already exist in vimperator and I can not figure out the difference.

Pressing <C-i> in any input field will invoke GVim where you can edit the text and by closing it, it will automatically insert the text in the field.

Does your plugin does something more than that? If yes, it isn't clear, maybe just add the link to Vimperator and try to explain the difference more cleanly.

Best wishes from Berlin,

Matthias

Sourcing special file on startup?

Is there any default file like .vimrc that is sourced automatically on starting vim via vim-anywhere (along with .vimrc and .gvimrc)? I'm currently quite happy with editing ./bin/run, adding -c or -s options by hand, but I'd feel more comfortable if this application had such default file to write my preferences in.

One might want to source additional file on starting vim via vim-anywhere because the context it's usually used is somewhat different from usual editing with vim. As for me, I'd prefer white background because most websites have white backgrounds. One might want to set default filetype to markdown, or enable plugins designed specifically for text editing, not coding (I'm thinking of something like vim-quotable).

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.