• Stars
    star
    242
  • Rank 166,067 (Top 4 %)
  • Language
    Shell
  • Created over 2 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

A curriculum for leveling up your Vim

Vim University

Despite its reputation for minimalism, Vim has a surprising depth that rewards study. Here we list many of its most loved features, some tips, and a list of ideas for things to study or practice to take your Vim usage to the next level.

Where to get help

  • :h (:help!)
  • :h tutor

Laying out your workspace

  • Splits:
    • :sp
    • :vs
    • :on
    • CTRL-W {H,J,K,L} move window to edge.
    • CTRL-W r rotate windows.
    • CTRL-W _ maximize current window (vertically); count to size to specific height 10 CTRL-W _.
    • CTRL-W | maximize current window (horizontally).
    • CTRL-W = equalize window sizes (vertically and horizontally).
    • CTRL-W t jump to topmost window.
    • CTRL-W b jump to bottommost window.
    • Common re-mappings:
      • CTRL-h โ†’ CTRL-W h to focus window on left.
      • CTRL-j โ†’ CTRL-W j to focus window below.
      • CTRL-k โ†’ CTRL-W k to focus window above.
      • CTRL-l โ†’ CTRL-W l to focus window on right.
  • Tabs
    • :tabe
    • CTRL-W T
    • gt/gT next/previous
    • {count}gt jump to {count} indexed tab
  • tmux (Codespaces):
    • Splits (panes)
    • Windows
    • Sessions
  • Foreground/backgrounding (CTRL-Z) vs :terminal
  • Folds
    • zm: increase fold level (mnemonic: "more").
    • zM: increase fold level to maximum.
    • zr: reduce fold level (mnemonic: "reduce").
    • zR: reduce fold level to minimum.
    • zc: close fold, zC close folds recursively.
    • zo: open fold, zO open folds recursively.
    • za: toggle fold (Pro-tipโ„ข๏ธ: <Tab> is a good for mapping to this).
    • zA: toggle fold recursively.
    • zv: unfold folds to view cursor line (mnemonic: "view").
    • :set foldlevelstart=1 (start with everything folded, 99 = start with nothing folded).
    • :set foldmethod=indent vs marker (eg. ~/.config/nvim/init.lua).

Navigation

Editor fundamentals

  • Motions
    • h, j, k, l for movement
    • gj, gk for virtual movement
    • w forward to beginning of word, or W (WORD)
    • b back to beginning of word, or B (WORD)
    • e forward to end of word, or E (WORD)
    • ge back to end of last word, or gE (WORD)
  • f (mnemonic: "find"), F (in reverse)
  • t (mnemonic: "up to", "until"), T (in reverse)
  • ; repeat last f/F/t/T operation
  • , repeat last f/F/t/T operation, but in opposite direction
  • .
  • *, # + n/N
  • /{pattern} + ?{pattern}
  • Composite commands:
    • xp: swap two characters (really, x, p).
    • ggn: go to first match in file (really, gg + n).
    • GN: go to last match in file (really, G + N).
  • Common editor operations
    • o open line below for editing in INSERT mode.
    • O open line above for editing in INSERT mode.
    • A enter INSERT mode at end of line.
    • I enter INSERT mode at beginning of line.
  • Useful "fundamental" plugins:

