Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
What do you mean by "copy text from vim to web browser"? Do you mean copy text from vim to html editor? – user25656 Sep 20 '12 at 11:20
I need to copy text from a file opened in vim editor into a multiline textbox on a webpage in firefox. – FireAndIce Sep 20 '12 at 12:18
I wrote this in vim and then copied it to this textbox by doing the following: select the text with shift+v, then press "+y to yank to the system clipboard. Vim's clipboard setting is currently the default, which for me is clipboard=autoselect,exclude:cons\|linux. This yanks to xclip, so xclip -o on the command line should show whatever was copied. Then simply ctrl+v into the textbox. – chris.ritsen Sep 20 '12 at 13:57
up vote 5 down vote accepted


  1. Select the text without pressing a shortcut key and middle-click in the browser window, or
  2. Select the text, press shift-ctrl-c and then use ctrl-v to paste, or
  3. 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=gedit

    before starting whatever program you start to edit the sql files.

share|improve this answer
SQL files are just text files containing SQL commands in ASCII or UTF-8. They generally have no special characters other than math symbols, parentheses, or quotes. – hexafraction Sep 20 '12 at 11:35
Yes. Except when they aren't, for example when they are sqlite3 files. Yes, some programs do that. In any case, that does not explain why the OP can't use gedit for them. – January Sep 20 '12 at 11:56
SQLite files don't carry this file extension nor are they called SQL files. – hexafraction Sep 20 '12 at 19:15
@ObsessiveFOSS You should have written "SQLite files should not carry this file extension" – January Sep 22 '12 at 6:02
The EDITOR environment variable is often assumed to hold the name of an editor that can run without a GUI. For an editor like gedit, it's usually best to set the VISUAL environment variable instead. When a graphical editor can be used, VISUAL is usually consulted before EDITOR. Usually. – Eliah Kagan Oct 3 '12 at 9:18

Use "+y to yank the selected text to your Ctrl-V clipboard ("*y would be middle mouse button)

More on registers in Vim

share|improve this answer
To use "+y, you have to check X11-clipboard support first. This post explained how in detail. – 47dev47null Feb 23 '13 at 2:27

you could simply use the mouse (right-click+copy) and (rightclick+Paste)

share|improve this answer
  1. Select the text using mouse
  2. Ctrl-Shift-C (Note the Shift)
  3. Switch to the new window where you want to paste
  4. Ctrl-V
share|improve this answer

I would open the file in the browser using a file URL:


Not super elegant but it works.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.