News for hackers. Stuff that matters.
Re:Why Should You Learn Vim in 2020 by mumblemumble on Wednesday August 05, 2020 @04:41PM (#24065354)
For what it's worth: I really don't care to tell people what editor to use. But I do think that everyone should think about spending some time with vimtutor. Not because it will turn you into a 10x developer, or because vim has the best keybindings ever, or anything like that. I've never bought it. But I do believe that it is very likely to make your life easier, even if you don't actually use vim.

Let me explain: I've been an emacs person for decades now. I was never super committed to it, though. In practice, I'll use whatever editor has the best plugin for the language I'm working in. Which means that, for the longest time, I had to try and keep track of 4 or 5 different sets of editor keyboard commands. Which is too damn much for one brain, so I found that, over time, I stopped being as efficient in any editor as I was in emacs 25 years ago.

So why vim? Because every editor worth its salt has an option to use vim keybindings. So you don't have to learn 4, 5, 6 different sets of editor commands. You can learn one, and learn it well.

Re:Why Should You Learn Vim in 2020 by wahern on Wednesday August 05, 2020 @05:09PM (#24065615)
> Because every editor worth its salt has an option to use vim keybindings.

Including the Unix shell line editor, which typically supports both vi and emacs key bindings, and nothing else. Yet for some reason the default always seems to be emacs rather than vi, even on BSD (e.g. OpenBSD), and even though POSIX only mandates vi mode because "[t]he author of emacs requested that the POSIX emacs mode either be deleted or have a significant number of unspecified conditions."[1] Emacs line editing mode is more confusing for me as I use Joe (WordStar clone) which has emacs-like key combinations but with slightly different assignments. And because of this default I've never made a habit of using line editing commands; there's no way I can unlearn my Joe muscle memory, and over the years I've gotten into the habit of avoiding shell personalizations, to my detriment in this case.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/s...

Re:Why Should You Learn Vim in 2020 by WWLink on Wednesday August 05, 2020 @05:14PM (#24065664)
MacOS uses ctrl+a/ctrl+e EVERYWHERE (but it doesn't work well in Microsoft products, if it works at all).

I like my emacs line editing mode :D

Re:Why Should You Learn Vim in 2020 by 27182818284 on Wednesday August 05, 2020 @10:37PM (#24067653)
This is one of my favorite things about macOS.

I love that control+a and command+a have different functions. I use control+k and control+a all the time while writing comments on websites, etc. Especially since I've been mapping caps-lock to control for more than a decade.

Re:Why Should You Learn Vim in 2020 by WWLink on Saturday August 08, 2020 @03:58AM (#24089888)
It also means you can use the usual cmd+c in a terminal window. That alone makes Macs my favorite console machine lol. I mean at least Linux has ctrl+shift+c too. Windows: shift+insert? REALLY?! WTF? lol. :D
Re:Why Should You Learn Vim in 2020 by yodsanklai on Wednesday August 05, 2020 @05:18PM (#24065713)
> Because every editor worth its salt has an option to use vim keybindings.

I'm not sure about this. For instance, I'm typing this message in a text box in my browser and I don't have access to vim keybindings. There are many cases where this happens (other example: google docs).

I do use vim whenever I can, but I'd say the most useful keybindings that one can learn are the ones from the OS.

Re:Why Should You Learn Vim in 2020 by justinator on Wednesday August 05, 2020 @05:22PM (#24065757)
Both Chrome and FF have plugins to add vim key bindings - at least for navigating around the UI and the page. Which would support the argument to learn them. I guess your argument would be stronger if there were other $editor_of_choice key bindings for browser textboxes?
Re:Why Should You Learn Vim in 2020 by oblio on Wednesday August 05, 2020 @05:27PM (#24065808)
There are key bindings for other editors, they're called CUA :-)

I can Ctrl-C/Ctrl-X/Ctrl-V to copy/cut/paste, Ctrl-arrows to move around one word at a time, Ctrl-shift-arrows to select words, Home and End to go to the start and end of the line, etc, Ctrl-Home/Ctrl-End to move to the start and end of the text input, etc.

Re:Why Should You Learn Vim in 2020 by vmladenov on Wednesday August 05, 2020 @05:32PM (#24065855)
On macOS a majority of UI text fields support readline bindings (^A, ^E, etc) which is really nice
Re:Why Should You Learn Vim in 2020 by jolmg on Wednesday August 05, 2020 @07:03PM (#24066569)
> support readline bindings (^A, ^E, etc.)

Those are emacs bindings. Readline uses emacs bindings by default, but it can also use vi bindings.

Unless you mean that it uses readline and so configuring it (i.e. ~/.inputrc) allows you to change the keybindings of macOS UI text fields. That'd be cool if it's the case.

Re:Why Should You Learn Vim in 2020 by yodsanklai on Wednesday August 05, 2020 @06:04PM (#24066124)
I have a big issue with these bindings: there is no "right" ctrl on my MBP keyboard. If you touch type, I find ^A very cumbersome to type. I find it easier to use mac os default (cmd + arrow) which also opens variants such as option + arrow, shift + option + arrow. The only readline binding I do use is ^K (not as bad as ^A because k is on the right side of the keyboard, and there is no alternative anyway).
Re:Why Should You Learn Vim in 2020 by LeonB on Wednesday August 05, 2020 @06:03PM (#24066112)
I read this comment 20 minutes ago and tweeted about it. I came back here to provide a link to a browser plugin for vi keybindings and found many other people had also commented with examples- only different ones.

Here’s another:

https://github.com/akahuku/wasavi

Re:Why Should You Learn Vim in 2020 by ybbond on Thursday August 06, 2020 @11:24AM (#24071751)
I checked the comment before commenting, and turns out someone already mentioned wasavi.

Very useful tool, too bad it does not support key mapping. I'd like to `nmap gj <ESC>` or the essential `nmap j gj`, because writing on small `<textbox/>` tends to wrap the content.

Re:Why Should You Learn Vim in 2020 by jjav on Wednesday August 05, 2020 @05:44PM (#24065970)
> I'm not sure about this. For instance, I'm typing this message in a text box in my browser and I don't have access to vim keybindings. There are many cases where this happens (other example: google docs).

But both in this box and in google docs (and so many more places) you have access to the basic emacs C-* cursor movement and line manipulation bindings.

One should really know both vi and emacs style basic movement bindings. Both work in many places, sometimes it's one or the other.

Re:Why Should You Learn Vim in 2020 by m3at on Wednesday August 05, 2020 @06:01PM (#24066095)
Here, that will let you greatly expand where you can use vim:

> Sometimes, you edit text outside of Vim. These are sad times. Enter vim-anywhere!

https://github.com/cknadler/vim-anywhere

Re:Why Should You Learn Vim in 2020 by dbalatero on Thursday August 06, 2020 @09:00AM (#24070482)
I'm working slowly on a Vim mode also that works in all text areas without kicking people into Vim: https://github.com/dbalatero/VimMode.spoon
Re:Why Should You Learn Vim in 2020 by m3at on Thursday August 06, 2020 @10:16AM (#24071062)
Very interesting! I will give it a go.
Re:Why Should You Learn Vim in 2020 by Onawa on Wednesday August 05, 2020 @10:36PM (#24067647)
Oh my god thank you so much for posting this!
Re:Why Should You Learn Vim in 2020 by randompwd on Wednesday August 05, 2020 @05:52PM (#24066039)
> I'm typing this message in a text box in my browser and I don't have access to vim

https://github.com/GhostText/GhostText

GhostText extension for chrome/FF and listed $plugin for $editor means you can live edit a browser textarea in $editor with text sent in real time to browser.

Unfortunately, Google Suite(docs etc.) does not play nice and does not work.

Worth checking out.

Also for a more embedded vim experience: https://github.com/glacambre/firenvim

Re:Why Should You Learn Vim in 2020 by jbpnoy6fifty on Wednesday August 05, 2020 @05:21PM (#24065743)
I believe he meant code editors. Examples of which I have used Vim bindings

- google chrome

- sql server management studio

- jupyter notebook

- jupyter lab

- visual studio code

- ms visual studio

- dbeaver

- eclipse

- sublime text 2

- hackerank, iirc

Re:Why Should You Learn Vim in 2020 by youerbt on Wednesday August 05, 2020 @05:46PM (#24065983)
For me, writing short prose like emails or internet comments doesn't really require vim keybindings. It mostly requires keyboard for what it was designed for - inserting text.

Editing source code, on the other hand, benefits much more from vim, because inserting text is only part of it.

Re:Why Should You Learn Vim in 2020 by m463 on Wednesday August 05, 2020 @07:32PM (#24066758)
I use macos and linux and the keybindings are compatible with emacs.
Re:Why Should You Learn Vim in 2020 by apta on Wednesday August 05, 2020 @11:18PM (#24067832)
Re:Why Should You Learn Vim in 2020 by freedomben on Wednesday August 05, 2020 @04:57PM (#24065515)
I actually learned "vim" on Qt Creator's Vim mode and although I do most of my development now in "real vim" I very much agree with your post. Nearly every editor support vim keybindings which drastically reduces the different shortcuts you have to remember. Even among JetBrains products I find it helps a lot with consistency.
Re:Why Should You Learn Vim in 2020 by pkulak on Wednesday August 05, 2020 @05:15PM (#24065681)
And this means that you can go between systems, not just editors. Before I learned vim bindings, using Linux was so punishing because I was used to using command/ctrl/shift/arrow keys and whatnot to select words, navigate to the beginning and end of the line, etc. After I moved to vim bindings for all my editors, switching to Linux was so easy that it's now where I spend almost all of my time. However, if I do need to use a Mac, I no longer have to fight muscle memory (except for that infernal super key copy/paste).
Re:Why Should You Learn Vim in 2020 by mixmastamyk on Wednesday August 05, 2020 @05:10PM (#24065630)
Agreed yes, and you could use CUA keybindings and be comfortable everywhere, working cross-desktop, cross-terminal, cross-platform. Only a minor variant on the Mac with Cmd instead of Ctrl. Some good options:

- Geany

- Sublime Text

- VS Code

- Notepad++

- micro

- ne

On top of these I usually memorize Ctrl-A and Ctrl-E for the command-line, and "i… :wq" for vim, although haven't needed the latter in a decade.

Re:Why Should You Learn Vim in 2020 by grativo on Wednesday August 05, 2020 @05:18PM (#24065712)
Sublime Text has a vintage mode which has vim controls, which is very nice. It does not have an advanced set of commands that perhaps other editors might have, but it has the core commands. https://www.sublimetext.com/docs/3/vintage.html
Re:Why Should You Learn Vim in 2020 by davidrupp on Wednesday August 05, 2020 @04:55PM (#24065494)
I find that the editors I use most —- TextMate and the JetBrains suite —- also have the option to use Emacs bindings. I try to maintain functional literacy with vi(m), because it tends to be more available by default, but I’ll use Emacs where possible.
Re:Why Should You Learn Vim in 2020 by mumblemumble on Wednesday August 05, 2020 @05:10PM (#24065626)
A fair point, and, though I'm not personally sad about making the switch, I definitely don't want to imply that other emacs users should drop everything and switch to evil mode.

But, at the risk of branding myself a traitor, I would suggest that anyone who doesn't already have emacs shortcuts burned into their muscle memory should choose to learn the vim ones, because they're somewhat more widely supported.

(And to use doom emacs to do it.)

Re:Why Should You Learn Vim in 2020 by davidrupp on Wednesday August 05, 2020 @05:16PM (#24065689)
I’ve found value in knowing both. And I’ve decided that I prefer Emacs because the mode I care about most —- which I informally call “just type stuff mode” —- is the default “mode” in Emacs.
Re:Why Should You Learn Vim in 2020 by JoshTriplett on Wednesday August 05, 2020 @05:08PM (#24065607)
There's also https://vim-adventures.com/ , which is a fun way to learn the basics.
Re:Why Should You Learn Vim in 2020 by aqme28 on Wednesday August 05, 2020 @05:14PM (#24065660)
Agreed. I don't use vim for day-to-day use, but if I have to ssh into a server it's nice to know that I can still get by.
Re:Why Should You Learn Vim in 2020 by lazyant on Wednesday August 05, 2020 @07:41PM (#24066800)
> every editor worth its salt has an option to use vim keybindings

Also a lot of inputs use Emacs binding or a subset of it: Bash and other shells, Cisco routers, heck, even in Slack you can Crtl-a or Crtl-k.

Re:Why Should You Learn Vim in 2020 by _virtu on Thursday August 06, 2020 @05:05PM (#24075458)
> I really don't care to tell people what editor to use.

Yeah, this is weird to me. I've seen some people list it on their resume. Why should I care what editor you use?

Re:Why Should You Learn Vim in 2020 by wombat-man on Wednesday August 05, 2020 @04:59PM (#24065531)
dang that's... a good point actually.
Re:Why Should You Learn Vim in 2020 by outworlder on Wednesday August 05, 2020 @07:12PM (#24066629)
At that point, you can use Spacemacs.