Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
GNU nano 2.9.0 (nano-editor.org)
89 points by protomyth on Nov 18, 2017 | hide | past | favorite | 59 comments


So I was looking through the sources of nano and I seemed to have discovered a previously-unknown (at least based on a quick search) easter egg.

First modify the buffer somehow. It really doesn't matter if you just type in "test"

Hit ^X to exit nano. When it asks you if you want to save the buffer hit Y

Save the file as "zzy" and press ENTER to trigger the Easter egg

^X+Y+zzy is likely a reference to xyzzy, a cheat code originally used in Colossal Cave Adventure[1]

1: https://en.wikipedia.org/wiki/Xyzzy_%28computing%29?wprov=sf...


Uh, really cool! Spoiler recording https://asciinema.org/a/aWR9hmT5CuEMbxfUUYEx4ATS4

PS: You can quit this text-animation by any keypress and then store the actual file zzy, if required.


'xyzzy' was also what enabled cheat-mode in Road Rash[1]. Ah.. good 'ol days..

1: https://en.wikipedia.org/wiki/Road_Rash


"xyzzy" also made an appearance in the Infocom games Enchanter and/or Wishbringer.


I used nano for years until I was forced to use vi when I was doing a FreeBSD install just for fun on my Cr-48. Once vim clicked for me I never went back. At the same time, Nano was invaluable as an easy to use terminal editor as a beginner. It was a huge help when I was learning to use Linux.


It's weird how comfortable familiarity is. I approached vim similarly, I first used pico/nano to modify files here and there but mostly used GUI IDEs or editors. Switched to vim and been using it for 10+ years.

Every once in awhile I encounter an OS where visudo or something else defaults to nano and I feel so awkward just trying to make simple changes and save the file.


The huge advantage of nano over vi in that scenario, is that nano 1) uses the conventional [i.e. as used by every editor other than vi] arrow key cursor movement and typing behavior without the need to toggle any modes etc, and 2) displays the shortcuts you need for anything else on the screen by default - things like saving, cutting/pasting, searching, and, oh yes, quitting.

So, while it might not be optimal for vi users, it is at least accessible to pretty much everyone regardless of their background. Whereas for someone not familiar to vi, getting thrown into the dreaded : prompt can be a frustrating nightmare.


The arrow keys work in vim too (I don't know about plain vi).


If vim is available, then you can do

    VISUAL=vim visudo
or

    EDITOR=vim visudo
According to the man page, VISUAL is preferred.


Nano does what is does very well. Want to quickly modify some some file it is the tool of choice in the way a hammer is the tool to drive a nail. Right tool for the right job.


I dislike using nano because of this: open a narrow terminal and open a file with lines long enough to wrap. Insert a character on the wrapping line. nano will insert a line break, hard-wrapping the line. Probably you can customize this, but I don't want to have to customize an editor so it doesn't break my files.


Learning some basics of vi(m) and using some plugins to enhance it can improve your productivity compared to Nano on the long term (e.g. syntax highlighting with color palettes, linter, tmux support, and what not).

That said, I prefer Sublime/Vim (Sublime also has these plugins), but Nano is a decent alternative and resembles the first text editor I ever used. Sublime is lightning fast for me, but it isn't open source.

To break the habit of firing up Nano I symlinked it from /usr/local/bin/nano to /usr/bin/vim. If you use Vim regularly, the shortcuts will stick in your head whereas if you resort to Nano you won't memorise them for long. If I ever still require Nano then I can execute it by executing /usr/bin/nano

For people on a Mac, I can recommend the app CheatSheet [1] available in Homebrew. If you're lost in an application holding Command (⌘) for a few sec will represent you with a cheatsheet of shortcuts. It won't work with CLI apps though.

[1] https://www.cheatsheetapp.com/CheatSheet/


It depends on your experience, familiarity with the tools, and nature of the change. For example, you might think a single character change would be faster in nano, but that’s not necessarily the case. By the time you’ve moved the cursor using the cursor keys, deleted the old character, and typed the new one, an experienced vi user could well have made the same change faster.

We can all think of far more complicated changes that are considerable more efficient in vi. So the question is 'given perfect familiarity with the tools, and all else being equal, what kind of changes, if any, are more suitable for nano rather than vi.

None of that is to say that nano doesn’t have a place.


As a beginner it was my editor of choice, as most of us it seems. But the GUI made me want a better editor, with the same capabilities of a GUI editor.

So, when i heard of micro i switched immediately, I just find the default copy/cut/paste and the mouse functionalities very comfortable.


Also known as the "record macros in Nano" release.


remacs is already taken


I love that there are people working on nano and the nano-styled website. Also excellent release notes. I just wish that nano in Bash for Windows was more recent than version 2.5.3 so I could try out the new features. ;-)


Some of my favorite memories are of learning C++ using the nano editor. I ended up a C# dev, put I still put nano on all my Windows boxes. It can be quite handy.


I used nano for quick edits for years with modified sane CUA keybindings. It was ok. Recently found the "micro" editor here and liking it more.


The only feature I miss is Undo.


Alt-U or option-U


Thank you so much! Is that a new feature?


echo "export EDITOR=nano" >> ~/.bashrc


    sed -i s,^EDITOR=nano$,EDITOR=vim ~/.bashrc


sed: -e expression #1, char 26: unterminated `s' command


Good catch. Forgot a comma at the end.


Is anyone using this thing?


Yep, all the time. It's perfect for quick, easy edits and available everywhere. I love the simplicity:

  CTRL-X [y/n/c];
  ALT-A and CTRL-K
  CTRL-W and CTRL-R
...pretty much covers 99.9% of the commands I ever use in it.


I use nano all the time.

If I need to do quick editing, nano is perfect. If I need to do anything more complex, I'd use rmate[1] + rsub[2] with sublime text.

1: https://github.com/aurora/rmate 2: https://github.com/henrikpersson/rsub


This is really cool. I'm sure something similar exists (or could exist) for Emacs and Vim, right?


Emacs has Tramp built-in to allow editing remote files: https://www.gnu.org/software/tramp/


Every time I'm sysadminning some Linux server or another. It's everywhere and does the job well enough without me having to learn vim :-D

I also often use it to look inside random files on my Mac that won't open anywhere else (e.g. .xml, .json, files without extension names).


I think vi is probably more ubiquitous though, especially since it’s included in busybox which powers almost all imbedded Linux hosts. Still a good idea to learn a little vim


>I think vi is probably more ubiquitous though,

As I mentioned below, While it may be more ubiquitous, vi isn't present on Debian's live cd, while nano is.


That's odd, considering vi is part of the POSIX specification and all. Many distributions won't come with full vim by default, but most do install a trimmed version of it to fulfil the role of vi.


I know how to get out of it, and also how to get into insert mode and make the most elementary of changes. I tried going further but it just doesn't mesh with whatever form of memory I have installed in my brain :-D


All I care to know of vim is how to exit it...


Yes! It's a simple and easy editor to use. It's one thing I really miss when I use a non GNU based NIX that doesn't come with it pre-installed.

It does everything you need it to do for quick configuration edits, and doesn't get in your way.

Have you ever tried to use the equivalent 'ee' editor that comes installed on other NIX? It's painful.


I helped my nephew (a teenager) with a coding project he was working on recently, and nano is what he was using when he made edits on the server. So, yes. People are still using it, and new people are picking it up because it's an easy editor that works anywhere. It seems like you'd want to learn something a little more powerful (like, say, vim) if you work on the command line via a remote connection frequently, but for every once in a while, you can't beat nano for ease of use. There's really no learning curve to do basic edits. (Meanwhile, some poor soul is struggling this very moment to figure out how to exit vim.)


All the time.

I could use vi/vim, but I'm just too lazy to teach myself or use "vimtutor" to actually learn how to use it. I know just enough to open/modify/save/exit, which I think is just good enough for a quick edits.


Yes. It's great for avoiding vi.


nano, or the new feature? I use nano all the time.


I use nano all the time. It's on most platforms and it's quick to bring up for some basic editing.

Over the last 20 years of using Linux I haven't learned vi and emacs above basic editing and saving files.


Nano. Just curious :)


Why do you use nano?


It's simple, it's on every platform I ever SSH into, and it gets the job done quickly?


Exactly this reason. You just know it will always be installed.

And I still type "pico".


(Assuming you're using Bash as shell)

If you want to get rid of this habit put this in /usr/local/bin/pico.sh or ~/bin/pico.sh

#!/bin/bash echo "Type nano instead of pico..." sleep 5 nano $*

Put in ~/.bashrc alias pico=~/bin/pico.sh (or /usr/local/bin/pico.sh)

Make sure to chmod +x the shell script.

You can also simply call it pico instead of pico.sh; then you won't have to use the ~/.bashrc addition.


pico is harder & slower for me to type for some reason! not sure why.


It's a simple text editor that's available out of the box in most Unix-like distros these days. So kinda like vi, except I know how to use it (and if I ever forget, it lists all shortcuts on the bottom of the screen anyway).


Actually, the Debian install cd doesn't have vi but does have nano, and vim (and neovim) is larger than nano.


The size argument alone cannot explain nano > vi preferences in d-i.

vim-tiny and nano sizes are nearly the same; nvi is smaller; I'm pretty sure the "vi" applet in busybox would be much smaller.


That actually seems a bit odd; it's not like vi is big.


I use it in a pinch fairly constantly. Despite being a heavily customized Emacs user all the rest of the time. Mostly when I'm already scouring around the shell poking at files or need to make a simple new one (like a .gitignore) and I don't want/need to perturb whatever else I'm doing in Emacs.


If you start Emacs server as a daemon, you can use it pretty much like you'd use nano/vi/vim in the terminal, without disturbing anything. With an Emacs server running, for me, it loads faster than vim. I have a bash function along the lines of

    et() {
        emacsclient -tty --alternate-editor '' "$@"
    }
.. for using Emacs in the terminal a-la vim/nano. When you close the file you opened, you'll be right back where you left-off in the shell. I still tend to use a long-running GUI instance as you describe, but for jumping into config files from a terminal to edit a line or two, it's great.


This post makes me so glad to have been forced into vi all those years ago.

Its everywhere, its quick, and unless you've done some pretty nutty stuff in your configs, basic usage is the same between a heavily customized vi and the vi you find bundled with every is bundled windows and gentoo. (Not to disparage any preference for emacs; it just seems a bit much to have to fall back to an entirely different editor seems a bit much)


I don't _have_ to "fallback". I just choose not to interrupt the extremely rich development environment I have setup in Emacs and my projectile projects by bringing in random other files/buffers.

It's akin to the same justification for why I wouldn't bother opening a random tiny file in Xcode or IntelliJ IDEA.

I don't use Emacs as just a simple text editor. I can probably count the times I've typed `emacs some/file/path.whatever` into the shell on one hand.


Nano? Yes.


nayes




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: