Sunday, February 19, 2006

Vi and Bash Shell Scripting

VI editor, while it's trivial to new users, it is always get me excited. I had just learned that there are two ways to get to the last part or end of the file easily with vi, one is using vi mode, you just need to press G key, another one would be using the command mode which is preceded with :, you can just type $ to go to the last line of the file. It is always fun to discover new tricks of using vi even though I have been using it for so long, in order to be proficient enough in using vi, I force myself to use the build in commands more often however there are still many uncovered or unknown tricks that I should try to figure out and learn, that's the interesting part of vi, you will never have enough.

Through my journey of bash shell scripting, I have never done this before to check my shell scripting syntax error until recently, if you want to check it if it's syntax is correct, for example your shell script's name is test, you can just run

shell>bash -n test

Then it will show the error if there's any or else just success without error.

Cheers :]

4 comments:

Anonymous said...

try 'vimtutor' command. it's very useful tutorial

Code Pimp said...

To go to the beginning of the file you
can use :1 (or any line number).
To go to the end of the current line $
and beginning of the current line ^.

regards
-rao-

geek00L said...

Thanks for the tips :]

mysurface said...

haha, you can't use gedit durin ssh, vi is the best choice.

http://my.opera.com/mysurface/blog/index.dml?tag=vi
vi support tab too, fake tab =P