Day 2: Getting jiggy with it (VIM)
ref: http://ss64.com/vi.html
VIM CODE FOLDING http://smartic.us/2009/04/06/code-folding-in-vim/
$ vim ~/.vimrc
za - fold/unfold the entire node
zr - unfold some nested folds one layer at a time
zm - fold all at level of cursor
zM - Fold everything (minimize)
zR - Unfold everything (restore)
zo - Open fold at cursor
zO - Opens ALL folds at cursor
^ - move to first character on line
::Advanced Command List
nG Goes to the nth line in the file!
f_ Search till the next occurance of '_'
t_ Search till before next occurance of '_'
Example:
Problem - Indents are all messed up.
Solution
1) Set cursor to where the indent should be for the "get 'home'" line.
2) dtg to set the indent proper.
3) jdtr to do the next down line.
4) f(j to setup in a good spot on the next line down
5) dt: to set that lines indet right.
etc. etc...
Wait, that's a lot of work, most IDE's do that automatically. And randomly. How can vim do that?
= - fix the indents for something. Specify a motion such as 'to the end' eg =G or 'to the start' =gg of 'fix endents for Bracketed block whilc on a bracket char' =%
:set paste - prevents some bug when you try to paste and comments go crazy
commenting:
visual block select with CTRL-V then I# (insert # in the begining)
uncommenting:
visual block select with CTRL-V then X (delete the first symbol on the line)
Please note uppercase I and X.
Show line numbers:
:set number
:: About vim
At first glance, vi appears to be a scrapy means of implimenting a text editor in a shell window.
This is not even remotely the case. Vi, or at least vim, rivals text mate in everyway.
This is possible because:
1) Vim is extensible. Anybody can write a vim plugin or syntax scheme
2) vim has millions of keystroke combos that allow you to work with out needing to move a hand to the mouse.
3) Someday Vim will work with a web cam that has eye tracking, allowing you to jump to specific words.
Vim is the future
color scheme
http://programmers.stackexchange.com...ramming-in-vim
:colorscheme evening
:colorscheme slate
:colorscheme elflord
Rails tips:
Site: http://whynotwiki.com/Editing_Ruby_code_in_vim
":w !ruby -c" - Check ruby syntax of file
Configuring vim with rails
http://oldwiki.rubyonrails.org/rails...seVimWithRails
Plugins for rails
Vid: http://www.youtube.com/watch?v=30P8DSNOZuU
rails.vim - http://www.vim.org/scripts/script.php?script_id=1567
$ wget http://www.vim.org/scripts/download_...p?src_id=13800
NERD tree - http://www.vim.org/scripts/script.php?script_id=1658
$ wget http://www.vim.org/scripts/download_...p?src_id=11834
VIM CODE FOLDING http://smartic.us/2009/04/06/code-folding-in-vim/
$ vim ~/.vimrc
Code:
"folding settings set foldmethod=indent "fold based on indent set foldnestmax=10 "deepest fold is 10 levels set nofoldenable "dont fold by default set foldlevel=1 "this is just what i use
zr - unfold some nested folds one layer at a time
zm - fold all at level of cursor
zM - Fold everything (minimize)
zR - Unfold everything (restore)
zo - Open fold at cursor
zO - Opens ALL folds at cursor
^ - move to first character on line
::Advanced Command List
nG Goes to the nth line in the file!
f_ Search till the next occurance of '_'
t_ Search till before next occurance of '_'
Example:
Problem - Indents are all messed up.
Code:
it "should have the right title" do get 'home' response.should have_selector("title", :content => "Ruby on Rails Tutorial Sample App | Home") end end
1) Set cursor to where the indent should be for the "get 'home'" line.
2) dtg to set the indent proper.
3) jdtr to do the next down line.
4) f(j to setup in a good spot on the next line down
5) dt: to set that lines indet right.
etc. etc...
Wait, that's a lot of work, most IDE's do that automatically. And randomly. How can vim do that?
= - fix the indents for something. Specify a motion such as 'to the end' eg =G or 'to the start' =gg of 'fix endents for Bracketed block whilc on a bracket char' =%
:set paste - prevents some bug when you try to paste and comments go crazy
commenting:
visual block select with CTRL-V then I# (insert # in the begining)
uncommenting:
visual block select with CTRL-V then X (delete the first symbol on the line)
Please note uppercase I and X.
Show line numbers:
:set number
:: About vim
At first glance, vi appears to be a scrapy means of implimenting a text editor in a shell window.
This is not even remotely the case. Vi, or at least vim, rivals text mate in everyway.
This is possible because:
1) Vim is extensible. Anybody can write a vim plugin or syntax scheme
2) vim has millions of keystroke combos that allow you to work with out needing to move a hand to the mouse.
3) Someday Vim will work with a web cam that has eye tracking, allowing you to jump to specific words.
Vim is the future
color scheme
http://programmers.stackexchange.com...ramming-in-vim
:colorscheme evening
:colorscheme slate
:colorscheme elflord
Rails tips:
Site: http://whynotwiki.com/Editing_Ruby_code_in_vim
":w !ruby -c" - Check ruby syntax of file
Configuring vim with rails
http://oldwiki.rubyonrails.org/rails...seVimWithRails
Plugins for rails
Vid: http://www.youtube.com/watch?v=30P8DSNOZuU
rails.vim - http://www.vim.org/scripts/script.php?script_id=1567
$ wget http://www.vim.org/scripts/download_...p?src_id=13800
NERD tree - http://www.vim.org/scripts/script.php?script_id=1658
$ wget http://www.vim.org/scripts/download_...p?src_id=11834
Total Comments 0