Skip to content

Enhance your Vim workflow with a script that opens the nearest URL to your cursor in a web browser, directly from Vim.

License

Notifications You must be signed in to change notification settings

sderev/vim-url-opener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

vim-url-opener

demo_extract_and_open_nearest_url.mp4

This setup allows you to open URLs in your web browser from Vim without having your cursor exactly under the URL.

This is not a plugin, but a set of Unix filters following the philosophy: "Do one thing and do it well."

As such, there is no automated installation process. You will need to manually install the scripts and configuration. But don't worry, it's very simple and takes less than a minute.

I wrote a small blog post on my website that more or less repeats what's written here, but with more details.

Table of Contents

  1. Usage
  2. Get the Files
  3. Installation and Configuration

Usage

To open a URL in your web browser, just place the cursor near the URL and press gx. There is no need to have your cursor exactly under the URL. You can customize the keybind, but it uses gx by default.

Get the Files

Either by cloning the repository:

git clone https://github.com/sderev/vim-url-opener.git

Or by downloading the files directly:

curl -O https://raw.githubusercontent.com/sderev/vim-url-opener/main/scripts/extract_nearest_url && \
curl -O https://raw.githubusercontent.com/sderev/vim-url-opener/main/scripts/add_this_to_your_vimrc.txt && \
curl -O https://raw.githubusercontent.com/sderev/vim-url-opener/main/scripts/brave

Installation and Configuration

  1. Copy the extract_nearest_url script to a directory in your PATH. For example: ~/usr/local/bin.
  2. Copy the brave script to a directory in your PATH.
  3. Edit the brave script and replace the path to your own web browser.
    • Rename the script to match the name of your web browser.
    • You will also now be able to open URLs in your web browser from your terminal: brave https://example.com.
  4. Add the content of add_this_to_your_vimrc.txt to your .vimrc.
    • Change the brave command to the name of the script you created in step 3.
    • Change the keybind if you want to use something other than gx.

That's it.

About

Enhance your Vim workflow with a script that opens the nearest URL to your cursor in a web browser, directly from Vim.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published