I need to copy text from vim to web browser since I'm not able to use gedit as I'm opening an sql file. How do I get this done?
6 Answers
Either
- Select the text without pressing a shortcut key and middle-click in the browser window, or
- Select the text, press shift-ctrl-c and then use ctrl-v to paste, or
I'm not entirely sure what vim has to do with sql files and what these sql files are (sqlite?), but maybe you have to use vim because the environment variable EDITOR is set to vim; maybe you could do whatever you do by setting
export EDITOR=geditbefore starting whatever program you start to edit the sql files.
- 37,208
Use "+y to yank the selected text to your Ctrl-V clipboard ("*y would be middle mouse button)
Select the text you want to copy using Visual Mode in Vim editor.
venters visual mode and selects the character at cursor location.Shift-vselects the entire line.In Vim, Copying is done using the
yor "yanking". To copy selected text to system clipboard type"+yin Normal Mode. Now you can paste it anywhere else usingCtrl-v.To copy text from outside applications into Vim editor, first copy the text using the usual
Ctrl-Ccommand then go to Vim editor and type"+pin Normal Mode.I find the above commands very tedious to type every time I copy-paste from outside Vim, so I mapped the
Ctrl-yto copy and theCtrl-pto paste in Vim. Now I don't have to type"+yand"+pevery time.
Add these to your .vimrc file:
nnoremap <C-y > "+y
vnoremap <C-y> "+y
nnoremap <C-p> "+p
vnoremap <C-p> "+p
Edit: Before following the above steps,check vim --verison.Vim must have +xterm_clipboard feature installed for the above method to work. If not , then run sudo apt-get install vim-gtk to get the necessary packages.
- 486
- 4
- 7
- 22
you could simply use the mouse (right-click+copy) and (rightclick+Paste)
- Select the text using mouse
- Ctrl-Shift-C (Note the Shift)
- Switch to the new window where you want to paste
- Ctrl-V
- 4,121
I would open the file in the browser using a file URL:
file:///home/dave/some-file
Not super elegant but it works.
- 839
- 1
- 9
- 15