News for hackers. Stuff that matters.
Re:micro – A Modern Alternative to nano by swozey on Friday August 18, 2023 @09:21AM (#37175246)
I had no idea people used nano as their main code editor. I use it on any nix server I'm working on and have probably used it tens of thousands of times.

I'd been a linux/bsd engineer forever and I worked at some places where they refused to install nano on servers. There are some greybeard linux admins who absolutely refuse to let someone use anything other than vi. I never got that. It's a 20MB package and not exactly much of an attack vector.

Re:micro – A Modern Alternative to nano by vdfs on Friday August 18, 2023 @09:33AM (#37175395)
20MB? just check nano executable and it's 277KB, the whole .deb packages is 860 kB

https://packages.ubuntu.com/jammy/nano

Re:micro – A Modern Alternative to nano by swozey on Friday August 18, 2023 @09:38AM (#37175459)
I thought 20MB was a lot.

I did "nano debian size" on google and one of them mentions - The Nano package contains a small, simple text editor which aims to replace Pico, ... Download size: 1.5 MB. Estimated disk space required: 20 MB.

https://www.linuxfromscratch.org/blfs/view/svn/postlfs/nano....

Re:micro – A Modern Alternative to nano by vdfs on Friday August 18, 2023 @09:40AM (#37175487)
That's not true for Debian either:

https://packages.debian.org/bullseye/nano

But building from source is a different story, if you stripe and clean build dir it will be similar to prebuilt .deb

Re:micro – A Modern Alternative to nano by xyproto on Friday August 18, 2023 @09:37AM (#37175443)
gccgo + upx can reduce the size of Go executables considerably, usually below 1M.
Re:micro – A Modern Alternative to nano by makapuf on Friday August 18, 2023 @09:54AM (#37175646)
note that it does not reduce the memory size once loaded (and even prevents sharing pages when several instances are run since memory is written when decompressed, not read as a program binary is)
Re:micro – A Modern Alternative to nano by londons_explore on Friday August 18, 2023 @10:29AM (#37176142)
> even prevents sharing pages when several instances are run since memory is written when decompressed, not read as a program binary

A shame the linux kernel doesn't have some way for packers to say "I am a packer, I run with access to nothing except the binary, therefore run me with no permissions and then share the pages I make with any user that executes me. If you like, you can even delete my output and reunpack me on-demand"

Re:micro – A Modern Alternative to nano by xyproto on Friday August 18, 2023 @03:49PM (#37181142)
That would be something!
Re:micro – A Modern Alternative to nano by kunwon1 on Friday August 18, 2023 @09:35AM (#37175419)
I was a nano user, and this happened to me. I got greybearded into vim, and now I only touch nano when I need to de-crappify a vimrc file

I was mad about it at the time, but now I'm happy I made the change. Vim or vi is everywhere, including on the switches and routers I work on. Nano is not everywhere, nor can it easily be put everywhere.

If I weren't regularly SSHing into decrepit or resource-constrained hardware, I would likely see less of a benefit

Re:micro – A Modern Alternative to nano by swozey on Friday August 18, 2023 @09:54AM (#37175638)
I don't know why, probably terrible memory, but I have practically a mental block when it comes to keyboard shortcuts. I've tried spacevim and a few other bundled vims before but I have such a hard time doing anything other than moving the cursor and :wq! type of stuff.

Like.. this is wild https://vim.rtorr.com/

And now I'm hooked on a horrible amount of vscode plugins.

Re:micro – A Modern Alternative to nano by linuxdude314 on Friday August 18, 2023 @12:46PM (#37178353)
You might like x!
Re:micro – A Modern Alternative to nano by naikrovek on Friday August 18, 2023 @01:15PM (#37178858)
you can do it. you have to want to, first, though.

then you sit down for an hour and you create and edit a file, and you do not allow yourself to hold any key down to move the cursor around. you have the link you posted printed out, and you use only what is on the sheet to edit.

when you want to add something to the end of the line, you do NOT push the END key then enter edit mode, you look at the sheet and you find what you want and you push SHIFT+A to enter edit mode and go to the end of the line at the same time.

you keep track of which mode you're in and what mode you need to do something, and you force yourself through the keystrokes needed to operate completely and efficiently using only the keyboard.

in an hour, if you force yourself to use only the shortcuts on the cheat sheet, you will be more fluent in vi/vim than ~90% of the people who use it, myself included, and I've been using vi/vim for 25 years.

Re:micro – A Modern Alternative to nano by LinXitoW on Saturday August 19, 2023 @07:00AM (#37187489)
You can still use VSCode and just use the Vim plugin.

Vim is not an editor, it's a language you speak with your editor. Like with real language learning, some of it is just rote memorization.

There are, however, some tricks that I find really help. The first is to find mnemonics for the different actions. Some are obvious, for example (d)elete or (c)hange. Some require a little imagination, like un(t)il (like in 'til).

Finally, there's some level of logic to many related things. For example, the CAPITAL version of an action is generally a "louder" more aggressive/stronger version. So (a)ppend is just "insert after current cursor position", whereas (A)PPEND! means "insert at the very end of this line".

Just like with languages, if you use them long enough, they start to "make sense", and "feel right". I don't have to translate "I want to append at the end of the line" to the correct keybinding, I simply "speak" to the editor in a way that "feels" right.

Re:micro – A Modern Alternative to nano by linuxdude314 on Friday August 18, 2023 @12:46PM (#37178348)
You make some excellent points. Unfortunately most hardware at some point ends up in this state.
Re:micro – A Modern Alternative to nano by tuxychandru on Friday August 18, 2023 @01:56PM (#37179553)
> now I only touch nano when I need to de-crappify a vimrc file

You can start vim with --clean to fix your vimrc.

Re:micro – A Modern Alternative to nano by kuchenbecker on Saturday August 19, 2023 @09:32AM (#37188616)
I suggest everyone at least familiarize themselves with `vi`.

`set mouse=a` - yes i want to use a mouse `i` - start editing `esc :wq` - exit

From there it's syntactic sugar navigation and editing.

Re:micro – A Modern Alternative to nano by dormento on Friday August 18, 2023 @09:25AM (#37175292)
20MB is bigger than some whole GNU/Linux systems I installed in the past. Might explain why the greybeard council disapproves of it.
Re:micro – A Modern Alternative to nano by swozey on Friday August 18, 2023 @09:36AM (#37175438)
You made me curious. I started w/ openBSD 1.2 in '95. I can't find it anywhere though to see what size it was.
Re:micro – A Modern Alternative to nano by rascul on Friday August 18, 2023 @01:04PM (#37178654)
There were some Linux distros in decades past designed to run off of a couple floppies. I struggle to recall any names at the moment.
Re:micro – A Modern Alternative to nano by cesarb on Friday August 18, 2023 @02:15PM (#37179839)
The classic one was "tomsrtbt" (http://www.toms.net/rb/).
Re:micro – A Modern Alternative to nano by swozey on Friday August 18, 2023 @04:38PM (#37181771)
His homepage just brought me SO much nostalgia. Just needs spinning skulls and construction gifs. http://www.toms.net/

And dang he owns toms.net, nice.

His resume on here hasn't been updated since 2002. Looks like he started his career in 1987. This is an interesting looking resume. Tons of skills at the top, goals, Other. I suppose it's cover-lettery.

Re:micro – A Modern Alternative to nano by kunwon1 on Friday August 18, 2023 @05:15PM (#37182215)
In 2005 I worked for a small radio shop. Firewall was running Coyote Linux, which booted off a single 3.5" floppy with write protect switched on.
Re:micro – A Modern Alternative to nano by junaru on Friday August 18, 2023 @09:37AM (#37175450)
Haven't tried removing nano ever but hate it with a passion for one simple reason.

If none of the EDITOR/VISUAL/etc. variables are set when you invoke 'visudo' a f*king nano appears.

Like god dammit it i assume vi in that name comes from vi as even the manpage has 'vi' among 'see also'. This is akin to launching firefox and some random application popping up - its the ultimate troll and i salute your graybeards for solving the problem at the core!

Re:micro – A Modern Alternative to nano by zwog on Friday August 18, 2023 @01:34PM (#37179188)
That is OS dependent, though. On Arch Linux with EDITOR empty `visudo` opens vi.
Re:micro – A Modern Alternative to nano by poutinepapi on Friday August 18, 2023 @09:49AM (#37175573)
Greybeards are going to greybeard mate. Plus, it's always funny to me because a lot of the old crowd you ask them what kind of system they ran and they(with swagger) admit that they were in charge of the WHOOOOLE IT department for their local government, and it was a big town too, so at least 500 users.

And I 105% assure that that system was the most secure in the entire county... And also unusable. And when that lad retires or someone in their office kills them out of sheer desperation, hopefully they'll be replaced by one of these new fangled engineers who might not know about vi, but they at least care a little bit about their users(Not a lot though, we're still engineers)

Re:micro – A Modern Alternative to nano by catiopatio on Friday August 18, 2023 @11:32AM (#37177018)
You could have learned enough vim to be usable in the time it took to write that comment.
Re:micro – A Modern Alternative to nano by codedokode on Friday August 18, 2023 @12:19PM (#37177864)
How to quit Vim and install Sublime Text?
Re:micro – A Modern Alternative to nano by rascul on Friday August 18, 2023 @01:00PM (#37178584)
> How to quit Vim

Restart the computer

Re:micro – A Modern Alternative to nano by cristifalcas on Friday August 18, 2023 @02:03PM (#37179664)
Silly you... It's Ctrl+Z
Re:micro – A Modern Alternative to nano by speedgoose on Friday August 18, 2023 @02:45PM (#37180275)
You can try Ctrl+C. Vim will of course not exit but display instructions about how to exit.
Re:micro – A Modern Alternative to nano by linuxdude314 on Friday August 18, 2023 @12:45PM (#37178325)
Agreed. Nano use is somewhat of a red flag to me.

It’s SO inefficient in comparison to Vim, VSCode, or tons of other alternatives.

If it’s the only thing on the box, fine, but in reality usually Vim is the only editor installed.

Re:micro – A Modern Alternative to nano by swozey on Friday August 18, 2023 @04:43PM (#37181844)
I initially thought you were speaking of CPU/ram efficiency until you threw in vscode, so I think you mean developer efficiency. Vi/vim is what you're accustomed to. I've worked with nano since it came out, I think 2004-5ish. I have no idea what I used prior to that, probably vi.

But I am MUCH faster and more efficient with nano than I am vi/vim/emacs. My text editor of choice is like my IDE of choice, it shouldn't be a problem at all for anyone to just accept that I'm getting my work done in a different application.

Re:micro – A Modern Alternative to nano by drbaba on Saturday August 19, 2023 @04:17AM (#37186674)
I'm more in the Vim camp myself, but suspect that those who use nano for longer programming sessions do so using a well-crafted nanorc. Nano does support some "modern" features like syntax highlighting, it's turned just off by default. (As far as I know, you won't be getting stuff like LSP and multiple cursors though.)
Re:micro – A Modern Alternative to nano by GoblinSlayer on Friday August 18, 2023 @02:13PM (#37179812)
Can I? I opened https://www.vim.org/docs.php but something bad happened to it and it displays in microscopic font for me.
Re:micro – A Modern Alternative to nano by swozey on Friday August 18, 2023 @04:27PM (#37181634)
I don't know how much you actually care, and I'm the nano OP of this comment chain/thread but there are some vims (and emacs) with plugins and what not built in. Only one I can think of off the top of my head is https://spacevim.org/ but theres a bunch.

If you are interested they might give you a good start.

Re:micro – A Modern Alternative to nano by b5n on Saturday August 19, 2023 @11:52AM (#37189985)
`vimtutor`
Re:micro – A Modern Alternative to nano by un1xl0ser on Friday August 18, 2023 @11:07AM (#37176719)
The main reason to know vi inside and out as a Unix administrator has to do with it being the lowest common denominator on Unix and Linux systems.

As a *nix tech I could get a call to work on a QNX system, HP-UX system, SGI Altix supercomputer or a Sun Ultra 2. Linux systems were easy, as they had the package management support for FL/OSS, and would commonly come with Emacs in the base-pack (before nano was mainstream). Sometimes you would have a terminal issue and have a single line to work with, in which case you would need to operate vi without seeing what you are doing (or use sed/awk). So maybe it is those instincts to KISS and force everyone to learn vi, like they had to (I had to).

Certainly it provides no significant surface area of attack to have an editor, but I wouldn't put it past a threat actor to leverage plugin functionality as a persistence mechanism. I presume that these applications operate differently as root, but maybe not as service (daemon) accounts. It's not very well hidden, but there are all grades of threat actors.

Re:micro – A Modern Alternative to nano by JohnFen on Friday August 18, 2023 @12:39PM (#37178220)
Personally, I strongly dislike nano and will take vi any day of the week over it.

However, the choice of text editor is a very personal one. It makes no sense at all for anyone to insist that anyone else should or shouldn't use any particular text editor. Just let people use what they like.

Re:micro – A Modern Alternative to nano by cesarb on Friday August 18, 2023 @12:50PM (#37178419)
> There are some greybeard linux admins who absolutely refuse to let someone use anything other than vi. I never got that.

When I first encountered nano, I found out that it could silently corrupt configuration files (by word wrapping long lines) unless you were very careful to always start it as "nano -w". Since then, I've always removed nano (or at least set something else as the default editor) on every Unix system I administer.

Re:micro – A Modern Alternative to nano by zamadatix on Friday August 18, 2023 @01:39PM (#37179288)
"-w" changes visual wrapping, it doesn't save that way. No different than the behavior of "cat" in an interactive terminal really, beyond the temptation for editor religion.
Re:micro – A Modern Alternative to nano by cesarb on Friday August 18, 2023 @02:07PM (#37179728)
> "-w" changes visual wrapping, it doesn't save that way. No different than the behavior of "cat" in an interactive terminal really, beyond the temptation for editor religion.

What you mentioned is "soft wrapping", which is visual only but doesn't affect the saved file. But the default for nano when I first encountered it was "hard wrapping", which does affect the saved file. Some distributions later changed the default in the nano configuration file, but depending on the configuration file instead of a built-in default is risky. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=135978 (and the five other bug reports merged into it) for an example of the problems caused by running nano in the default configuration without disabling its line wrapping.

Re:micro – A Modern Alternative to nano by zamadatix on Friday August 18, 2023 @04:29PM (#37181672)
I stand corrected on the wrap behavior of the original nano 1.x. Softwrap and the default wrap mode change weren't added until later.
Re:micro – A Modern Alternative to nano by swozey on Friday August 18, 2023 @04:32PM (#37181693)
That's interesting. I haven't ever had that problem. I have had a ton of problems with zsh adding characters to things like SSL certs (I forgot, maybe an ending %?) where I had to switch back to bash to base64 encode/decode it properly.

I write the standards for our engineers to follow/emulate/consider. I don't have very much for nano but this is what I put into every containers userdata scripts. I can't get this curl command to show up correctly.

  # Add syntax highlighting and line numbers to nanorc, need to fork syntax repo so we're not installing random git repos

  curl 
https://raw.githubusercontent.com/scopatz/nanorc/master/inst... | sh

  {
  echo set constantshow
  echo set linenumbers
  } > ~/.nanorc
Re:micro – A Modern Alternative to nano by rascul on Friday August 18, 2023 @12:57PM (#37178531)
If I recall correctly that default changed awhile back. One could also set it how they want in nanorc.

However, I do understand the criticism, and how that could leave a bad first impression.

Re:micro – A Modern Alternative to nano by notnmeyer on Friday August 18, 2023 @12:53PM (#37178462)
pretty much madness. it’s almost like a badge of honor for some folks.
Re:micro – A Modern Alternative to nano by stjohnswarts on Saturday August 19, 2023 @02:17AM (#37186076)
there are vi minimalist versions that are much much small than 20MB