Welcome to the most active Linux Forum on the web.
Go Back > Blogs > omgiamlinux
User Name


Rate this Entry

Day 2: Getting jiggy with it (VIM)

Posted 10-27-2011 at 08:38 PM by omgiamlinux
Updated 10-27-2011 at 08:40 PM by omgiamlinux


$ vim ~/.vimrc
"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
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 '_'

Problem - Indents are all messed up.
    it "should have the right title" do
            get 'home'
                  response.should have_selector("title",
                                                                        :content => "Ruby on Rails Tutorial Sample App | Home")
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


visual block select with CTRL-V then I# (insert # in the begining)


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
:colorscheme evening
:colorscheme slate
:colorscheme elflord

Rails tips:

":w !ruby -c" - Check ruby syntax of file

Configuring vim with rails

Plugins for rails

rails.vim -
$ wget

NERD tree -
$ wget
Posted in VIM dedication
Views 445 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 03:30 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration