Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to open an URL in Vim

Lets say that you have either URL or a link on a webpage that is a text file. How would be the easiest way for the user to be able to open that file in a Vim?

  • Right click and save link as?
  • Use a specific file extension that defaults to Vim?
  • Command line command?
like image 592
Glennular Avatar asked Jun 30 '10 20:06

Glennular


People also ask

How open HTML file in Vim?

Visually select the full path of a local html file or a URL, then type \h to preview the file or web page. Copy the full path of a local html file or a URL in another application, then type \h to preview the file or web page in Vim.

How do I jump to the beginning of a file in Vim?

Type "gg" in command mode. This brings the cursor to the first line.

Can you search in Vim?

One can search forward in vim/vi by pressing / and then typing your search pattern/word. To search backward in vi/vim by pressing ? and then typing your search pattern/word. Once word found in vim, you can press the n key to go directly to the next occurrence of the word in backwards.


2 Answers

Depending on how your vim binary was built you can just give vim the url:

vim http://www.google.com/

Vim spawns curl and grabs the file, then opens it.

like image 110
speshak Avatar answered Sep 27 '22 20:09

speshak


Assuming you want to just open a link in vim, how about this:

curl http://www.google.com | vim - 

EDIT to make this command easier you can always user your browser of choice's "Copy link address" option.

EDIT Given @speshak's answer and my own, I would say the "easiest" way would be option 3, "a command line command".

like image 41
Matthew J Morrison Avatar answered Sep 27 '22 22:09

Matthew J Morrison