Skip to content

Instantly share code, notes, and snippets.

@bibstha
Last active August 29, 2015 14:23
Show Gist options
  • Save bibstha/a86c259176bbaab9c002 to your computer and use it in GitHub Desktop.
Save bibstha/a86c259176bbaab9c002 to your computer and use it in GitHub Desktop.

Some intermediate tips for VIM enthusiasts

In the beginning, there was the basics:

Command Mode
i - Insert Mode
a - Insert after the character
I - Insert at the beginning of the line
A - Insert at the end of the line
u - Undo
dd - delete line
x - delete character
s - delete character and auto insert mode
<Ctrl-r> Redo

:w save, :q exit, ! <shell command>, :w!, :q! forced versions
:%s/searchstring/replacestring/g

Next Upgrade

Micheal's vim configs
- Line numbers
- show white spaces and strip white space()
- Syntax highlight and Solarized Theme

And there was light

https://github.com/thoughtbot/dotfiles

Along with many other blog posts written in thoughtbot blogs related to vim and efficiency.

- Relative Line Numbers
- Vim Movements
  - Disable arrow keys and use h, j, k, l exclusively
  - n+(hjkl) for fast movements
  - f,F for fast movements in line with , and ; for repeat
  - . (dot) for repeated commands
  - % for vim toggling location between opening and closing tags, braces, statements
  - gg and G, 
  - zz, zt, zb, <Ctrl-D>, <Ctrl-U> - scroll current window
  - # and *
- Vim Selected Commands
  - d+(vim movement), c+(vim movement)
  - d/c + (i/a) + selection (diw, ciw, da(, da", ca", ...)
- Source Formatting
  - > right indent, < left indent, = for default indent
  - mix >, < and = with movement commands
  - =% proper indent a block of code, gg=G proper indent the whole source file
  - Visual Mode, v, Shift+v, Ctrl+v (column select)
  - Ctrl+v with Shift+I (to do things like in sublime, multi cursor)
- Multiple Files
  - splits (split, vsplit, tabnew)
  - ctrl+p
  - netrw (Sex, Vex, Sex!, Vex!, e, Ex)
  - using % for auto file path completion

Part2?

  • Patterns
  • Buffers (:bufdo, :ls, :bd, :b(num), ..)
  • Tabs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment