Home Vim Tips How To Use Vim Editor To Input Text Anywhere In Linux

How To Use Vim Editor To Input Text Anywhere In Linux

By sk
Published: Updated: 3.6K views

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.

  • Curl
  • Git
  • gVim
  • xclip

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.

Use Vim editor to input text anywhere in Linux
Use Vim editor to input text anywhere in Linux

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.

Use Vim editor to input text in Libreoffice
Use Vim editor to input text in Libreoffice

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 )

Update Vim-anywhere

Run the following command to update Vim-anywhere:

$ ~/.vim-anywhere/update

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>

Uninstall Vim-anywhere

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:

$ ~/.vim-anywhere/uninstall

And, that's all for now.

Resource:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More