Skip to content

Instantly share code, notes, and snippets.

@deris
Created July 4, 2013 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deris/5929247 to your computer and use it in GitHub Desktop.
Save deris/5929247 to your computer and use it in GitHub Desktop.
NeoBundleの相対パスを開く(from .vimrc)
NeoBundle 'tyru/open-browser'
nnoremap gz vi':<C-u>call ExecuteWithSelectedText('OpenBrowser https://github.com/%s')<CR>
vnoremap gz :<C-u>call ExecuteWithSelectedText('OpenBrowser https://github.com/%s')<CR>
" visualモードで最後に選択したテキストを%sで指定してコマンドを実行する {{{
function! ExecuteWithSelectedText(command)
if a:command !~? '%s'
return
endif
let reg = '"'
let [save_reg, save_type] = [getreg(reg), getregtype(reg)]
normal! gvy
let selectedText = @"
call setreg(reg, save_reg, save_type)
if selectedText == ''
return
endif
execute printf(a:command, selectedText)
endfunction
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment