• Stars
    star
    185
  • Rank 201,012 (Top 5 %)
  • Language
    Vim Script
  • Created over 8 years ago
  • Updated about 2 years ago

Reviews

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

Repository Details

💇 Discoverable & searchable shortcuts for (Neo)Vim

shortcut.vim

This plugin provides a discoverable shortcut system for Vim that is inspired by Spacemacs and powered by fzf.vim. It displays a searchable menu of shortcuts when you pause partway while typing a shortcut, say, because you forgot the rest of it or because you just want to see the shortcut menu again to discover what else is available. You can interactively filter the menu by typing more shortcut keys or parts of shortcut descriptions shown in the menu.

asciicast

Requirements

Installation

  1. Clone this Git repository as follows, or download and extract its contents.

     git clone https://github.com/sunaku/vim-shortcut.git ~/vim-shortcut
    
  2. Run the following commands in Vim to start using this plugin immediately, or add them to your vimrc file to automate this whenever you start Vim.

     :set runtimepath+=~/vim-shortcut
     :runtime plugin/shortcut.vim
    
  3. Run the following command inside Vim to learn more about using this plugin.

     :help shortcut.vim
    

Usage

  • Use the Shortcut! prefix (with a bang) to describe existing shortcuts.

  • Use the Shortcut prefix (without a bang) to define brand new shortcuts.

  • Use the :Shortcuts command to display a searchable menu of shortcuts.

  • Use the g:shortcuts variable to access shortcuts keys and descriptions.

  • Use the g:shortcuts_overwrite_warning variable to detect any conflicts.

Discovery & fallback shortcuts

I recommend that you define these two shortcuts for discovery and fallback (feel free to change the <Leader> key to your own commonly used prefix):

Shortcut show shortcut menu and run chosen shortcut
      \ noremap <silent> <Leader><Leader> :Shortcuts<Return>

Shortcut fallback to shortcut menu on partial entry
      \ noremap <silent> <Leader> :Shortcuts<Return>

The fallback shortcut's keys should represent the common prefix used by most of your shortcuts so that it can automatically launch the shortcut menu for you when you pause partway while typing a shortcut, say, because you forgot the rest of it or because you just want to see the shortcut menu again to discover what else is available. However, this is not a strict requirement because you might find it useful to map shortcuts with uncommon prefixes when you know them by heart and you thereby feel that a fallback is unnecessary. As a result, you can map any keys to any shortcut, regardless of the prefix! Furthermore, you can set up multiple fallback shortcuts too, one per prefix.

Describing existing shortcuts

Use Shortcut! with a bang to describe shortcuts that are already defined:

Shortcut! keys description

For more examples, see my vimrc:

Shortcut! [f       go to previous file in current file's directory
Shortcut! ]f       go to next     file in current file's directory

Any extra whitespace is ignored.

Defining new shortcuts

Simply prefix any existing map command with Shortcut and a description.

For example, take this mapping:

map definition

Add Shortcut and description:

Shortcut description map definition

You can use multiple lines too:

Shortcut description
      \ map definition

For more examples, see my vimrc:

Shortcut duplicate before cursor and then comment-out
      \ map <Space>cP  <Plug>NERDCommenterYank`[P
Shortcut fzf files in directory and go to chosen file
      \ nnoremap <silent> <Space>ef :Files<Return>
Shortcut save file as...
      \ nnoremap <silent> <Space>yf :call feedkeys(":saveas %\t", "t")<Return>
for i in range(1,9)
  execute 'Shortcut go to tab number '. i .' '
        \ 'nnoremap <silent> <Space>'. i .'t :tabfirst<Bar>'. i .'tabnext<Return>'
endfor
Shortcut comment-out using FIGlet ASCII art decoration
      \ nnoremap <silent> <Space>c@ V:call CommentUsingFIGlet()<Return>
      \|vnoremap <silent> <Space>c@ :<C-U>call CommentUsingFIGlet()<Return>

function! CommentUsingFIGlet()
  " ...
endfunction

Any extra whitespace is ignored.

Documentation

Run :help shortcut.vim or see the doc/shortcut.txt file.

Testing

Developers can run the vim-vspec tests:

gem install bundler         # first time
bundle install              # first time
bundle exec vim-flavor test # every time

License

Like my work? 👍 Please spare a life today as thanks! 🐄🐖🐑🐔🐣🐟🙊
Why? For 💕 ethics, the 🌎 environment, and 💪 health; see link above. 🙇

Copyright 2015 Suraj N. Kurapati https://github.com/sunaku

Distributed under the same terms as Vim itself.

More Repositories

1

tamzen-font

💌 Bitmapped programming font, based on Tamsyn
Ruby
818
star
2

dasht

💁 Search API docs offline, in terminal or browser
Shell
803
star
3

md2man

📚 Converts markdown into UNIX manual pages
Ruby
362
star
4

tork

💞 Tests your Ruby code, in parallel, as you change it
Ruby
181
star
5

vim-dasht

💁 (Neo)Vim plugin for dasht integration
Vim Script
131
star
6

home

🏡 My $HOME directory (dot files & bin scripts)
Shell
128
star
7

.vim

✌️ A modular (Neo)Vim configuration
Vim Script
112
star
8

vim-ruby-minitest

Vim highlighting & completion for MiniTest
Vim Script
107
star
9

glove80-keymaps

Glove80 keymap: "Glorious Engrammer"
HTML
100
star
10

vim-unbundle

🎁 Fast, filetype-lazy loader of Vim scripts & plugins
Vim Script
97
star
11

wmiirc

Ruby configuration for WMII window manager
Ruby
81
star
12

tmux-navigate

🥂 Seamless tmux/vim navigation (over SSH too!)
Shell
50
star
13

engrammer

Arno's Engram layout for programmers
Makefile
42
star
14

vim-hicterm

🌈 Highlights terminal color code numbers (0-255)
Vim Script
41
star
15

vim-modusline

🌈 Mode-specific statusline colors
Vim Script
39
star
16

binman

🤓 Creates manual pages from header comments
Ruby
36
star
17

wmii

My fork of the WMII window manager.
C
36
star
18

readably

📚 Static blogs: YAML + Slim → HTML5
Ruby
30
star
19

simple-ftp

My final project for CMPE-150 at UCSC during Spring 2004.
C
27
star
20

rumai

Ruby interface to 9P2000 protocol and WMII window manager
Ruby
21
star
21

bdf2fon

Convert X11 BDF fonts to Microsoft .FNT and .FON formats
C
15
star
22

ruby-vpi

Ruby interface to IEEE 1364-2005 Verilog VPI
Ruby
15
star
23

sunaku.github.io

🌟 My own little corner of the Web
HTML
10
star
24

.dwm

My dwm configuration with Ruby statusbar.
C
10
star
25

inochi

Infrastructure for Ruby projects
Ruby
10
star
26

ruby-coroutine-example

How to embed Ruby inside C coroutines.
C
9
star
27

ember

eRuby template processor
Ruby
8
star
28

sm4tik-font

BDF font of sm4tik's 8x8 XBM icons.
7
star
29

erbook

Write books, manuals, and documents in eRuby.
JavaScript
7
star
30

beakl15p

BEAKL-15p keyboard layout
7
star
31

kwalify

YAML schema validation for Ruby
7
star
32

swig-ruby-ffi

Ruby FFI language module for SWIG
C++
7
star
33

structy_record

🎩 Provides a Struct-like interface for Records
Elixir
6
star
34

detest

Assertion testing library for Ruby
Ruby
5
star
35

rassmalog

Static blogging with YAML and eRuby
Ruby
5
star
36

libixp

Mirror of 9P2000 library from WMII window manager.
C
5
star
37

babelfish

Ruby interface to Yahoo! BabelFish translation service.
Ruby
4
star
38

ofc2_to_png

Open Flash Chart 2 JSON to PNG converter
JavaScript
4
star
39

knights-tour

Knight's Tour algorithm in C, OpenGL, and Cg. This was my final project for CMPE-220 at UCSC during Winter 2007.
C
3
star
40

.dmenu

My dmenu configuration.
C
3
star
41

programming-elixir-issues

Sample project from the Programming Elixir book
Elixir
2
star
42

vim-ruby-shoulda-context

Vim highlighting & completion for shoulda-context.
Vim Script
2
star
43

firefox-tranquility

My fork of the Tranquility addon for Firefox
JavaScript
1
star
44

test-loop

MOVED TO sunaku/testr
1
star
45

kernel_hash

Adds a Kernel#Hash() method like Kernel#Array()
Ruby
1
star
46

redcarpet-manpage

renamed to md2man
1
star
47

test-unit-must

Selfish "must" assertions for Test::Unit
Ruby
1
star
48

ff-bash

For each File (GNU BASH)
Shell
1
star
49

opener

👐 A 33-line alternative to Ruby's launchy gem
Ruby
1
star
50

testr

MOVED TO sunaku/tork
1
star
51

onig-5.9.2

My patches to Oniguruma 5.9.2
C
1
star
52

test-unit-must.vim

Vim syntax highlighting for test-unit-must assertions
Vim Script
1
star
53

equal_rights_for_hash

Adds Kernel#Hash() and generic #to_h() methods.
Ruby
1
star