Since this is a DDG thread, I just wanna highlight a thing I did in vim recently
Using vim you may know you can define the `keywordprg` to use when pressing `K` on a word (in command mode). This is going to, if able, show you some form of documentation
Python is already using `pydoc` in this case.
I wanted something for the other instances, and I wanted to try getting DDG to be an ok solution, since it has that Q&A view.
Here's what I ended up with (for now, surely evolving -- not perfect)
note: you could put this in a ftdetect/javascript or whatever directory, but this is to be generalized for my case, and so I use an autocmd:
autocmd Filetype * if &ft!="python" && &ft!="vim"
\ | let &l:keywordprg=fnamemodify($MYVIMRC, ":h") . "/search.sh " . &l:filetype | endif
Sorta ugly but hey, I don't want to overwrite the keywordprg used by python and vim (if you're parsing a vim plugin you did not write, you may want to press K on a thing to understand what it is)
And in your your vimrc's root you'll need `search.sh` with these contents:
# searches the filetype & keyword
# in case of multiple filetypes (javascript.jsx) we just use the first
firefox "https://duckduckgo.com/?q=$(echo $1| cut -d'.' -f1)+$2"
Cool, now press K on a thing and assuming you use firefox, hopefully the results are OK, heh. It could be improved.
As an example I just pressed `K` on the word `import` in a `javascript` file:
If you're using another browser, you could probably just use `x-www-browser` in place of firefox, to launch your default browser (in the case of linux)
Using vim you may know you can define the `keywordprg` to use when pressing `K` on a word (in command mode). This is going to, if able, show you some form of documentation
Python is already using `pydoc` in this case.
I wanted something for the other instances, and I wanted to try getting DDG to be an ok solution, since it has that Q&A view.
Here's what I ended up with (for now, surely evolving -- not perfect)
note: you could put this in a ftdetect/javascript or whatever directory, but this is to be generalized for my case, and so I use an autocmd:
Sorta ugly but hey, I don't want to overwrite the keywordprg used by python and vim (if you're parsing a vim plugin you did not write, you may want to press K on a thing to understand what it is)And in your your vimrc's root you'll need `search.sh` with these contents:
Cool, now press K on a thing and assuming you use firefox, hopefully the results are OK, heh. It could be improved.As an example I just pressed `K` on the word `import` in a `javascript` file:
https://duckduckgo.com/?q=javascript+import&atb=v132-3_j&ia=...
If you're using another browser, you could probably just use `x-www-browser` in place of firefox, to launch your default browser (in the case of linux)