Although I'm a big fan of the one True Editor , I frequently use a version of vi for editing small files. The vi editor that comes with Fedora is an "enhanced" version of vim. (Don't worry about what the acronyms mean, I gave up a long time ago.) vim has some useful features that go above and beyond vi. For example, vim supports context sensitive syntax highlighting. Thus, if I edit the prototype Fortran program, using
$ vi hello.f
My xterm window comes up looking like this:
program hello write(*,*) 'Hello World!' stop ' Goodbye' end
with keywords highlighted. This behavior is default in Fedora, but you can select it by creating (or editing) the file .vimrc in your home directory to include the line
syntax on
This is a good thing. However, there's also an annoying thing in the default Fedora Core setup of vim. I've resently been editing a file with a lot of numbers which include exponents. One way to search for these numbers is to search for the exponent symbol, "E". In that case vim gives you something like this:
0.102332848348E+01 0.264530189469E+00 -0.403958800217E+01 0.648883753760E+02 -0.182200684198E+03 0.881612131102E+00 -0.106720017820E+01 -0.117890618863E+01 0.286257745413E+02 0.871945343502E-02 -0.214399839048E-01 0.295824532165E+01 -0.272516080977E+01
Actually, it's more annoying than that. The E is actually highlighted with a yellow background, but I didn't want to figure out how to show that right now.
This annoying behavior can be corrected by adding:
set nohlsearch
to the .vimrc file.
One more thing: I usually prefer case-insensitive searches, so that searching for "bob" matches "Bob" and "BOB" as well. That requires the line:
set ignorecase
There's a lot more you can do with .vimrc. Here's a sample. I'm satisfied with these simple tweaks, however.
2 comments:
How weird. I was just about to post the SAME THING over at falafel sex. Spooky.
Hey, we have to post a Linux tip once in awhile...
Post a Comment