How to show line numbering in nano when opening a file
Is there a way to tell nano to automatically show line numbering each time I open a file?
CTRL+3 then SHIFT+3 will show line numbers CTRL+3 then SHIFT+3 will hide the line numbers
The keyboard combination to display the current line number whilst you are using nano is CTRL+C.
Alternatively, to display the line & column number position you could just use the
-cparameter when launching nano i.e:
nano -c [filename]
To make this permanent,
nanouses a configuration in your home folder
Thus to display line numbers always when using nano...
(don't worry if its empty - this file doesn't exist by default)
N.B. the deprecated syntax
set constis shown in the animation
Since you are using line numbers remember you can use ALT+G to jump to a specific line number.
If you are in a tty, an alternative to CTRL+C is F11 and an alternative to ALT+G is F13 (which doesn't exist on my keyboard) or Ctrl+_ (Ctrl+Shift+-).
Note that `-c` might not behave the way people are expecting. It won't prefix each line with the number (like `less -N`), it just makes the status box at the bottom of the screen permanent.
I agree with @IanDunn, this is the wrong answer. Add `set linenumbers` instead (only works in recent versions).
Accidentally found nice shortcut: Alt+#, which in some keyboard layouts can be done with Alt+Shift+3.
Add `set linenumbers` to `.nanorc` to make it permanent. If the shortcut doesn't work try `Modifier key + #`.
@Gregor Godier Thanks alot this is great with `set linenumbers` in nanorc
New versions can be downloaded from here: https://www.nano-editor.org/download.php
Stumbled across this keyboard shortcut when making a typo and was pleasantly surprised :D
Compile Nano from source:
git clone git://git.savannah.gnu.org/nano.git;cd nano;./autogen.sh;./configure;sudo make install
Then add the following to your
You can use Meta+# to turn line numbers on and off from within Nano.
Actually like that. See you did 2 commits, was the 2nd one, (size increase..) because of the 1st one?
I do like this better than set const or now set constantshow so took the liberty to put in a ppa using 2.6.2 release for ubuntu 16.04. If you wish me to credit or whatever differently let me know.. https://launchpad.net/~mc3man/+archive/ubuntu/nano-lined
Oh cool, thanks for that! I don't mind getting or not getting credited, it just makes me happy to see people finding something I did useful, besides most of the code there belongs to the maintainers of nano, not me.
Sweet. I've submitted a request to merge this into nano at nano's savannah page: https://savannah.gnu.org/bugs/index.php?49217
Don't worry, I'm already working with Benno on merging this: https://lists.gnu.org/archive/html/nano-devel/2016-09/msg00061.html
This has been merged upstream and will be available in the next release of Nano https://lists.gnu.org/archive/html/nano-devel/2016-10/msg00074.html
this implies that you have to compile from source to set `set linenumbers`
nano -c filenamedoes not work, use
nano filenamethen Ctrl +_. It will ask you for the line number to go to.
If you have already opened the file with nano you press
(not simultaneusly, press control and w, then without letting go control and letting go w, press t)
This command will require column and line, you enter them this way:
and you will end up in line 10 character 23.
If you are at the top of the file and you only want to find the line:
Ctrl+w+t and then 10
If you are at a acertain line and you want to find the column:
Ctrl+w+t and then ,23
If you haven't opened the file yet, you can do this:
nano +10,23 file (enter)
and the file will open with cursor in the line 10, chanracter 23, so you can try also:
nano +10 file (enter)
nano +,23 file (enter)(Note that this will send you to the character 23 of the first line only)
This may be the correct way to find the line in the terminal however it does not answer the question on how to make it automatically show on opening.
This is the only thing that worked for me to find a line number....none of the above worked in my instance of nano.