I know that doing
%y a will yank complete file into register
a. However this doesn't help in pasting the file content in another text editor (say gedit). What alternative is there for doing so?
Not sure if
vi is required for this operation.
xclip utility that allows you to copy anything from console output to x server clipboard.
You should specify
DISPLAY=:0.0 environment and execute it like this:
cat file | xclip
or for remote file
ssh remote "cat file" | xclip
vi (note, that this way will temporaly clear vi buffer content, to revoke it press
u, data will stay in X cilpboard):
Now you're able to paste it anywhere with middle mouse button (note, that
shift+ins won't work).
Rather than yanking into the
a register yank into the
+ register to
yank the file contents into the X clipboard using one of:
This does require that you're using a copy of vim that has X support compiled in and is able to connect to your X server. Which of those works better for you will depend on which type of clipboard the target editor uses.
You can even have one of those registers used as the default for yank and paste
operations by including one of the following in your
set clipboard+=unnamed set clipboard+=unnamedplus
If you're regularly finding yourself needing to use both Vim and gedit together, you should probably switch to gVim, the GUI version of Vim.
It seems you're using Ubuntu where gVim isn't installed by default. Use this command to get it:
$ sudo apt-get install vim-gnome
vim-gtk which doesn't depend on Gnome, but since you're using gedit, you must be using one of the Gnome-based versions of Ubuntu.
I've solved this by adding the following alias to my
alias vim='gvim -v'
.vimrc set the clipboard to
Then yank:ed text is copied to the global buffer, and can be pasted in gedit with ctrl+v. Globally copied text can also be pasted using the vim