Developer Tips: How To Show Line Number in vi / vim & nano

By Angsuman Chakraborty, Gaea News Network
Wednesday, November 5, 2008

vi / vim as well as nano are the most popular editors on Unix / Linux / Solaris and for hardcode Mac OSX users too. For developing / debugging we need line numbers. A way to get them to display line numbers doesn’t jump out easily from their big documentation, so here are my simple tips on how you can display line numbers in vi / vim and nano editors.

How to display line number in vi / vim

:set number

How to stop displaying line number in vi / vim

:set nonumber

How to display line numbers in nano

Start nano with -c option:

nano -c

Frankly I prefer line number display like vi or jEdit. Unfortunately -c is as best as it gets on nano.

For hardcode developers on Linux who doesn’t prefer to use fat resource hogging Eclipse or NetBeans, I recommend jEdit editor. Try it and you will start loving it.

Discussion

Aaron Sinclair
November 11, 2009: 6:04 pm

I don’t like NetBeans or Eclipse for that reason - yes they’re powerful tools but they’re slower than Visual Studio!! Not good.

For all coding I use Geany, because it has intellisense for most languages (php, c, makefiles & bash are the ones i use most). The only pain in the ass about Geany is that the file tree only shows you the files that are open, not a tree of the filesystem, so you really have to open every file you wanna edit. Still, I’d rather that than wait for my IDE to catch up with my typing :)

Bluefish is lightweight and fast, but its syntax highlighting, switching between documents & tab functionality are annoying. I used this before I found Geany.

jEdit is nice, and I do use that for Java from time to time. Otherwise I stick with Geany.

November 9, 2008: 11:20 am

In vi we can use “:set nu” for short.

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :