• Stars
    star
    157
  • Rank 238,399 (Top 5 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 13 years ago
  • Updated over 12 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

vim knowledge tabularized - search vim keys, options and more with great precision.

Description

Increase the speed and amount of vim knowledge at your fingertips with precise searching of vim's items: keys (keybindings), options and commands. vimdb is aware of vim's default items, ones in your vimrc and ones in plugins. vimdb's plugin detection works only if you're using a pathogen-like setup i.e. each plugin has its own directory under ~/.vim/bundle/ (see Configuration below to change the directory). Tested with vim >= 7.2 on mac and windows. Works only on ruby 1.9.x.

Install

$ gem install vimdb

Usage

Basic examples searching different vim items:

# List keys with Ctrl
$ vimdb keys C-
+---------------+------+---------------------+------------------------------------------
| key           | mode | from                | desc                                    |
+---------------+------+---------------------+-----------------------------------------|
| 0 C-d         | i    | default             | delete all indent in the current line   |
| <C-End>       | i    | default             | cursor past end of fil                  |
| <C-End>       | n    | default             | 1  same as "G"                          |
| <C-Home>      | i    | default             | cursor to start of file                 |
| <C-Home>      | n    | default             | 1  same as "gg"                         |
| <C-Left>      | n    | default             | 1  same as "b"                          |
...
262 rows in set


# List options that contain word 'window' in any field
$ vimdb options window -a
+----------------+--------+----------------------------------------------------+
| name           | alias  | desc                                               |
+----------------+--------+----------------------------------------------------+
| autochdir      | acd    | change directory to the file in the current window |
| bufhidden      | bh     | what to do when buffer is no longer in window      |
| cedit          |        | key used to open the command-line window           |
| cmdwinheight   | cwh    | height of the command-line window                  |
| cscopequickfix | csqf   | use quickfix window for cscope results             |
| cursorbind     | crb    | move cursor in window as it moves in other windows |
| diff           |        | use diff mode for the current window               |
| equalalways    | ea     | windows are automatically made the same size       |
| guiheadroom    | ghr    | GUI: pixels room for window decorations            |
| helpheight     | hh     | minimum height of a new help window                |
| icon           |        | let Vim set the text of the window icon            |
...
30 rows in set

# Search for commands from pathogen plugin
$ vimdb commands pathogen -f=from
+----------+-------+---------------------+-----------------------------------------------------+
| name     | alias | from                | desc                                                |
+----------+-------+---------------------+-----------------------------------------------------+
| Helptags |       | pathogen.vim plugin | :call pathogen#helptags()                           |
| Ve       |       | pathogen.vim plugin | :execute s:find(<count>,'edit<bang>',<q-args>,0)    |
| Vedit    |       | pathogen.vim plugin | :execute s:find(<count>,'edit<bang>',<q-args>,0)    |
| Vopen    |       | pathogen.vim plugin | :execute s:find(<count>,'edit<bang>',<q-args>,1)    |
| Vpedit   |       | pathogen.vim plugin | :execute s:find(<count>,'pedit',<q-args>,<bang>1)   |
| Vread    |       | pathogen.vim plugin | :execute s:find(<count>,'read',<q-args>,<bang>1)    |
| Vsplit   |       | pathogen.vim plugin | :execute s:find(<count>,'split',<q-args>,<bang>1)   |
| Vtabedit |       | pathogen.vim plugin | :execute s:find(<count>,'tabedit',<q-args>,<bang>1) |
| Vvsplit  |       | pathogen.vim plugin | :execute s:find(<count>,'vsplit',<q-args>,<bang>1)  |
+----------+-------+---------------------+-----------------------------------------------------+
9 rows in set

# Info about how a vim item is made
$ vimdb info keys
Created using index.txt and :map

# For a list of all commands
$ vimdb

More Usage

As you can see from the last example, vimdb supports options for each command. For a command's listing of options use --help or -h:

$ vimdb keys --help
Usage: vimdb keys [QUERY]

Options:
  -a, --all          search all fields
  -f, --field        field to query
  -i, --ignore_case
  -m, --mode         search by mode, multiple modes are ORed
  -n, --not          return non-matching results
  -r, --regexp       query is a regexp
  -R, --reload       reloads items
  --reverse_sort
  -s, --sort         sort by field
  -t, --tab          print tab-delimited table

Description:
  List vim keys

As you can see, keys can be searched by keystroke, mode, description or from (default, user or plugin name). Some examples:

# List keys with Ctrl-A combo
$ vimdb keys C-A

# List keys with Esc key
$ vimdb keys E-

# List keys with Leader
$ vimdb keys L-

# List keys with no Leader - not of last search
$ vimdb keys L- -n

# List insert mode keys
$ vimdb keys -m=i

# List keys I've defined in vimrc
$ vimdb keys user -f=from

# List keys from my plugins
$ vimdb keys plugin -f=from

# List keys from snipmate plugin
$ vimdb keys snipmate -f=from

# List keys that contain completion in description
$ vimdb keys completion -f=desc

Advanced Usage

vimdb can be customized with your own commands thanks to its rc file and command engine, boson. For example, my rc file defines a command that detects conflicts between default keys and plugin keys:

$ vimdb conflict
+-------+------+---------------------+---------------------------------------------------------------------------------+
| key   | mode | from                | desc/action                                                                     |
+-------+------+---------------------+---------------------------------------------------------------------------------+
| C-w o | n    | default             | close all but current window (like |:only|)                                     |
| C-w o | n    | zoomwin plugin      | <Plug>ZoomWin                                                                   |
| *     | n    | default             | search forward for the Nth occurrence of the ident under the cursor             |
| *     | nos  | tcomment_vim plugin | :TCommentRight<CR>                                                              |
| *     | n    | default             | search forward for the Nth occurrence of the ident under the cursor             |
| *     | nos  | tcomment_vim plugin | :TComment<CR>                                                                   |
...

If you look at conflict's implementation, you see it's only about a dozen lines. Since vimdb stores vim items as array of hashes, you can use these within commands for whatever purpose.

To illustrate creating a command, let's create one that lists the first given number of vim commands. In your ~/.vimdbrc:

class Vimdb::Runner
  desc "Prints first X options"
  def first(num)
    # Set item type we're retrieving
    Vimdb.item('options')
    puts Vimdb.user.items.first(num.to_i).map {|e| e[:name] }
  end
end

To test drive it:

$ vimdb first 5
aleph
allowrevins
altkeymap
ambiwidth
antialias

Configuration

Configure vimdb with a ~/.vimdbrc (in ruby), which is loaded before every command request. For example, to configure where plugins are stored:

# plugins stored in ~/.vim/plugins
Vimdb.plugins_dir = 'plugins'

For a more thorough example, see my rc file.

Vim Mappings

Since vimdb runs on ruby 1.9.x, there's a good chance you don't have vim compiled against ruby 1.9.x. No worries, use rvm or rbenv to install a 1.9.x version. Then to invoke vimdb within vim, set up a key to pipe out to vimdb using rvm or rbenv:

map <Leader>v :!rbenv exec vimdb
" or for rvm
map <Leader>v :!rvm 1.9.3 vimdb

Key Modes

Vim's key modes are represented as single letters

  • n: normal
  • c: commandline
  • i: insert
  • o: operation
  • v: visual
  • s: select

If you're unfamiliar with all these modes read about them in vim with ':h :map-modes'.

The following modes from :map were altered to fit into the above modes:

  • ! -> ci
  • l -> ci
  • x -> v
  • v -> vs

How It Works

This gem creates a vimdb database, ~/.vimdb.pstore, by parsing your vim documentation and outputs of vim commands. When an item is first searched it is parsed. Subsequent searches are cached. To reload (and reparse) you database, pass a --reload option to most commands.

Motivation

Wanted to learn faster than :help would let me.

Credits

  • mattn for windows support

Contributing

See here

Todo

  • Add support for more vim items - variables, functions
  • Considering user annotation for vim items

More Repositories

1

hirb

A mini view framework for console/irb that's easy to use, even while under its influence. Console goodies include a no-wrap table, auto-pager, tree and menu.
Ruby
1,637
star
2

ripl

ruby interactive print loop - A light, modular alternative to irb
Ruby
395
star
3

tux

Sinatra dressed for interactive ruby - a sinatra shell
Ruby
301
star
4

bond

Mission: Easy custom autocompletion for arguments, methods and beyond. Accomplished for irb and any other readline-like console environments.
Ruby
233
star
5

boson

A command/task framework similar to rake and thor built with extendability in mind.
Ruby
218
star
6

one9

commandline tool to convert 1.8 code to ruby 1.9.2. So what's your excuse for not upgrading to 1.9.2? ;)
Ruby
171
star
7

logseq-query

Clojure
159
star
8

table

Display ascii tables for almost any data structure with ease.
Clojure
107
star
9

lightning

Speed for your shell and the commandline
Ruby
74
star
10

bahia

commandline acceptance testing - aruba for non-cucumber test frameworks
Ruby
52
star
11

nirvana

A ruby web shell that is very ape and very nice
JavaScript
52
star
12

datomic-free

A wrapper around datomic-free to easily start and upgrade it
Shell
51
star
13

irbfiles

ripl/irb the way I like it (enhanced with boson)
Ruby
50
star
14

datomico

Use datomic with intention revealing names. Ease of use and sticking to datomic's principles are encouraged.
Clojure
49
star
15

bb-clis

Babashka CLIs
Clojure
48
star
16

has_machine_tags

A rails tagging gem implementing flickr's machine tags + maybe more (semantic tags)
Ruby
44
star
17

debugger-completion

Mission: auto-complete debugger
Ruby
43
star
18

datomic-client

ruby client for datomic's http api
Ruby
41
star
19

tag-tree

Explores the wicked combo of machine tag queries + their results as trees.
Ruby
28
star
20

alias

Creates, manages and saves aliases for class methods, instance methods, constants, delegated methods and more.
Ruby
25
star
21

console_update

A gem to edit your database records via the console and your favorite editor.
Ruby
21
star
22

ltfiles

my light table dotfiles
JavaScript
20
star
23

gem_grep

*Not being maintained. Any takers?* A gem command plugin which enhances the search command by providing extra search options and displaying results as a table.
Ruby
17
star
24

machinetag.js

jQuery plugins to search/parse machine tags and display machine tag trees.
JavaScript
16
star
25

dotfiles

config files for my most used apps
Shell
15
star
26

rubydoc

A repl tool to help rubyists find clojure equivalents
Clojure
15
star
27

wolf

Devour computational knowledge on the commandline with wolframalpha
Ruby
14
star
28

ripl-play

A ripl plugin to playback and record inputs in ripl
Ruby
14
star
29

logseq-config

13
star
30

ripl-rails

alternative to script/console using ripl
Ruby
11
star
31

dlint

Lint datomic-style datalog queries and rules. For clojure and clojurescript
Clojure
11
star
32

osx-setup

Set up my osx environment with a one-liner
Ruby
11
star
33

Mermaid

Light Table plugin that generates diagrams and flowcharts from text using mermaid
JavaScript
11
star
34

datomic-box

[wip] Spin up a running Datomic Free box from the commandline. Done.
Clojure
10
star
35

rbenv-travis

Run travis tests locally using rbenv rubies
Ruby
10
star
36

local_gem

Load/require any gem/library simply given its path. Great for nascent gems or for trying the latest code on a gem.
Ruby
10
star
37

lein-spell

Catch spelling mistakes in programming documents and clojure docstrings.
Clojure
9
star
38

gitbeam

Light Table plugin for seamless github interaction
JavaScript
9
star
39

sacha

An outliner for Light Table
JavaScript
9
star
40

photon

Light Table plugin to quickly open your most active projects
Clojure
9
star
41

gh-active-issues

A pedestal service that helps github maintainers grapple with their issues and helps users understand what's before their issue
Clojure
8
star
42

Sancho

Your trusty Clojure(Script) sidekick for LightTable. Includes grimoire and crossclj integration
JavaScript
8
star
43

Share

Collaborative editing for Light Table
JavaScript
7
star
44

nbb-clis

Nbb CLIs
Clojure
7
star
45

leinfiles

Handy functions for a clojure repl - most likely lein repl
Clojure
7
star
46

boson-more

Home for boson2 plugins
Ruby
7
star
47

queriac

Picking up where Yubnub left off..
Ruby
6
star
48

ripl-rack

script/console for rack using ripl
Ruby
6
star
49

ripl-em

interact with eventmachine code - asynchronously of course
Ruby
6
star
50

ripl-irb

A ripl plugin to smooth the transition from irb
Ruby
6
star
51

rbenv-plugin

Manage rbenv plugins
Ruby
6
star
52

tag

tag anything from the commandline
Ruby
6
star
53

ripl-commands

This ripl plugin adds commands to ripl that are similar to irb's
Ruby
6
star
54

ripl-hijack

hijack a ruby process a la ripl
Ruby
5
star
55

ripl-johnson

A full-featured javascript shell using johnson (mozilla's tracemonkey)
Ruby
5
star
56

ripl-i18n

A ripl plugin that let's ripl speak your language
Ruby
4
star
57

repl.js

jquery plugin to replify an html element
JavaScript
4
star
58

previewradio-pedestal

a sinatra to pedestal-service comparison
Clojure
4
star
59

sinatra-bootstrap

sinatra app bootstrapped by bootstrap and some
JavaScript
4
star
60

ripl-misc

some misc ripl plugin ideas
Ruby
4
star
61

ripl-color_error

ripl plugin to colorize errors
Ruby
4
star
62

lein-grep

A Leiningen plugin that renders meaningful search results.
Clojure
4
star
63

urls

easy bookmarking for the commandline and beyond
Ruby
4
star
64

bond-yard

bond plugin to generate completions for yard-documented methods
Ruby
3
star
65

fda-events

Exploratory app for FDA's drug adverse event API
Clojure
3
star
66

core

*Unfinished* Easily use and share your ruby extensions and other extension libraries ie ActiveSupport, facets
Ruby
3
star
67

lein-open

Open a jar in an editor easily
Clojure
3
star
68

emoji

middleware/interceptorware to add bundled emoji images
Clojure
3
star
69

github-contributions

App to show a github user's forks and contributions to each one. Using pedestal and SSE
Clojure
3
star
70

jrepl

*Work in progress* javascript shell with readline and autocompletion
JavaScript
3
star
71

bacon-bits

Making bacon a little tastier
Ruby
3
star
72

smart-ignore

LT plugin that auto-updates ignore-pattern based on current directories in a workspace
JavaScript
3
star
73

github_user_page.js

*broken with new layout* jquery plugin/ github bookmarklet to enhance github's user pages
JavaScript
3
star
74

emojinator

a silly app that slurps a url and emojinates any word that matches an emoji name
Clojure
2
star
75

sse-chat

simple sse chat example for pedestal, ported from sinatra
Clojure
2
star
76

ripl-debug

A ripl plugin that automatically passes a failed eval to ruby-debug
Ruby
2
star
77

bolt

[work in progress] - web commands a la queriac, done all clientside with rum/reactjs
Clojure
2
star
78

menu

More choices with less typing
Ruby
2
star
79

ripl-after_rc

A ripl plugin that defines blocks to run after ~/.irbrc
Ruby
2
star
80

logseq-clis

CLIs for logseq using nbb-logseq
Clojure
2
star
81

bacon-rr

rr adapter for bacon
Ruby
2
star
82

om-components

A collection of reusable om components [WIP]
Clojure
2
star
83

bender

smack-talking hubot
CoffeeScript
2
star
84

vimfiles

no horses were harmed while horsing around with this vim setup
Vim Script
2
star
85

websh

A sinatra web shell using ripl that deploys on Heroku.
JavaScript
2
star
86

robolot

your faithful async knight
Ruby
1
star
87

emacs.d

An emacs config based on emacs-starter-kit - optimized for ruby and clojure.
Emacs Lisp
1
star
88

ripl-ripper

ripl plugin for a multi-line ripl using ripper
Ruby
1
star
89

pedestal-dataflow-logger

An experiment in logging pedestal-app dataflow internals
Clojure
1
star
90

urls-web

web interface to urls
JavaScript
1
star
91

atomfiles

JavaScript
1
star
92

semtag.me

pedestal app that communicates via clojure data using CORS requests
Clojure
1
star
93

rip-licious

A tasty collection of rip plugins
Ruby
1
star
94

rip-ext

Rip plugin to easily synchronize gem environments across ruby versions
Ruby
1
star
95

psycho

Going psycho with syck to psych conversions? Let psycho handle this syck-psych-o-ness!
Ruby
1
star
96

is_it_ec2

is it ec2?
JavaScript
1
star
97

readline.js

jquery plugin to bring readline to the hoi polloi
JavaScript
1
star
98

migration_sql

Generate migration sql for Rails apps and Sequel
Ruby
1
star
99

link-checker

A multi-threaded link-checker powered by pedestal and SSE
Clojure
1
star
100

git-puns

Atom package to git some git laughs
Clojure
1
star