Skip to content

Instantly share code, notes, and snippets.

@hemantajax
Created June 10, 2013 15:03
Show Gist options
  • Save hemantajax/5749438 to your computer and use it in GitHub Desktop.
Save hemantajax/5749438 to your computer and use it in GitHub Desktop.
vim basics
VIM:
moving:
gg - beginning of file
G - end of file
$ - end of line
^ - beginning of line
Basic Editing:
Syntax highlighting:
1:
:e(edit) ~/.vimrc
2:
syntax on
set number
now save .vimrc
Boom!
u - undo
x- delete single character
dd - delete complete line
cc - delete and edit in place
- want to delete everything inside double quote
<link href="stylesheets/jquery-ui-timepicker-addon.css" rel="stylesheet" />
in command mode: ci"
for {sdfsf dfgjdfg dfgdfgfd} - ci{
cut and delete same : dd
for paste: p
for copy line: y
for pasting it : p
Search:
/function (hit n for next occurrence or N for previous occurrence )
/term
Search Replace:
:s/term/replace world/flag
:/funct/function/g
v - visual mode: line selecting
suppose you want to search/replace in a particular function
then enter into v mode, select lines and do...
>:s/term/hemant/c(for confirmation)
Macro:
convert
<li class="redflag" data-id="1">Red</li>
<li class="orangeflag" data-id="2">Orange</li>
<li class="yellowflag" data-id="3">Yellow</li>
<li class="greenflag" data-id="4">Green</li>
<li class="blueflag" data-id="5">Blue</li>
<li class="purpleflag" data-id="6">Purple</li>
<li class="greyflag" data-id="7">Grey</li>
<li class="clearflag" data-id="0">Clear Flag</li>
to
Red
Orange
Yellow
Green
Blue
Purple
Grey
Clear Flag
qa - q start macro, a name of register
df> f< d$
q - press again to quit macro
Execute macro:
for single time: @(name of register) @a
multiple times: 200@a
Boom!
To get all registers:
:reg
Advance Movement:
ctrl + d (down half of the screen)
ctrl + u ( move up half of the screen)
ctrl + f ( forward full screen)
ctrl + b (backword full screen)
for backward search: ?function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment