Skip to content

Instantly share code, notes, and snippets.

@simplay
Last active August 29, 2015 14:19
Show Gist options
  • Save simplay/17d04d4a11a58d967fce to your computer and use it in GitHub Desktop.
Save simplay/17d04d4a11a58d967fce to your computer and use it in GitHub Desktop.
all vim steps needed to be done...

... and this is how the story started...

:s/foo/bar/gc replace every foo in a text with bar (confirm after each detected occurrence). goto beginning of a word (move cursor onto its first letter), type v1ey to copy that word and move cursor to target word (its first letter) and type v1ep to overwrite it with copied word (not taht overwritten word is now in clipboard, i.e. can be pastes again - easy word swaps).

Locations you should know: ~/.vimrc

Initially, do this:

    Step 1. Install homebrew from here: http://brew.sh
    Step 1.1. Run export PATH=/usr/local/bin:$PATH
    Step 2. Run brew update
    Step 3. Run brew install vim && brew install macvim
    Step 4. Run brew link macvim

Insert Mode verbs

    i insert at current location
    a insert after current location (append)
    I insert AT START of current line
    A insert AFTER END of current line
    o insert line below current line (open)
    O insert line ABOVE current line
    s delete character under cursor and start inserting in its place (substitute text)
    S delete all text on line and start inserting in its place (substitute line)
    cw delete to the end of current word and start inserting in its place (any movement command can be substituted for w)
    cc same as S (change line)
    C delete from the cursor to the end of line and start inserting at the cursor position 
    dd delete current line; yy yank current line

normal mode verbs

hjkl
w moves one word forward 
e moves to end of word
b moves one word backward
gg moves to first line
G moves to last line
1337G moves to line 1337
d2w deletes 2 words in front of cursor position
d3l (delete)(3)(left)
    hl we count individual characters, not words, for jk we count individual lines
cw (change)(word), c3w (change)(3)(words)
u to undo and Ctrl-r to redo, multiple times
y will "yank" (copy); p will "put" (paste)

 /regularexpression to search forward, 
 ?regularexpression search backward; 
    press n for next hit, or N for previous. 

Triples (action)(times)(object)

{d} number {w,e,b}

browsing in nerdtree :e.. lists files in the parent directory. /regex

* searches for the word under the cursor. # same backwards % on brackets (([{}])) will find the matching one. . repeat last change.

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