Tools

  • Marks
    • a-z are in-file marks, A-Z are global marks.
    • Special marks include:
      • [: last yanked text.
      • <: last visual selection (> is end of last visual selection).
      • ^: last place we left INSERT mode.
      • .: place where last change was made.
    • Set a mark: :mark {mark} (or shorter, :k{mark}).
    • Go to mark `{mark} (exact position within line).
    • Go to mark '{mark} (beginning of line contents).
    • For convenience: https://github.com/kshenoy/vim-signature
      • m{mark}: to toggle mark; m, to place next available mark.
      • dm{mark}: delete a mark.
    • Jumping between marks without naming them:
      • ]' next (or ]`).
      • [' previous (or [`).
  • Registers
    • :di/:registers
    • "{register}y{motion} and "{register}p or "{register}P
  • Macros
    • Recording a macro: q{register} (uppercase appends).
    • Replaying a macro: @{register} (@@ repeats last replay command).
    • Editing macros: "{register}p โ†’ edit โ†’ "{register}yy
      • <CTRL-v> can be handy here for typing literal control characters.
    • Replay plug-in: https://github.com/wincent/replay (default mapping: <CR>)
  • Command-mode tricks:
    • Global operations
      • :g/foo/ d delete lines matching "foo" (d is an "Ex" command; can use others, like :s etc).
      • :v/foo/ d delete lines not matching "foo".
      • :%sort sort everything (:%sort n sort numerically; for other modifiers, see :h :sort).
    • Regex patterns:
      • Magic and "very magic":
      • Perlisms in Vim syntax (these in "very magic" syntax):
        • Non-greedy mappings:
          • a{-} (ie. like a*?)
          • a{-1,} (ie. like a+?)
        • Positive look-ahead (zero-width match): ab@= (ie. like a(?=b)).
        • Negative look-behind (zero-width match): ab@! (ie. like a(?!b)).
        • Positive look-behind (zero-width match): a@<=b (ie. like a($<=b)).
        • Negative look-behind (zero-width match): a@<! (ie. like a(?<!b)).
        • Easy to remember:
          • \zs do a zero-width match anywhere, setting start of match to that position; eg:
            • Positive look-behind: a\zsb
          • \ze do a zero-width match anywhere, setting end of match to that position; eg:
            • Positive look-ahead: a\zeb
      • Replacement modifiers:
        • \u makes next character uppercase
        • \U makes everything uppercase until \E/\e
        • \l makes next character lowercase
        • \L makes everything lowercase until \E/\e

Miscellaneous tips

  • Indenting and dedenting:
    • VISUAL mode: >>, <<
    • INSERT mode: CTRL-d (mnemonic: "dedent"), CTRL-t (mnemonic: "tab")
  • In INSERT mode, CTRL-O to execute one command and return to insert mode.
  • gv reselect last VISUAL selection
  • ga show ASCII value at current position
  • g8 show UTF-8 value at current position
  • g CTRL-g show current cursor position and total counts (columns, lines, words, bytes)
  • gu{motion} make lowercase
  • gU{motion} make uppercase
  • g~{motion} toggle case
  • gq{motion} format lines
  • CTRL-a increment number
  • CTRL-x decrement number
  • In INSERT mode, CTRL-r ={expr} to insert the value of an expression.

Customizing Vim

Debugging and troubleshooting

  • :verbose set ...?
  • :verbose map <prefix>
  • 'verbose' and 'verboselog'
  • Startup profiling: vim --startuptime log.txt

Resources

More Repositories

1

command-t

โŒจ๏ธ Fast file navigation for VIM
Lua
2,707
star
2

wincent

๐Ÿ’พ Dot-files
Vim Script
1,110
star
3

ferret

๐Ÿ€ Enhanced multi-file search for Vim
Vim Script
678
star
4

clipper

โœ‚๏ธ Clipboard access for local and remote tmux sessions
Go
592
star
5

terminus

๐Ÿ–ฅ Enhanced terminal integration for Vim
Vim Script
452
star
6

loupe

๐Ÿ” Enhanced in-file search for Vim
Vim Script
145
star
7

scalpel

๐Ÿ”ช Fast within-file word replacement for Vim
Vim Script
110
star
8

corpus

๐Ÿ“ A note-management application
Vim Script
91
star
9

git-cipher

๐Ÿ” Tools for storing encrypted content in Git
Ruby
82
star
10

masochist

โ›“ Website infrastructure for over-engineers
Hack
79
star
11

vim-clipper

Clipper integration for Vim
Vim Script
40
star
12

wikitext

๐ŸŒ Fast wikitext-to-HTML translator
Ruby
34
star
13

vcs-jump

๐Ÿคพ๐Ÿปโ€โ™€๏ธ Jump to interesting places with a Git or Mercurial repo
Vim Script
30
star
14

docvim

Documentation generator for Vim plug-ins
Haskell
26
star
15

yak-layout

Yak keyboard layout and optimizer
JavaScript
25
star
16

relay-2-simpler-faster-more-predictable

"Relay 2: simpler, faster, more predictable" presentation given at the Silicon Valley ReactJS Meetup on August 17th, 2016
HTML
21
star
17

base16-nvim

base16 color schemes in Lua for Neovim
Lua
19
star
18

pinnacle

๐Ÿ” Highlight group manipulation for Vim
Vim Script
17
star
19

replay

๐Ÿ” Convenient re-run of last recorded Vim macro
Vim Script
17
star
20

presentation-template

Simple starting template for slideshow presentations built using reveal.js, highlight.js and HTML
HTML
12
star
21

synergy

Lightweight iTunes controller for Mac OS X
Objective-C
11
star
22

vim-docvim

Syntax highlighting for Docvim comments
Vim Script
11
star
23

passage

๐Ÿ”‘ macOS keychain caching proxy
Go
11
star
24

cv

๐Ÿ“œ Curriculum vitae
JavaScript
10
star
25

prefnerd

Monitors changes to the OS X defaults database
Ruby
9
star
26

hextrapolate

Number base conversion tool
JavaScript
7
star
27

gerrit-best-practices-tech-talk

Slides from a tech talk at Causes on the subject of best practices for Gerrit code review
CSS
7
star
28

typing-in-js

An introduction to JavaScript type systems
HTML
6
star
29

secure-notes-exporter

๐Ÿ” Export Secure Notes from the OS X keychain
C
6
star
30

js

โ˜•๏ธ Assorted JavaScript
TypeScript
5
star
31

Google-Breakpad

Fork of the official Google Breakpad repository
C++
5
star
32

algorithms

Code related to the Princeton Algorithms course
JavaScript
5
star
33

atosym

dSYM-compatible replacement for atos
Objective-C
4
star
34

bansshee

Anti-SSH-attack tool
4
star
35

walrat

Ruby packrat parser generator
Ruby
4
star
36

gdiff

Mac OS X-native diff and patch visualization tool for Git
Objective-C
4
star
37

WinSwitch

Fast User Switching menu replacement for Mac OS X
R
3
star
38

walrus

Object-oriented templating system
Ruby
3
star
39

WOPublic

Common code used in all Wincent products
Objective-C
3
star
40

react-training-week-8

โš›๏ธ Simple exercises for React training week 8
JavaScript
3
star
41

next

To-do app
TypeScript
3
star
42

automatic-octo-barnacle-theme

Empty Liferay 7.1 theme created for testing purposes
CSS
3
star
43

converter

โš›๏ธ Simple demo app for React workshop
JavaScript
3
star
44

remote-component-test

HTML
2
star
45

jost

๐Ÿคก Just Jost (not Jest)
JavaScript
2
star
46

url-lengthening-as-a-service

URL lengthener
JavaScript
2
star
47

remote-app-test

JavaScript
2
star
48

presentation

A dead simple presentation boilerplate
JavaScript
2
star
49

wincent-strings-util

Strings file localization tool
Objective-C
2
star
50

login-tool

Command-line tool for managing startup items
Objective-C
2
star
51

clipper-lightning-talk

Lightning talk on Clipper (clipboard access for local and remote tmux sessions)
JavaScript
2
star
52

wopen3

Open3 replacement
Ruby
2
star
53

git-submodules-tech-talk

Slides from a tech talk that I gave at Causes on Git submodules
CSS
2
star
54

buildtools

Build scripts and configuration for use across all Wincent projects
Shell
2
star
55

static-react-boilerplate

Boilerplate for simple static React web applications
JavaScript
2
star
56

wincent-icon-util

Custom folder icon utility
Objective-C
2
star
57

testable-js-lightning-talk

Slides for a lightning talk on writing testable JS and testing it with Jasmine
Ruby
2
star
58

WOHotKey

Hot Key support for Cocoa applications
Objective-C
2
star
59

mkdtemp

Secure creation of temporary directories
Ruby
2
star
60

dented

โ†”๏ธ Indenting and dedenting utilities
JavaScript
2
star
61

simple-debounce

๐Ÿ€ Simple debounce implementation that fires on the trailing edge only
JavaScript
2
star
62

rails-3-lightning-talk

Slides for a 5-minute lightning talk on view escaping in Rails 3
JavaScript
2
star
63

unpack-content

๐Ÿ—ƒ Extract header data and body from plaintext (Markdown-ish) markup source
JavaScript
2
star
64

git-filter-branch-lightning-talk

How to open-source your repo without open-sourcing your repo
CSS
2
star
65

null

An empty value
1
star
66

minimal-npm-boilerplate

Minimal boilerplate for creating an NPM package
JavaScript
1
star
67

fusion

Pure plug-in architecture framework for Objective-C
Objective-C
1
star
68

fusion-base

Base plug-in for building "pure plug-in" apps
Objective-C
1
star
69

fusion-meta

Plug-in management plug-in for building "pure plug-in" apps
Objective-C
1
star
70

fusion-updater

Updater plug-in for building "pure plug-in" apps
C
1
star
71

fusion-crash-reporter

Crash reporter plug-in for building "pure plug-in" apps
C
1
star
72

wincent-on-rails

Legacy Rails application that used to power wincent.com
HTML
1
star
73

askpass

Graphical password prompter
C
1
star
74

compass-lightning-talk

Tiny demo app showing off some features of Compass for a 5-minute lightning talk at Causes
Ruby
1
star
75

conway

Conway's Game of Life
JavaScript
1
star
76

seven-languages-prolog-tech-talk

Slides and code from a tech talk on Prolog given at Causes for our Seven Languages in Seven Weeks reading group
Prolog
1
star
77

tiktoken-ruby

Rust
1
star
78

fusion-demo

Demonstration app for Fusion framework
Objective-C
1
star
79

fusion-menu

Menu plug-in for building "pure plug-in" apps
Objective-C
1
star
80

fusion-help

Help plug-in for building "pure plug-in" apps
C
1
star
81

WOBezel

Bezels, splashes and HUDs for Mac OS X
Objective-C
1
star
82

fusion-prefs

Preferences plug-in for building "pure plug-in" apps
Objective-C
1
star
83

WOTest

Objective-C unit testing framework
Objective-C
1
star
84

gerrit-intro-tech-talk

Slides from an introductory tech talk at Causes on the subject of Gerrit code review
CSS
1
star