News for hackers. Stuff that matters.
Re:How Did Vim Become So Popular? by blinding-streak on Tuesday June 30, 2020 @07:38PM (#23696099)
Hated Vi at first. Absolutely loathed it. I was all about emacs.

But I gave vi another shot, and I'm so glad I did. The learning curve can be steep, and it's really unintuitive at first (or it was for me). But once it clicks a little bit, and you settle in.. Wow. I felt way more productive using it than any other editor.

Re:How Did Vim Become So Popular? by war1025 on Tuesday June 30, 2020 @08:14PM (#23696336)
I've been using vim for ~8 years now as my editor at work. I don't even use the "fancy" movements that everyone always brags about. It's still way more convenient to move around in than any other editor I've used.

I don't know where I saw it, but the idea that "Code exists to be read" really resonates with me. I don't care how fast I can crank out code. I care about how efficiently I can hop around from place to place to grok what is going on and how it needs to change.

The killer feature of vim that I feel like very few people know about is it's remote editor feature.

Launch a long lived instance of vim with a `servername` set, for example I do: `vim --servername EDITOR`

Then set up a application shortcut that will open the file using the prefix `vim --servername EDITOR --remote <file>`

When you open a file, it gets opened in your single vim instance.

From there you can navigate between all your open files using `:b <file-tab-complete>`

It's really a joy to use. You don't have the mess of tabs where you run out of space super fast, you just have a bunch of open files that you can switch between super easily by name.

Re:How Did Vim Become So Popular? by not_kurt_godel on Wednesday July 01, 2020 @03:27AM (#23698768)
This just sounds like a nightmare to me. I can't stand it when I have a terminal program with an unseeable list of files/panes that have to be opaquely navigated through. I very much want to be one of those vim/emacs ninjas but I just don't see how this is more ergonomic than Jetbrains where any file - not just 'open' ones - is readily available with all sorts of search methods with a single shortcut. And then I can visually see what files I'm working with instead of groping around through one file at a time in the dark.
Re:How Did Vim Become So Popular? by war1025 on Wednesday July 01, 2020 @08:48AM (#23700749)
> I just don't see how this is more ergonomic than Jetbrains where any file - not just 'open' ones - is readily available with all sorts of search methods with a single shortcut.

I would guess the difference is that I use a separate terminal window for all of that stuff. I have my desktop split into three main workspaces. The first has my terminal, the second my browser, the third my editor. I have two more workspaces just in case, but they rarely get used. I have shortcuts set up to hop between workspaces using `<super><workspace number>`.

If I want to track through where something is used or defined, `git grep` usually gets me what I want. From there, if there is a file I want to look at, I use my shortcut `go <filename>` to open it. This used to be an alias for `gnome-open`, but a couple years ago they switched it to `xdg-open` . It opens the file with whatever program would open it when opening it from the file browser, which for any text file is my vim instance over in workspace 3.

I don't pay much attention to which files are open or not. Usually I build up a working set of files I care about pretty quickly and then I can hop between them from within vim. Otherwise I can easily go back over to my terminal and open it by name directly.

It may not be for you, but it's far from a nightmare in my experience.

Re:How Did Vim Become So Popular? by not_kurt_godel on Wednesday July 01, 2020 @01:25PM (#23704038)
> It may not be for you, but it's far from a nightmare in my experience.

Right, everyone has their preferences. As was said in another comment, merely paying attention to and adapting one's personal tooling is a huge differentiator between software developers, regardless of which particular tools those might be. Your setup has a lot of conceptual similarities to mine. I use terminals heavily, but ultimately I personally like a GUI as the 'root' of my working space. I'd rather start from a place where I can navigate everything visually/spatially and then add shortcuts on top of that to automate the most repetitive/tedious paths that naturally occur in that environment.

Re:How Did Vim Become So Popular? by alwillis on Wednesday July 01, 2020 @05:14AM (#23699491)
Vim can operate like that if you want. Most people use NerdTree to have all of their files visible like most IDEs: https://code.tutsplus.com/tutorials/vim-essential-plugin-ner...
Re:How Did Vim Become So Popular? by RMPR on Wednesday July 01, 2020 @02:04AM (#23698256)
>The killer feature of vim that I feel like very few people know about is it's remote editor feature.

Now this is dope, I used to rely on a trick I discovered in a conference[0], append to the `path` variable in your .vimrc so you can recursively fuzzy find files in the directory where you opened Vim, and more recently setting global marks[1] in the files of interest.

0: https://youtube.com/watch?v=XA2WjJbmmoM

1: https://vim.fandom.com/wiki/Using_marks

Re:How Did Vim Become So Popular? by dannycastonguay on Tuesday June 30, 2020 @07:56PM (#23696218)
(Helpful tip) map caps lock to escape: https://vim.fandom.com/wiki/Avoid_the_escape_key
Re:How Did Vim Become So Popular? by californical on Tuesday June 30, 2020 @08:04PM (#23696270)
Strongly agree -- I mapped my whole keyboard to always have caps/esc swapped. It didn't take long to get used to. My left hand feels way better, not needing to reach very far.

Biggest downside is using someone else's keyboard. I've grown a nasty habit of hitting escape instinctually, every time I finish typing something. I turn on their caps lock so regularly! Still worth it though

Re:How Did Vim Become So Popular? by matvore on Wednesday July 01, 2020 @08:39AM (#23700681)
I still use caps lock since I regularly code in POSIX shell, C, C++, and Perl, which all have naming conventions that use all-caps names.

Also, as a VIM user, I only have to use Alt when I’m dealing with GUI apps, which is definitely common, but a time when I don’t mind moving my hands around.

So for me, Esc is Alt. Alt is caps lock. And of course caps lock is Esc.

And I swap Super key and Control, since the Super key is easier to press with my palm on my ergonomic keyboard. And Ctrl does have a lot of uses in Vim.

I also map the Windows Menu key (not the Super key, but the other one which is used for showing context menus) To underscore. That helps me type C identifiers with multiple words in them. This one remapping is a huge benefit, almost as important as mapping caps lock to Esc.

Re:How Did Vim Become So Popular? by Lio on Wednesday July 01, 2020 @03:20AM (#23698711)
Map caps to ctrl and you can get access to a world of convenient insert mode shortcuts.

ctrl-[ (for right hand) or ctr-3 (left hand, thanks teddyh) => escape

ctrl-i => tab

ctrl-h => backspace

ctrl-m => return

ctrl-w => delete prev word

ctrl-u => clear line

ctrl-o => cmd mode for 1 cmd

...and many, many more, including all the completion options.

Re:How Did Vim Become So Popular? by patrec on Wednesday July 01, 2020 @06:12AM (#23699851)
Still wasteful. Map Capslock to both Escape and Ctrl and never look back

https://github.com/alols/xcape (for linux)

https://apple.stackexchange.com/questions/132564/how-can-i-r... (for macOS)

https://github.com/ililim/dual-key-remap (for windows)

Re:How Did Vim Become So Popular? by austhrow743 on Wednesday July 01, 2020 @07:17AM (#23700220)
What's the advantage to having control on it as well? Do people have trouble reaching the control key?
Re:How Did Vim Become So Popular? by patrec on Wednesday July 01, 2020 @04:41PM (#23706370)
Try it (or swap caps and control for day, to make sure you don't accidentally "cheat"). On most keyboards reaching the control key is very unergonomic compared to the capslock key. I wonder how many cases of RSI could be avoided by this simple tweak alone.
Re:How Did Vim Become So Popular? by jtms on Tuesday June 30, 2020 @10:43PM (#23697198)
I strongly agree, but would go one step further and just remap caps lock to escape for the entire OS. Caps lock is a relatively useless function that takes up extremely prime real estate.
Re:How Did Vim Become So Popular? by the_jeremy on Tuesday June 30, 2020 @07:58PM (#23696233)
Or if you're on a locked-down computer because your office hates people, ctrl+[ works as well (and is portable to other people's computers)
Re:How Did Vim Become So Popular? by jrockway on Tuesday June 30, 2020 @08:10PM (#23696310)
You can also do the remapping in hardware. Programmable keyboards are quite popular these days (I built one out of a $3 stm32f103), and they don't rely on the OS to help you do what you want to do.

(This is a blessing and a curse. You never have to worry about OS-level hacks to make caps lock a control key, but on the other hand, there is no way in the USB HID protocol to say "send an !". Rather, the keyboard has to synthesize a shift + 1. And what character that actually maps to depends on your OS, because of course it does.)

Re:How Did Vim Become So Popular? by jrumbut on Tuesday June 30, 2020 @08:13PM (#23696331)
I still get some mileage out of my caps lock key and use "jj" and use paste mode if I have to insert an uncommon string with "jj" in it. Usually pasting it anyway.
Re:How Did Vim Become So Popular? by war1025 on Wednesday July 01, 2020 @12:29PM (#23703308)
I tried that `jj` or `jk` thing for a while and it just did not click with me at all.

I tried it because I was having a bunch of wrist pain. The actual solution to my wrist pain was easy: Don't code on a laptop keyboard. The ergonomics are terrible.

Re:How Did Vim Become So Popular? by mahmoudhossam on Tuesday June 30, 2020 @07:59PM (#23696237)
I went one step further and swapped escape and caps lock keys on all my machines and haven't regretted it so far.
Re:How Did Vim Become So Popular? by ncmncm on Tuesday June 30, 2020 @10:11PM (#23696979)
I cannot remember the last time I wanted to use CapsLock--more than 30 years ago, anyway.

By far the most irritating thing about others' keyboards is they have not disabled it yet. Second most is that Ctrl isn't there instead.

Re:How Did Vim Become So Popular? by Symbiote on Wednesday July 01, 2020 @02:45AM (#23698484)
How do you TYPE_A_CONSTANT for the first time, or an ENUM_VALUE (perhaps somewhere you don't have autocomplete)?

I keep a caps lock on my programmable keyboard for this (Fn+K).

I also like SQL to be formatted with capital letters for keywords.

Re:How Did Vim Become So Popular? by Lio on Wednesday July 01, 2020 @03:25AM (#23698751)
Either using shift keys or:

  type_a_constant ctrl-[ vawU
That sounds more than it is. Really I just touch type it without thinking consciously about it.

Probably don’t even need visual mode that’s just how I work.

Re:How Did Vim Become So Popular? by alpaca128 on Wednesday July 01, 2020 @03:30AM (#23698790)
I prefer Ctrl on Caps Lock and Escape on the original Ctrl. Works pretty well too.
Re:How Did Vim Become So Popular? by hellofunk on Wednesday July 01, 2020 @05:46AM (#23699688)
One thing I like about vim is that the defaults are more sane than emacs. Almost no one uses emacs out of the box without extensive customizations. People customize vi too, but out of the box it is already pretty close to being there on its own, which is really nice.