Vim: Open current line on Atlassian Stash (Bitbucket Server)

This is based on Felix Geisendörfer Vim Trick: Open current line on GitHub.

Step 1. Create a git alias

# ~/.gitconfig
  url =! bash -c 'git config --get remote.origin.url | sed -E "s/.+\\.ru\\\\/\\(.+\\)\\\\/\\(.+\\)\\.git$/https:\\\\/\\\\/stash\\\\.yourcompanyname\\\\.com\\\\/projects\\\\/\\\\1\\\\/repos\\\\/\\\\2\\\\/browse/g"'

Change domain name from ‘’ to something real. Pay attention to ‘.’ escaping.

Step 2. Create a mapping in Vim

; ~/.vimrc
nnoremap <leader>ou :!echo `git url`/%?at=`git rev-parse HEAD`\#<C-R>=line('.')<CR> \| xargs open<CR><CR>

Step 3. Enjoy

My dotfiles:

Anton Kaliaev

Read more posts by this author.

Ulyanovsk, Russia