Say Hello to My Little Friend

With my recent Ruby on Rails project, I've done more on the linux command line than with PHP development. For example, you run a ruby script to generate a code skeleton for scaffolding, controllers, models and views. Stuck with a windows environment for my development on the go (I commute 3 hours a day, in which time I'm hacking away on my laptop, which I am doing right now. In Vim.)

I reached into the crevices of my mind to remember how to create Batch files. Yes, that’s right, batch files. Yes, Good Old MS-DOS. I still have a DOS For Dummies book (aquired long after DOS was out, I just couldn't resist the nostalgia and I think it only cost 2 bucks). I created a batch file for ls, mv and cp. Not rocket science I know and although I had installed cygwin I was not particularly keen on using that all the time, I also had found some exe's that imitate many of the unix commands...but I didn't need all that jazz. I just wanted a ls, mv and cp command!

As my project progressed, I was doing more and more on the server side, tweaking here and there. Man, I said… I need to get VI for windows I knew it existed, I had it many years ago. Actually, I think it was only a dos version that I had. I searched and discovered GVIM. And it’s pretty darn nice!

It loads darn fast! .. I use it almost exclusively for any text file now. Rightclick - Open in GVim, BAM. Previously I had used notepad, but if the file had been saved in unix format, of course you have those funny little boxes and its all wonky. At which time I would say grrrrrrrr and sputter and open in either JEdit (which is slooow) or Ultra-Edit (not too bad). I am happy now.

Once I'm on *nix for awhile and using VI/VIM I am used to using jkl; to get around. You should see me working in word and typing those letters. DOH. Then, on the other hand... after spending hours on a windows app with ctrl-s to save.. I would do that in vim. DOH. To me, it seemed like it locked my terminal session and I would always abandon it and start a new one. Peter at Push.cx met me for lunch one day and I was sputtering about that. He explained why ctrl-s would "seem" to lock the terminal and how to make it stop. I then programmed ctrl-s to do a :w command and wrote about it on my blog. Sweet.

Also I mentioned to Peter that on my RailsPlayground.com when I edited a file in vi it was in color! and my old hosting company did not..and I didn't understand why. I was not born with the knowledge of terminals and ansi colors like everybody else, I guess. He said to turn syntax coloring on using "syn on" ... I did.. it works. Later that day I found there was different color schemes you could use. Right now my favorite is "murphy" ... though its kinda of weird, its on a black background. I am not fond of reading text on a black background, but it seems to work for me right now in a terminal mode.

Little did I know that VIM had a split screen. Whoa you say. Me too. You just do :split and to switch back and forth, you use ctrl-w-
However, many of these cool commands are on the GUI menu of the windows version of ViM. Including, mouse drag copy and paste, which I find is easier than trying to count the number of lines to yank. Also moving around with the mouse and scroll wheel is very nice. And if that wasn't enough, it has a menu and icons bar. Which great for beginners who don't know all the commands or if you think you work faster with a mouse. Also has a file open dialog box.

I feel like I only know about 1% of how to use vim, but I learn more about it everytime I use it. Any vim tips you all would like to share?

Links:

Wait a sec...

Right now my favorite is "murphy" ... though its kinda of weird, its on a black background. I am not fond of reading text on a black background, but it seems to work for me right now in a terminal mode.

Is that a reference at me? ;)

not really

I thought if I said I liked murphy, which is a black background.. you'd say, oh then why don't you like black background for codesnipers. So I was attempting to clarify that it works for me in terminal. I dunno, I'm a girl, I'm allowed to be goofy!

I guess, I saw the cool ruby kids with their black background and brightly colored syntax coloring in demos and screen shots, I was trying to be cool also.

I also have my font size up to 14px and lots of different colors.

Sold on 'evening'

I'm sold on using the evening theme, it's just works better for me. The background is dark grey and colors contrast with it nicely.

I'm using ViM for years now and still don't know all of its secrets. Check out regular expression search and replace with its various options. It comes in handy many times.

Awesome ....

Thanks.. thats awesome.. :)

Thanks guys

any example of when i would want to do this one, maybe sort or cut??

:% !
lets you filter the entire buffer through of your choice

Sort

Yes, :%!sort would be a fine usage, though I rarely edit data files that need it.

Two meta-tip for ViM:
1. Read "Seven habits of effective text editing"
2. Track the ViM tips on http://www.vim.org/tips/index.php

Found some handy tips

Today I was editing in VIM and thought, there's gotta be a way to transpose two letters .. like teh

I found it, in this document:
http://www.oualline.com/vim-cook.html

its just

xp

Also learned from my friend Brian how to use visual to add comments to a block.
Ctrl-V to start visual block, use movement keys to select, then capital I then # .. and it inserts a # at beginning of each line.

:) sweet.