Is there a way to turn on line numbering for nano?
The only thing coming close to what you want is option to display your current cursor position. You activate it by using
--const (manpage: Constantly show the cursor position) option or by pressing AltC on an open text file.
set linenumbers in
/etc/nanorc works for me in
nano version 2.7.1.
It also can be activated with
--linenumbers on the command line.
Toggle the line numbers from within nano with:
M-# in my case Alt+Shift+3.
This was added on the 20th of October and was documented on the 22nd of October and has yet to make it into a release so compile it from source like so:
git clone git://git.savannah.gnu.org/nano.git;cd nano;./autogen.sh;./configure;sudo make install
Then add the following to your .nanorc:
You can use ^# to turn line numbers on and off from within Nano. It's probably a bit buggy since it's recent and hasn't been tested by many people.
Nano is by design a very simple editor with few features. If you start wishing for anything beyond basic edition, nano isn't the right tool. Emacs is a very powerful editor; to switch line numbers on, type
M-x linum-mode. If Emacs scares you and you want a text mode editor, consider Joe, where line numbers are switched on with the
Alternative, a quick alias in .bashrc:
echo "alias nano='nano -c -l'" >> ~/.bashrc && source ~/.bashrc && reset
Forcing the syntax seems mandatory for hashbang scripts, so to force a particular highlighting:
echo "alias nano='nano --syntax=php -c -l'" >> ~/.bashrc && source ~/.bashrc && reset