Skip to content

Instantly share code, notes, and snippets.

@reegnz
Last active December 17, 2021 21:52
Show Gist options
  • Save reegnz/1ddb4a29bc86971712d3abfbeff87f63 to your computer and use it in GitHub Desktop.
Save reegnz/1ddb4a29bc86971712d3abfbeff87f63 to your computer and use it in GitHub Desktop.
Open JIRA issues from vim

Opening JIRA issues from vim

Did you ever want to open a JIRA issue from vim, so you copied the jira issue name, opened the browser, opened JIRA then pasted the issue id into the search, then clicked on the search result?

That sequence above is terribly tedious!

With the vim script below, you just position your cursor on top of the ticket id, then hit gj and boom! Issue is opened in your browser!

Config:

let g:jira_host = 'https://your.jira.url.here'
function OpenJira()
let l:word = expand("<cWORD>")
let l:match = matchlist(l:word, '\(\w\+-\d\+\)')
if empty(l:match)
return 0
endif
let l:issue = l:match[1]
let l:url = g:jira_host .. '/browse/' .. l:issue
call netrw#BrowseX(l:url, 0)
endfun
command OpenJira :call OpenJira()<CR>
nnoremap gj :OpenJira<CR>
let g:jira_host = 'https://jira.example.com'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment