« BackCustomize Nano Text Editorshafi.ddns.netSubmitted by shafiemoji 10 days ago
  • p4bl0 3 hours ago

    I tried a long time ago [1,2] to initiate this discussion on Nano here. I'm glad it's happening :).

    [1] https://news.ycombinator.com/item?id=41289141

    [2] https://news.ycombinator.com/item?id=41289773

    • its_notjack 5 hours ago

      I must have used nano for years at this point, and I'm shocked to find out how customisable nano actually is! I tend to use micro[0] on most of my systems now just because it comes with really lovely defaults and keybindings that are a bit more familiar, but this might make me take a second look at nano in future.

      [0] https://micro-editor.github.io/

      • tpoacher 3 hours ago

        It's not just customisable, it's also insanely scriptable. Any action that you can do in nano itself corresponds to a command, and you can create "string macros" that you can bind to key combinations. Additionally it can execute external commands on any nano buffer and return the result. Combining the two is very powerful.

        E.g. I have a configuration which allows me to use nano while editing pdf side-by-side, and be able to click on the pdf and land in the correct line in nano, and vice-versa. (and obviously compiling the latex document itself happens via a custom keystroke).

        • digisign 3 hours ago

          Before I used micro & ne I used nano, and configured the keybindings to work in the CUA style. I still have the dot files, didn't delete them, but they rarely get used anymore.

          I think they recently added Ctrl+S to save by default, even if unconfigured, woohoo.

          • flkiwi 4 hours ago

            Same same. Never even occurred to me to look. That's the risk of a (successful) low-friction product though: you use it in quick bursts where the tool is necessary but largely invisible, and you never invest in learning more about it because it works so well with the defaults. There's probably a profound strategic insight buried in there somewhere.

          • chawyehsu 4 hours ago

            It seems few people are aware of how customizable nano actually is. Usually, they use nano with the default preset for quick bootstrapping tasks and then switch to vim without hesitation. While vim/neovim are certainly very powerful, nano remains my go-to editor for many quick terminal operations. I've customized it quite a bit[1], especially the key bindings, though the defaults are already excellent.

            [1]: https://github.com/chawyehsu/dotfiles/blob/main/.config/nano...

            • davidcollantes 2 hours ago

              I would dearly love it if you could comment a little bit more that nanorc. I am going to “steal” some of it, for sure. Thank you much for sharing it!

            • sanex 5 hours ago

              Nano is my go-to whenever doing something quick in the terminal. It's quick, I don't need to learn how to use it, and now it's going to be slightly more convenient. I had no idea it had these options. Thank you!

              • bigstrat2003 2 hours ago

                Nano is by far the best terminal editor imo. The only situation where I'm using a terminal editor is when I'm ssh'ed into a server, and I need to quick edit a file (for serious code writing a GUI editor is far more capable). Nano is ideal for that use case: you get in, it tells you what all the relevant keybinds are right on the screen, and you get out without any fuss.

              • thejbo 2 hours ago

                I actually prefer 'constantshow' instead of 'linenumbers'. That way if you want to select/copy some text from the terminal it doesn't include those line numbers.

                • notepad0x90 2 hours ago

                  My struggle is that I work on lots of systems, sometimes ephemeral/temporary systems. There is no easy way to "sync" customizations, so I adapt to defaults.

                  Even basic things like how shell history is managed is very annoying to configure every single time. if only it was as simple as cloning your private github repo to ~/.config.

                  • mikkupikku 2 hours ago

                    I use a very customized emacs/evil setup, and before that a very customized vim/neovim setup, but I've never had trouble jumping onto systems where only plain Jane vi is available. I think it's because of the color scheme, or lack thereof, that I don't have any problem automatically switching. If I don't see my color scheme, by fingers just automatically use vi compatible bindings and I don't find myself expecting my other customizations to be present.

                    Maybe not everybody can switch so easily, but I think it's worth trying out. (One change that absolutely does trip me up is capslock->control. If I try using somebody else's computer, I constantly enable capslock by accident.)

                    • wahlis an hour ago

                      Check out Chezmoi (https://chezmoi.io). They even offer a nice comparison table for alternatives.

                    • qsort 5 hours ago
                    • jasperry 5 hours ago

                      The line numbers and position bar are some real quality-of-life enhancements!

                      I don't regularly use nano anymore, but I have often thought that more programs should imitate the way it shows the command shortcuts on-screen as a kind of instant tutorial. I remember my physics major friends in college thinking it was pure snobbery for vi not to do that by default. Back then we were dialing in to an HP-UX server and using pico, which nano is an open-source clone of. For those who aren't aware, pico was originally the editor component of the Pine email client.

                      • mystifyingpoi 5 hours ago

                        > physics major friends in college thinking it was pure snobbery for vi

                        I don't think it is snobbery, that approach would clutter the entire screen. Basically every single small/capital letter and symbol has a function in vim.

                        • jasperry 4 hours ago

                          To its credit, vim does show a help text with :q on it if you start it with no file. Back then, it was just vi opening to a blank screen.

                          • qsort 4 hours ago

                            set shortmess+=I

                        • ziotom78 4 hours ago

                          Absolutely, the shortcut help is so useful!

                          I believe that Nano and Pico copied it from Wordstar.

                        • tracker1 2 hours ago

                          Also worth a look, if you want more TUI..

                          https://github.com/microsoft/edit

                          • SilentM68 2 hours ago

                            Thank you, looking for way to set tab to 2 spaces for eons without success! Very helpful :)

                            • jdorfman 4 hours ago

                              I’ve been using nano as my default bash profile editor for over 15 years. It’s also great for quick updates for other config files.

                              Definitely going to enable mouse support. Didn’t know that was possible.

                              • reaperducer 36 minutes ago

                                Note that for the last few versions of macOS, "nano" is symlinked to pico.

                                • positron26 4 hours ago

                                  Right after the nano maintainer got bullied out by the FSF, I noticed two bindings got their defaults changed. They never change. I almost feel like it was graffiti, a flex against the old maintainer, a retribution for not doing whatever the FSF wanted.

                                  Since forever, GNU readline programs and nano had identical bindings. I'm fast moving around the CLI because I'm fast at nano. Emacs has the same defaults. What sane organization only abandons their own defaults and prioritizes that work after pushing the existing maintainer out (or irritating them enough to accomplish this)?

                                  • kstrauser 44 minutes ago

                                    Which bindings changed?

                                  • iLoveOncall 5 hours ago

                                    If you're on Mac and can't get .nanorc to work, check out https://stackoverflow.com/a/73373788/3876196

                                    It's also possible that you simply do NOT have nano installed at all, and just have the simlink from nano to pico by default. That was my case. In this situation, install nano and it should work.

                                    • Ekaros 4 hours ago

                                      Did you know Nano supports mouse? Alt+M... Not that I use that much, but it is fun fact.

                                      • p4bl0 3 hours ago

                                        This is the very first item in the linked blog post.

                                      • threatofrain 4 hours ago

                                        What about LSP?

                                        • akatsutki 3 hours ago

                                          better than vim

                                          • SilentM68 2 hours ago

                                            I would say that every tool has its good and bad.

                                            A tool is only as good as its ease of use and clarity of its documentation, imho.

                                            • bigstrat2003 an hour ago

                                              Wouldn't that make vi(m) just about the worst tool to exist? There's a reason that the "how do I exit vim" jokes exist, it's because the UI is awful unless you already know how to use it.

                                            • bilekas 3 hours ago

                                              Don't quite agree, it's simply a different tool, that's like saying notepad is better than vscode. They're both different purpose builds.

                                              • qsort 3 hours ago

                                                no