Saari Development

This blog is intended to be a log of my (Ali Rizvi's) professional ramblings as a software development engineer. I intend to add logs of my experience with different technologies, software, tech books/articles and related stuff from time to time. My intention is to have an archive for my personal use and public benefit.

Monday, February 27, 2006

Vim: Indentation (tab) Settings

In the same discussion that I discovered the settings for ruby specific settings I found some tips on best setting of tab and shift related settings

sts=2 sw=2 ts=8 et

Here is my understanding of the settings:

sts = smart tab stops - these are useful when you hit tab for indenting, when you hit backspace you will go back a sts lenth rather than one space at a time because of et is enabled

sw = shift width - this is useful when you do << or >> for indenting

ts = tab stop - would render the real tab (tab character) properly if found in your code

et = expand tabs - replaces/exapnds tab to spaces

Vim: Setting different indentation for Ruby files

Adding this to .vimrc file should result in shift-width set to two when editing ruby files:

autocmd FileType ruby setlocal sw=2

Saturday, February 25, 2006

*nix: Text Files Commands

This post saved the day for some work related stuff:

Week 101 - Unix Commands Reference (7 March 2005)

It talks about:

split ... split a file into many files
sort ... sort the lines of a file into alphabetic order
uniq ... filter out repeated lines of a file
join ... perform a database join on files
paste ... merge corresponding lines of two file
comm ... display lines common to two files
diff ... compare two files
diff3 ... compares three files
sdiff ... compare and merge two files
zdiff, bzdiff ... diff zipped, bzipped files

Wednesday, February 22, 2006

Ruby: using irb and ri as a exploratory learning device


irb> Kernel.methods.each do |method| puts method; system "/usr/local/bin/ri --no-pager Kernel##{method}"; ch = STDIN.getc; break if (ch.chr == 'q') end

Once you enter this just keep hit enter until you want to quit, at that point hit 'q' and enter.

Still some kinks to be worked out but it is a start

Update:
Found this interesting link: http://www.rubygarden.org/ruby?Irb/TipsAndTricks on http://www.rubyweeklynews.org/

Sunday, February 19, 2006

vim extracting first column (space delimited)

Just figured out how to extract a single (first) column from a file containing text

:%s/^\(\w\+\)\.\*/\1/g

I am sure there is a better way to do this but this is best I can get for now. I don't like the excessive escaping vim requires in regex.

PS: Just figured out that you have to have:

:set nomagic

for the above subsitution to work.

Friday, February 10, 2006

vimrc update - showmatch

" rediscovered showmatch
set showmatch
" this would show you the matching paren or brace