mirror of
https://github.com/jbranchaud/til
synced 2026-01-02 22:58:01 +00:00
Add Open The Selected Lines In GitHub With Gbrowse as a vim til
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
|
||||
|
||||
_1027 TILs and counting..._
|
||||
_1028 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -1116,6 +1116,7 @@ _1027 TILs and counting..._
|
||||
- [Open The Directory Of The Current File](vim/open-the-directory-of-the-current-file.md)
|
||||
- [Open The Gemfile](vim/open-the-gemfile.md)
|
||||
- [Open The Latest Rails Migration](vim/open-the-latest-rails-migration.md)
|
||||
- [Open The Selected Lines In GitHub With Gbrowse](vim/open-the-selected-lines-in-github-with-gbrowse.md)
|
||||
- [Open Vim To A Tag Definition](vim/open-vim-to-a-tag-definition.md)
|
||||
- [Opening a URL](vim/opening-a-url.md)
|
||||
- [Opening Man Pages In Vim](vim/opening-man-pages-in-vim.md)
|
||||
|
||||
27
vim/open-the-selected-lines-in-github-with-gbrowse.md
Normal file
27
vim/open-the-selected-lines-in-github-with-gbrowse.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# Open the Selected Lines In GitHub With GBrowse
|
||||
|
||||
The [`vim-fugitive`](https://github.com/tpope/vim-fugitive) plugin comes with
|
||||
the `:Gbrowse` command.
|
||||
|
||||
> Open the current file, blob, tree, commit, or tag in your browser at the
|
||||
> upstream hosting provider. If a range is given, it is appropriately appended
|
||||
> to the URL as an anchor.
|
||||
|
||||
I would try this from repositories hosted on GitHub and get an error. Reading a
|
||||
bit further into the `:Gbrowse` documentation I can see why.
|
||||
|
||||
> Upstream providers can be added by installing an appropriate Vim plugin. For
|
||||
> example, GitHub can be supported by installing rhubarb.vim, available at
|
||||
> <https://github.com/tpope/vim-rhubarb>.
|
||||
|
||||
I was missing the [`vim-rhubarb` plugin](https://github.com/tpope/vim-rhubarb).
|
||||
After installing that, I can open the current file in GitHub by running
|
||||
`:Gbrowse`.
|
||||
|
||||
If I make a visual selection of any number of lines, then I can go into command
|
||||
mode again typing out `Gbrowse` with the automatically preceding visual
|
||||
selection tags. This will open the file on GitHub with those lines selected.
|
||||
|
||||
```
|
||||
:'<,'>Gbrowse
|
||||
```
|
||||
Reference in New Issue
Block a user