Nano - jump to end of file

Open the file with nano file.txt.

Now type Ctrl + _ and then Ctrl + V


Many editors support the +NNN option on the command line to jump directly to line NNN. Luckily for you, nano appears to jump to the end if the line number given is past the end of file, so you could use something like:

nano +999999 file

That also works in joe, but not in, e.g. less or VIM, they complain about going past EOF. (at least the ones on my system. less +G file and vi +$ file work in those.)

Of course something like $EDITOR +$(wc -l file) file would probably work in most editors, but that's a bit silly and involves reading the file twice.


From the built-in Nano help (^G):

M-\   (^Home)   Go to the first line of the file
M-/   (^End)    Go to the last line of the file

So, press Alt+\ to go to the first line or press Alt+/ to go to the last line.

  • This would be the equivalent of gg (start) or G (end) in vim.
  • This also states that Ctrl+Home or Ctrl+End should work, but that's never worked for me they seem to work natively on console/desktop but not via SSH using PuTTY.
  • The way I remember this is that / is near the bottom of the keyboard and \ is near the top.

If you want a command, you could write a function in your .bashrc or .bash_aliases to use the line count from wc:

function nano-end {
    # if the file exists, jump to the end
    # otherwise, just open an empty nano
    [ -f "$1" ] && nano +$(wc -l "$1") || nano
}

Now just type nano-end filename to open the file to its last line!

Tags:

Nano