Vim-anywhere is a simple script that allows you to use the Vim editor to input text anywhere in your Linux box. That means you can simply invoke your favorite Vim editor, type whatever you want and paste the text on any application or website. The text will be available in your clipboard until you restart your system. This utility is absolutely useful for those who love to use the Vim keybindings often in non-vim environment.
Install Vim-anywhere in Linux
The Vim-anywhere utility will work on any GNOME based (and derivatives) Linux distributions. Also, make sure you have installed the following prerequisites.
For instance, you can install those utilities in Ubuntu as shown below.
$ sudo apt install curl git vim-gnome xclip
Then, run the following command to install Vim-anywhere:
$ curl -fsSL https://raw.github.com/cknadler/vim-anywhere/master/install | bash
Vim-anywhere has been installed. Now let us see how to use it.
Use Vim editor to input text anywhere in Linux
Let us say you need to create a word document. But you're much more comfortable using Vim editor than LibreOffice writer. No problem, this is where Vim-anywhere comes in handy. It automates the entire process. It simply invokes the Vim editor, so you can write whatever you want in it and paste it in the .doc file.
Let me show you an example. Open LibreOffice writer or any graphical text editor of your choice. Then, open Vim-anywhere. To do so, simply press CTRL+ALT+V. It will open the gVim editor. Press "i" to switch to interactive mode and input the text. Once done, save and close it by typing :wq.
The text will be available in the clipboard until you restart the system. After you closed the editor, your previous application is refocused. Just press CTRL+P to paste the text in it.
It's just an example. You can even use Vim-anywhere to write something on an annoying web form or any other applications. Once Vim-anywhere invoked, it will open a buffer. Close it and its contents are automatically copied to your clipboard and your previous application is refocused.
The vim-anywhere utility will create a temporary file in /tmp/vim-anywhere when invoked. These temporary files stick around until you restart your system, giving you a temporary history.
$ ls /tmp/vim-anywhere
You can re-open your most recent file using command:
$ vim $( ls /tmp/vim-anywhere | sort -r | head -n 1 )
Run the following command to update Vim-anywhere:
Change keyboard shortcut
The default keybinding to invoke Vim-anywhere is CTRL+ALT+V. You can change it to any custom keybinding using gconf tool.
$ gconftool -t str --set /desktop/gnome/keybindings/vim-anywhere/binding <custom binding>
Some of you might think that opening Vim editor each time to input text and paste the text back to another application might be pointless and completely unnecessary.
If you don't find this utility useful, simply uninstall it using command:
And, that's all for now.