Skip to content

Instantly share code, notes, and snippets.

@studiomohawk
Created May 19, 2011 00:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save studiomohawk/979900 to your computer and use it in GitHub Desktop.
Save studiomohawk/979900 to your computer and use it in GitHub Desktop.
Learning Vim - Bits and Pieces

2011/05/19

Search and replace

via Vim Tips Wiki

:%s/foo/bar/gc Change each 'foo' to 'bar', but ask for confirmation first.

Or I have EasyGrep installed so

  • Leader vv - Grep for the word under the cursor, match all occurences, like |gstar|
  • Leader vV - Grep for the word under the cursor, match whole word, like |star|
  • Leader vr - Perform a global search search on the word under the cursor and prompt for a pattern with which to replace it.

2011/05/20

Working with split windows

via vimcasts.org

  • ctrl-w s split the current window horizontally, loading the same file in the new window
  • ctrl-w v split the current window vertically, loading the same file in the new window
  • :on[ly] close all windows except the currently active window
  • ctrl-W T Move current split window into its own tab

2011/05/24

Using surround.vim

surround.vim by Tim Pope

Surround.vim is all about "surroundings": parentheses, brackets, quotes, XML tags, and more. The plugin provides mappings to easily delete, change and add such surroundings in pairs.

  • vi"(double quote): select inside ""
  • vit: select inside tag
  • ci"(double quote): change inside ""
  • yit: copy inside tag
  • yi{: copy inside {

If you are HTML/CSS guy, then above and mix should be enough to utilize surround.vim
You can pair with easyGrep's Leader vr it's very useful.

2011/06/03

Make selecting with mouse in Vim do so in Visual Mode, Remap arrow keys to act as hjkl

  • Mouse uses visual mode when selecting

set selectmode=key

  • Arrow keys, in visual mode, act like hjkl

:map <down> j
:map <up> k
:map <left> h
:map <right> l

2011/06/16

  • Use tab to open files in buffer

:tab ball

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment