- Notifications
You must be signed in to change notification settings - Fork1
Search Stack Overflow code snippets within `vim`
License
cheat/vim-so
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
vim-so
wraps theso executable to provide a plain-language search interfacefor code snippets on Stack Overflow.
Assume that you're building a Go application, and have forgotten how toreverse an array. You may run the following ex command:
:So reverse an array
The following will occur:
vim-so
will detect the currentfiletype
vim
will execute the following shell command:so -t go "reverse an array"
- The first applicable code snippet will be pasted into the current buffer
- You may cycle among snippets via
so#next()
andso#prev()
vim-so
can be installed as described in:help packages
, or by using apackage manager like Pathogen, Vundle, or Plug.
Search the Stack Overflow API for code snippets matching a phrase. It'srecommended that you map this function to a convenient command:
command -nargs=1 Socallso#search(<q-args>)
Cycle to the next code snippet. It's recommended that you map this function toa convenient hotkey:
nnoremap<C-N>:call so#next()<CR>
Cycle to the previous code snippet. It's recommended that you map this functionto a convenient hotkey:
nnoremap<C-P>:call so#prev()<CR>
Open the Stack Overflow thread associated with the current code snippet inyour web browser:
command SoView :callso#view()
The browser executable that should be used in conjunction with theso#view
function.
Here's a practical configuration example. Add these lines to your.vimrc
:
letg:so_browser="firefox"command -nargs=1 Socallso#search(<q-args>)command SoViewcallso#view()nnoremap<C-N>:call so#next()<CR>nnoremap<C-P>:call so#prev()<CR>
About
Search Stack Overflow code snippets within `vim`