nano
has always been my favorite. it's not too fancy to be annoying and huge, so you can comfortably run it on servers. it's not too low-level so there's not a very steep learning curve (comparing to vi/m
).
it's often pre-installed on servers too so it doesn't need installation, just write nano
into the command line and there you go.
However, it's still kind of hard to work with, and get around, since it's a cli program nonetheless. some of the troubles I find myself struggling with when working with nano
are (could be terminal related, or nano related):
word-wrap: I paste a long line and I see 4 characters and it takes me several seconds to have an idea about what's happened
no line numbers: a disadvantage for obvious reasons
weird shortcuts:
ctrl+k
cuts a line,ctrl+u
pastes it,alt+delete
removes the line. not very common shortcuts, for me at least.does not ask for password on save: you need to remember and
sudo nano
the file when opening it. if you onlynano
, it won't ask you for a password before writing. it simply prompts that it's a protected file and you can't save your edits. in these cases, I just copy what I've written, paste it elsewhere,sudo nano
, paste and then save. pretty annoying.
On the other hand, as mentioned before, it's very handy, versatile and fun to work with as well. so it's worth to take the extra mile and modify it based on my daily use.
two of the most useful "fixes" that I use are:
-
/
and enter a number: go to line - easy to use text replace (
ctrl+h
in vscode/etc.):ctrl+/
and enter a text to replace. enter the replacement text, and nano shows you the occurrences and confirm whichever you like to replace. -
esc+shift+4
toggles soft-wrapping (google if you don't what it is. nano supports two types of wrapping.) 3.1. toggle hard-wrap withesc+l
-
alt+shit+3
to toggle line numbers
you can also start nano
with various options to have features on or off. for example nano -Y
enables syntax highlighting or nano -T
sets the tab size. read more here or just man nano
to check them out.
finally you can write you own ~/.nanorc
and write you desired customizations there. options like set linenumbers
and set autoindent
are available. check out this article for more
reminds one of vi
's command-mode, huh...
Top comments (0)