Created
July 29, 2010 06:44
-
-
Save nicalpi/497434 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Config is there http://github.com/spyou/vim-config | |
#Give a go to vimtutor in order to have a little overview of Vim. | |
"open/save" | |
#:w (save) | |
#:q (quit) | |
#:qa (quit all buffers) | |
#:q! (quit without saving) | |
#:wq (save and quit) | |
"Navigation in Vim" | |
#Navigation with arrow key, home and end, pageUp, pageDown | |
#Alternatively use kj lh and ^ or $ | |
def super_method | |
@var = Class.new(:name => params[:name]) | |
end | |
#Navigate inside the document with gg (top) M (middle) G(end) 14G (line 14) | |
#Navigate between words beginning with w and W | |
#Navigate between words end with e and E | |
#Back previous with b and B | |
def second_method | |
@super_long_variable_to_append = SuperClass.new(:name => "something", :title => "else") | |
end | |
#From here, go up 5 lines by 5UpArrow | |
#Use paragraph mode with { and } | |
"Modifying text" | |
#Basic text inserting is done with i (insert before) and a(insert after). | |
#Insert can be done with I (beginning of line) or A (end of line) | |
#Combine command like ea (insert end of word) | |
#Escape mode is <esc> | |
#Search character with f and t | |
#Repeat with ; | |
def second_method | |
#Append a new line with o | |
@super_long_variable_to_append = SuperClass.new(:name => "something", :title => "else") | |
#Append a new line above with O | |
@not_needed_anymore = DeleteMe.with(:command => dd) | |
#Undo the previous command with u | |
#Redo with <command>R | |
@little_typo__here = CorrectMe.with(:command => x or s) | |
#give a go to X | |
#Substitute this comment line for something more user full with S | |
#another one with cc | |
@change_my_name = CorrectMe.with(:command => c$ (from .) or cw or cW) | |
#Indent me with < | |
#Repeat previous command with . (dot) | |
#Ident me + the next 4 lines with 5< | |
#1 | |
#2 | |
#3 | |
#4 | |
#Use . to repeat | |
#Indent me with > | |
#Auto indent the line with =G | |
#Auto indent the whole file with gg=G | |
end | |
"Vim visual mode" | |
#Enter visual mode with v | |
#Delete with Del and chande with c | |
#Select outer () with ab and outer {} with aB | |
#Select inner () with ib and outer {} with iB | |
#Select a word with aw | |
def visual_mode(params=ab) | |
@h = {:command => aB} | |
end | |
"Vim visual block" | |
#Enter visual block with <ctrl>V | |
#Exit with esc | |
#Or exit with a command (like I) | |
def visual_block | |
conditions = { :Cond1 => var1, | |
:Cond2 => var2, | |
:Cond3 => var3, | |
:Cond4 => var4 | |
} | |
end | |
"Copy and Paste" | |
#Make "THIS" a selection and copy with y | |
#Paste with p | |
#Copy this line with yy and paste above with P | |
#Copy from :here and paste with p | |
#Ducplicate the block with D | |
#Make "THIS" a selection and delete with d | |
#Delete this line with dd and paste with p | |
#Duplicate the block with D | |
"Vim commands" | |
#Use : to enter command mode | |
#help command name | |
"Search and Replace" | |
#Search using regexp with / | |
#replace all php occurence with :%s/php/ruby/g | |
@text = "As super developers we love php! Don't we? what? you don't like php ... ok" | |
"Vim windows mode" | |
# :tabnew | |
# ^Ws | |
# ^Wv | |
# navigate with <ctrl>ww and <ctrl>wW | |
# :q to close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment