Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Aug 17, 2023. It is now read-only.
/vim-soPublic archive

Search Stack Overflow code snippets within `vim`

License

NotificationsYou must be signed in to change notification settings

cheat/vim-so

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

vim-so wraps theso executable to provide a plain-language search interfacefor code snippets on Stack Overflow.

Example

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:

  1. vim-so will detect the currentfiletype
  2. vim will execute the following shell command:so -t go "reverse an array"
  3. The first applicable code snippet will be pasted into the current buffer
  4. You may cycle among snippets viaso#next() andso#prev()

Installation

vim-so can be installed as described in:help packages, or by using apackage manager like Pathogen, Vundle, or Plug.

Functions

so#search

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>)

so#next

Cycle to the next code snippet. It's recommended that you map this function toa convenient hotkey:

nnoremap<C-N>:call so#next()<CR>

so#prev

Cycle to the previous code snippet. It's recommended that you map this functionto a convenient hotkey:

nnoremap<C-P>:call so#prev()<CR>

so#view

Open the Stack Overflow thread associated with the current code snippet inyour web browser:

command SoView :callso#view()

Options

g:so_browser

The browser executable that should be used in conjunction with theso#viewfunction.

Configuring

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`

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp