I’m using a vim plugin and when I want to look up a function under the cursor in the online api docs, I type ‘\da’
Here’s the vimscipt code for the keymapping:
nnoremap <buffer> <LocalLeader>dda :silent call <SID>OpenURL('http://api.drush.ws/api/function/')<CR><C-L>
When the command is run, it writes the standard output from the shell into the current vim buffer, so the phrase:
“Created new window in existing browser session.” will be written into the current buffer.
Also here’s the openurl function:
function s:OpenURL(base)
let open = b:Drupal_info.OPEN_COMMAND
if open == ''
return
endif
let func = shellescape(expand('<cword>'))
if a:base == 'api.d.o'
if strlen(b:Drupal_info.CORE)
execute '!' . open . ' http://api.drupal.org/api/search/' .
\ b:Drupal_info.CORE . '/' . func
else
execute '!' . open . ' http://api.drupal.org/' . func
endif
else
execute '!' . open . ' ' . a:base . func
endif
endfun
How do I fix this/redirect stdout?
(I’m using ubuntu/gnome.)
Thanks!
I do not see anything that will put command output into the current buffer. But if you don’t want to observe command output at all, you can do one of two things:
silentin front of each!(note: you must have the space aftersilent) and addredraw!command just beforeendfunction.execute '!'.<...>withcall system(<...>)(in this case having newline in arguments is much likely to cause bugs).