Skip to content

Instantly share code, notes, and snippets.

@romainl
Last active June 19, 2023 04:31
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save romainl/8d3b73428b4366f75a19be2dad2f0987 to your computer and use it in GitHub Desktop.
Save romainl/8d3b73428b4366f75a19be2dad2f0987 to your computer and use it in GitHub Desktop.
Look up keywords on https://devdocs.io from Vim

This gist is no longer maintained.

See https://github.com/romainl/vim-devdocs for an up-to-date version.


Look up keywords on https://devdocs.io from Vim

Use :DD without argument to look up the word under the cursor, scoped with the current filetype:

:DD

Use :DD keyword to look up the given keyword, scoped with the current filetype:

:DD Map

Add a ! to prevent scoping:

:DD! getelementbyid

Use :DD scope keyword to do the scoping yourself:

:DD scss @mixin

Use the :DD command for keyword look up with the built-in K:

setlocal keywordprg=:DD

My Vim-related gists.

" What command to use
function! Cmd() abort
if executable("xdg-open")
return "xdg-open"
endif
if executable("open")
return "open"
endif
return "explorer"
endfunction
" Build the URL stub
let s:stub = Cmd() . " 'https://devdocs.io/#q="
" Build the command
command! -bang -nargs=* DD silent! call system(len(split(<q-args>, ' ')) == 0 ?
\ s:stub . (expand('<bang>') == "!" || &filetype . '%20') . expand('<cword>') . "'" : len(split(<q-args>, ' ')) == 1 ?
\ s:stub . (expand('<bang>') == "!" || &filetype . '%20') . <q-args> . "'" : s:stub . substitute(<q-args>, '\s\+', '%20', 'g') . "'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment