Hacker News new | past | comments | ask | show | jobs | submit login
Why, oh why, do those nutheads use vi? (2007) (viemu.com)
62 points by behnamoh on Dec 7, 2021 | hide | past | favorite | 124 comments



I keep trying to get into vim, but I just really enjoy multi-cursor editing in Sublime Text. The example in the article of changing multiple lines using '.' to repeat is the same as selecting the three lines in Sublime Text, entering multi-line edit mode, and then typing the change once. The same applies for replacing a single word (e.g. with Cmd+D) and/or regex replacements. Basically, I have a really easy time avoiding any repetitive commands in my normal day, so I wonder what the real advantage of vim would be for my use case. Or maybe I just don't know what I haven't yet learned...


Vim's keymap has a wide variety of 'text objects'.

Reiterating point 3 from the article: e.g. if the cursor is at | in:

  printf("Hello |World\n");
With vim, you could manipulate the text in different ways by using different motions, e.g.:

`db` would give `printf("World\n");` (b for backwards),

`de` would give `printf("Hello \n");` (e for end-of-word),

`di"` would give `printf("");` (inside `"`),

`di(` would give `printf();` (inside `(`),

or instead of deleting, some actions could be useful, like changing to uppercase: e.g.

`gUi"` would give `printf("HELLO WORLD\n");`


Didn't realize I could do `di"`... that's so neat.

I always at least whip through such articles about vim as there may be something I don't use daily, but could. There always is such a thing.

I love to use all the zero-configuration things that are already present in Vi/Vim at work. IDE's are cool for devs or people who do everything from a stable workstation. I rarely have such comfort, jumping from one server to another, from one image to another. And Vi or Vim are always there. Thanks for all those hints.


For VSCode users:

ctrl+backspace: `printf("World\n");`

ctrl+delete: `printf("Hello \n");`

alt+shift+right, alt+shift+right, delete: `printf();`


Or install the vim emulator plugin. It's not perfect but it does a lot


You can select multiple lines in vim using ctrl-v, then do some action on all lines like inserting by shift-i, or whatever you want to do with the lines. Replacement with regex is also trivial.


There are endless patterns for using Vim. Here are a few which I use frequently instead of multi-cursors: https://asciinema.org/a/v7pOP4tqxPOPUu1HwbixmuUnS

I switched to Vim from Sublime Text years ago, and honestly multiple cursors and the live search and replace (especially across multiple files) were both missed until I learned how to do them in Vim just as easily.

Vim is a multi-year investment, and isn't worth it for most people.


AFAICT multi-cursor mode is not nearly as useful as vim (or keyboard macros in most editors). I don't know SublimeText but I do know, functionality of multi-cursors is often limited. For example, say I want to go to all functions calls

    foo(aa, bb, c);
    foo(d, ggg, hh);
    foo(iiii, i, jjjj);
I want to do something to the 2nd argument on each line. add a fn(prevContents). So I search for "foo(" and then pick "put a cursor on every match". Then how do get to the first comma and the select to the second comma on each line? This is easy with vim, easy with keyboard macros, not easy with multiple cursors (that I know of). For example as soon as I press "find" so I can search for the comma I lose multiple cursors. Maybe there's a special "Search with multiple cursors" command but if so that just highlights the issue, you shouldn't need special commands, you should be able to combine existing commands. vim and keyboard macros make that easy.


For things like that, I usually make use of the C-Left and C-Right combinations to get to the same place on every line; after all, if two lines are similar enough for me to do the same thing to all of them, they very often have the same sequence of words. (Sometimes there can be issues, e.g., if one line has an extra index.) For reference, I tried your particular example, and the keystrokes look something like:

  C-f, "foo\("                    [open a Find dialog]
  C-Enter:  [foo(]XX, YY, ZZ);    [Find All shortcut]
  Right:    foo(|XX, YY, ZZ);     [move to the right side of the match]
  C-Right:  foo(XX|, YY, ZZ);
  C-Right:  foo(XX,| YY, ZZ);
  C-Right:  foo(XX, YY|, ZZ);
  C-S-Left: foo(XX, [YY], ZZ);    [select leftward]
I suppose that it's not quite as ergonomic as Vim keybindings, but it's definitely less of a departure from the usual OS text boxes.


Now, I use vim mode in Sublime, so I have already "seen the light" so to say. But that situation is probably one I'd actually be able to solve faster with multiple cursors.

What I'd do is this: Put the cursor on one of the calls, then use ctrl-d to put a new cursor at all the matches. Then use ctrl-right-arrow to move by word until the second comma, combine that with shift to select the argument and edit all of them with visual feedback to my heart's content.

In reality, depending on the complexity of the text, after creating all the cursors, I'd probably use the vim movements to get them to where I need though.


Multiple-cursor editing is a nice and cool feature, and for what it's worth there are some vim plugins to get it in vim, but let's see the alternative:

- multiple-cursor: select non-contiguous pieces of text, then edit them all at once.

- vim macro/repeat: edit a piece of text, and repeat on similar occurrences.

The vim "way" could be, `/;$` to select the trailing semi-colon, then `cgn` to edit it (enter the curly block once in insert mode, then exit with `<Esc>`), and now you can repeat on the next trailing semi-colon simply by hitting `.` (dot).

So, instead of first looping on the occurrences to get multiple cursors, then do the editing, you first do the editing on an occurrence, and you loop on the editing. There is admittedly less of a "wow" factor, but I don't think it is any less powerful.

(edited for formatting).


It is way harder to use macros than to do multiple-cursor editing, especially for the kind of fast changes that happen 10 times a day. The difference is between seeing interactively exactly what you are doing and where something is going wrong (with multiple cursors), vs. recording a macro, replaying it, realizing you forgot to do something like use the correct keybinding, rerecording, etc.

I say this as a huge vim advocate, who used vim exclusively for 8 years before switching to emacs and lately to vscode.

Vim gets a lot of things right, and there's no comparison to using vim-style editing. But multiple-cursor editing is a killer feature that really does improve your workflow a lot of the time. Luckily most editors have some version of it now, though often not as good as the original and doesn't always play nicely with the various vim modes.


If you insist, you may have a look at https://github.com/mg979/vim-visual-multi

It implements multi cursors in vim and combines it with vim movements etc.


Yeah I used it (or something similar) when I was actively using vim. It wasn't as good as a proper IDE but was fairly good for a variety of use cases.

(I actually tried to implement my own multi-cursor plugin in vim, and got a decent amount of the way there before realizing my fundamental approach probably wouldn't work.)


Maybe because I’m also a maker I don’t expect my tools to do everything… what’s wrong with using vim for what it does very well, and then Sublime (geany, kate) when a gui is just easier?


Nothing at all!

But the way I use my editor is that I'm usually in it all day. Both for editing code, but also for personal notes, etc. So it's on all day and I spend most of my time in it.

This effectively means I have one tool that I mainline. I'll still use vim in the odd situation where I can't use my main editor, but it's usually just easier for me to open files in the editor I already have open.


. is more general as it repeats any editing action, not only insert-at-cursor.

I keep trying to get into vim

Speaking out of my 20 years experience, you probably shouldn’t. You’ll find vim a little behind sublime/vscode in some parts and will keep trying to get out of it, unsuccessfully. I came to conclusion that I wish all of the editors (vim included) separated editing from their operation and made it modular (vim-like extensions are limited to a subset of it and are really worst of all these worlds, cause only half of your habits work and none of your scripts/addons do).


Evil emacs is pervasive, vim users that I pair with are able to use my keybindings. I just have a lot more plugin power at my disposal on top of that.

Update: I guess your complaint is about a plugin ecosystem that doesn't respect vim bindings. I think you'd be impressed by what the evil community has, speaking as a former power vim user whose emacs setup is even better.


My problem with evil is that I'm still inside of Emacs and I still need to know Emacs to be useful with it. If I am keen to become an evil user, what is my path forward? I've watched videos, read "tutorials," I've tried evil, doom, spacemacs, etc. I'm always put off by the thing almost as soon as I punch `$ emacs .` into my terminal. I've got nearly 2 decades of mileage with (neo)vi(m) in my rear view mirror. I am very interested in org-mode and am willing to learn but for the life of me I can't figure out how to.


Fair enough, I haven't seen a great learning path, every question that I asked at first ended in an answer with something in emacs that I didn't know about. What the hell are helm, avy, Ivy etc? I just want to find some files.

I'm on spacemacs which I believe has given me a massive head start on a great setup. If I started from something more lightweight I would have wanted to end up where I am now, but the results on my own would have been worse.

However I admit that even the supposedly beginner friendly spacemacs still has the same problem of "find the intuitively named spacemacs layer, then start googling all the package names mentioned in the docs (which are not intuitively named), and possibly read the source", which is a big set of hurdles.


Appreciate the reply. I guess it's all perception. If I was in my 20s, I'd have the time and desire to dig into it and figure it out. Alas, I'm in my 40s and between work and family I just don't have the time for those things. Maybe when my kids are a little older...


Almost every modern editor has some form of vim emulator, so you can have the best of both worlds


These don’t work for me because I made a slip and added too much vim-specifics to my editing/workflow habits. Vim emulators only work for those who have 3-5 years of non-active exploration experience. Once you commit to plugins, buffer/window-related actions, scripts, hooks, heavy vimfiles setup, etc, the way back is as hard.

Edit: please don’t downvote the parent commenter, it’s a non-obvious knowledge and it doesn’t apply to everyone.


Yeah okay, I understand emulation is a subset, but surely a modern IDE takes care of most of the productivity gains you get from customization and adds a few more, like the context/AST-aware refactoring you find in Jetbrains IDEs

Edit: I spent a long time trying to make Vim more IDE-like, but found it was more productive to make my various IDEs more Vim-like, but I concede that might not be suitable for everyone


Just so we don't compare apples and oranges: The refactoring tooling in jetbrains products is unique. I haven't seen vscode or any other ide capable of reproducing this, at least not for dynamic languages.

I wouldn't use this as the basis of an argument for superiority of IDEs in general over vim.

And of course there are tradeoffs, rubymine users I worked with always complained about startup times and heavy indexing. (This was a few years back, maybe it's improved since)


I use VIm in vscode quite a lot, and I do reach for macros to refactor code a lot more than when I switch to a JetBrains IDE. But I couldn't see a benefit to using vim outside of vscode for these refactoring operations, so I'd be curious to know whether you do and what you use?


I'm not saying vim emulation has anything to do with refactoring, I'm saying that outside the jetbrains stable there are no refactoring tools worth speaking of, i.e. refactoring is not a variable in which IDEs in general beat vim.

If you can write vim macros to extract method, push up dependencies etc, then you've made vim better than most IDEs.


Yeah, I’m also leaning to just learn the heck out of vscode internals and tune it to my own needs maybe via custom plugins, instead of running behind the train. Sometimes investments just stop returning, and you have to make bold moves want it or not.


After many years of being in your camp, I finally made the switch to VSCode (well, first to Spacemacs, then to VScode).

It's true that there are a lot of things I configured specifically in vim, however, VSCode has a pretty decent vim mode that takes care of a lot of stuff (including a bunch of pretty standard stuff that most people add to vim, like adding vim-surround for example).

In addition, it has a pretty decent way to configure new commands, so most of the other stuff I missed from vim I could actually figure out how to port over to VSCode.

Totally worth it for me - it was a few months of slowly rebuilding habits and porting commands from vim, but now I have a "best of both worlds" setup.


One thing that bothered me a lot when I tried to use vscode (with the best vi bindings I could find) was that the vi bindings only actually worked within specific text areas

if I want to do something like filter things in the problems pane, I need to focus an entirely separate thing with no vi bindings so I'm forced to reach for the mouse to use that or even to just get back to a pane that supports vi bindings.

also ctrl+w closes tabs instead of being a prefix for focusing different panes


I used to have that problem everywhere. But I solved it back then by creating a set of scripts that let me use something like vim mode anywhere on the computer.

Lately I've switched to a programmable keyboard, so my actual arrow keys are int accessible via a special Layer (I hold a thumb key, and that gives me hjkl, as well as various other bindings I've created that act like vim commands).


What are you getting from vscode that you didn't have in spacemacs?


First of all, setup is much easier. If something breaks, I can easily fix it. If I need a new language to be supported, it's usually a click then a 10 second install, and it usually suggests it for me (instead of having to search around).

It starts faster, everything works together better, no weird plugin-compatibility issues (mostly). If I need to find a command, it's easier to lookup in VSCode than Spacemacs (because the menus use a much better GUI, with fonts, highlights, etc).

If I want to switch between files, open a folder as a project, etc, it all works well, and out of the box. With Spacemacs, there isn't a good file-tree pane that I can put on the left - IIRC it comes with something like NERDTree from vim, but it never worked well for me. Partially this is the whole fonts/gui/etc limitations, partly it's because a lot of the shortcuts just don't work that well. Just quickly opening up a folder, seeing what files there are, and being able to rename a file by right-clicking on it and hitting rename is something that I don't do often, but happens once a week, and in Spacemacs, that once a week necessitated either looking it up, or fixing something.

(I was faster at doing these things with vim, in which I had way more time invested, but why I switched from vim to emacs is a similar story in many ways.)

Honestly, overall, VSCode and modern IDEs are just a much smoother, better overall experience in so many small and large ways, that I feel I am much more productive, and have to spend way less time tinkering with my editor. And much as I love to do that, I've been doing it for 10 years, and already have a decent set of knowledge about what I need and want. Getting it practically out of the box with VSCode, and having it work better, is a wonder.

(My biggest block in switching to a different editor in all this time was that I had to have a decent VIM mode, because being able to actually edit text at speed and comfort is more important than all the other features to me. But once I realized that Spacemacs' vim mode was decent, I switched to that, and then I played around with VSCode and realized the vim mode there was decent too. Definitely enough to satisfy 95% of standard text editing use cases, with either plugins or my personal mappings making up the gap.)


Makes sense. From the sounds of things, we went in very different directions because I cannot tolerate mouse use in my workflow (severe RSI that got drastically better when I switched to vim). Switching to something that requires pointing to navigate anywhere or clicking is a hard no.

From the sounds of things you're used to discovery by context clicking and menu items, and emacs' lack of such things does hurt discovery. I find the mnemonic key mappings in spacemacs to be superior to those interactions, but I'll admit: only if you can actually find them, and it does take some time to get used to the conventions.

As a developer though, I am an expert in using my editor, so I'm happy doing e.g. ",tt" to run the test where my cursor is, ",tb" to run all tests in a buffer, etc. because that knowledge pays off hundreds of times a day.

Lastly I'm not sure the distinction "modern IDE" is helpful. Neo/vim and emacs are both under very active development. Useful variables seem to be things like: package ecosystem, UX, aesthetics, responsiveness. All of those can be divided into beginner/expert and IMO emacs wins all of the expert cases, _if you are willing to put lots of time in_. For example I'll take my beautiful full screen spacemacs with the bells and whistles turned on over the looks of my colleagues' VSCode any day.

"Willingness to put the time in" of course exists in a continuum. I know fantastic programmers who gave up on the effort of emacs, and others who tell me that I'm selling myself short by stooping to spacemacs instead of rolling my own. So everyone's MMV.


> Makes sense. From the sounds of things, we went in very different directions because I cannot tolerate mouse use in my workflow

I half agree and half disagree. I also really hate having the mouse involved in my workflow.

> From the sounds of things you're used to discovery by context clicking and menu items, and emacs' lack of such things does hurt discovery.

That's part of it, but not all of it. I don't use context menus much and am also a keyboard-centric user. I rarely use menus for any common tasks.

That said, things that I do once a week, but do need to do, are often easier to do using a mouse (or rather, it's good that a better discovery mechanism exists for them).

> Lastly I'm not sure the distinction "modern IDE" is helpful. Neo/vim and emacs are both under very active development.

That's true, but that's not what most people mean. I think the 'modern' comes in in terms of UX, or at least that's at the root of things - because almost everything can be done with vim/emacs, except for fundamentally changing how they look (different fonts/colors/etc). Or changing the under-the-hood stuff (like running parallel processes).

> For example I'll take my beautiful full screen spacemacs with the bells and whistles turned on over the looks of my colleagues' VSCode any day.

I mean, obviously this is subjective. But GUIs that allow a full range of colors/sizes/etc, and are not limited to only being text buffers, do objectively allow you to do more things. And it's no coincidence that almost all IDEs/editors don't use a single font size everywhere, etc.

> "Willingness to put the time in" of course exists in a continuum. I know fantastic programmers who gave up on the effort of emacs, and others who tell me that I'm selling myself short by stooping to spacemacs instead of rolling my own. So everyone's MMV.

I mean, I used vim for about 8 years, including writing (personal use) plugins and having a very large .vimrc. I then switched to spacemacs, had a bunch of configurations there as well.

So I feel like I've definitely put in a decent amount of time getting "good" at vim (and to a much smaller extent, spacemacs).

Still, putting aside the pure text-manipulation aspects of vim productivity, just launching VSCode and opening a folder gets you way more of the way to productive coding than everything I managed to roll out using a vimrc (and does't break every time I change language/computer).


Do Sublime and VSCode have anything like vim's macro system?


Yes. VSCode at least (haven't used Sublime in a few years) has a vim mode, which has great macro support. It's not 100% compatible with vim but it's pretty good.


Thanks but I'd meant in terms of having their own macro systems. Using vim macros from VSCode still requies you to 'get into vim', after all.


It's been a while since I've used vim, but I definitely recall doing multiline editing as you describe in vim. There is a visual-block mode that does multiple cursor manipulation


For the same reason I find the grammar of Kakoune a lot easier to understand. It is similarly subject first instead of predicate first.

I wish there was a NeoKak that would integrate with other environments like VS Code the way NeoVim does.


As a power Vim user, I can attest that multiple cursors do at least 75% of what I want to do in Vim, and multiple cursors are better and faster.


How about macros? I find i use them on at least a daily basis


Macros and replaying my last command at a new location are the biggest thing I miss from vim. With regex replace groups you can generally get close enough to the desired productivity though.

(Personally, I find vim's multiselect cumbersome to use compared to sublime/vscode's.)


What kinds of macros do you use?


You can build a macro on the fly to do some transformation for, say, a line of text, or even a function, and just repeat those manipulations. Usually they are crude combinations of vim inputs that work well enough for the situation at hand. Obviously it's not a replacement for IDE refactoring, but if you're using a vim emulator, you can do both


One transform I've done a few times is something where you have a list like this:

foo bar baz

And you need each line transformed into:

[Foo](https://example.com/foo.html)

Or something like that. Macros make short work of it.


Multiple cursors as well.


My multiple cursor-fu isn't good enough to know how to do that with words of different lengths. I should get more into it.


Some past threads:

Why, oh WHY, do those #? nutheads use vi? - https://news.ycombinator.com/item?id=18582221 - Dec 2018 (23 comments)

Why, oh WHY, do those #? nutheads use vi? - https://news.ycombinator.com/item?id=14153147 - April 2017 (1 comment)

Why, oh why, do those nutheads use vi? (2007) - https://news.ycombinator.com/item?id=9362786 - April 2015 (126 comments)

Why, oh why, do those nutheads use vi? - https://news.ycombinator.com/item?id=3542507 - Feb 2012 (220 comments)

Why, oh WHY, do those #?@! nutheads use vi? - https://news.ycombinator.com/item?id=151637 - April 2008 (52 comments)


Honestly, investing the time to learn vi/vim is such a productivity hack that I’m glad some old grey beards from a previous company all but forced me to learn it. I can’t use anything else now: I’m much too slow in anything but vim.


Yep, the same experience. But after seeing/trying what vscode can (with so much ease) outside of a scope of pure text editing, I now feel “scammed”. Vim’s worst side is that it’s scriptable, configurable, fast, good-nuanced, but still a “dumb” text editor that lacks integration with modern tools and techniques.


I'd recommend having a look at https://github.com/neoclide/coc.nvim if you feel you're missing out from not having VSCode extensions - it's available for both vim and neovim. Allows you to use those language servers that you're otherwise not able to in vanilla vim, with additional surrounding tooling - I honestly don't miss anything from VSCode at this point


I use neovim inside VSCode, there's an extension that works pretty well

https://github.com/asvetliakov/vscode-neovim


Thanks for the cue, I should try it the next time I feel acute missing out.


I dunno. I guess I am still in the phase of vim-plugins-are-magic. I've, over time, crafted a really robust neovim setup: I've got plugins that make git use easy, file searching, really good language server support, etc etc and all of this is done more or less native (some tools call out to nodejs powered things but shrug) and doesn't spin up my laptop's fans like vscode used to with a handful of plugins and things.


What things are you referring to?


I use vim because I haven't found a better tool for manipulating rectangles of text.

I don't do anything too sophisticated with it (after 13 years, I still navigate with the arrow keys), but I do keep my .vimrc in version control. Highly recommended.


nano is a fantastic rectangle


emacs is pretty good too with rectangles


Counterpoint: vi sucks. Emacs is clearly the superior OS.


What people usually don't understand: vi(m) and emacs are different concepts.

Vim is a language for keyboard combinations, with a full grammar that contains subjects, objects, adjectives and verbs (e.g. df2m means delete until you find the second m occurance).

Emacs on the other hand allows to flexibly bind as much as you want on each keystroke or key shortcut, which is a completely different concept.

I don't favor vi over emacs. I don't give a damn what you use, use the tool that makes you the most productive. Vim helped me to reflect on my own inefficiencies and taught me how I can optimize my own workflow. And this also applies to emacs users.

If the most efficient tool turns out to be notepad++ for you - I don't care, as long as you're happy with using it. There's no point trying to convince others to use a tool if it doesn't reflect or optimize their workflow. If they don't see the need, they won't be able to appreciate it either (yet).


Great OS. If only it had a decent text editor.


Emacs can be good, but VS code killed it.


Yeah Eight-hundred Megs And Continuously Swapping these days :)


Never noticed, didn’t even know it was an electron app until I looked it up, with RAM at $30 for 8GB at most and 16GB being found for $50 it’s easy to use. I use codium though so no telemetry, and it’s easy to setup anywhere and easy for others to understand.


That depends if your RAM is soldered in or not.


What are your computer specs? 8GB soldered ram is still sufficient for general usage, as is 16GB ram. If you have less like 4GB you’ll have way more problems in a browser than VS code.


My main “personal” computer is a 9th gen ipad these days but for dev stuff I use a bottom end M1 mac mini with 8GB of RAM. This runs VScode absolutely fine but seeing as I mostly write Go on it, I don’t really need the full weight of visual studio code running.


Haha I thought you used emacs and were bashing vs code because you used it. Why dont you use emacs?


I was stuck on an air gapped network for 2 years with only vi. It stuck.


I currently have VS code open with multiple plugins and a dozen of opened files, and it is using 33MB of RAM. Of course, vi would never use that much RAM, but for the functionnality that VS code offers, I find this acceptable.


Are you sure you're measuring the ram properly? I just opened VSCode with nothing open and it's taking several hundred MB. The main process only uses about 50MB, but it also spawns several Code Helper processes. Some of which use between 50-150MB each.


You’re reading something wrong. Mine is idling at 500Mb here with one YAML file open.


With a project and text file open I’m getting around 500-700mb, still perfectly acceptable to me.


This post is exactly what I was looking for. I went through vimtutor some time ago and have been using vim since, but I kept thinking "there HAS to be a better way to do this thing but it wasn't in vimtutor." Just using . and f is going to help me tremendously. I'd be interested in any other resources that bridge to the gap between vimtutor and the manual.


I have a list of resources here: https://learnbyexample.github.io/curated_resources/vim.html

I'd recommend this SO answer (https://stackoverflow.com/a/1220118) and this series of articles "Vim from the ground up" (https://thevaluable.dev/vim-beginner/)

I'm also writing a reference guide (https://learnbyexample.github.io/vim_reference/)


The book "Practical Vim" is written with this exact use case in mind. And it's great


At this point, using other non-vim editors makes me feel like I have one hand tied behind my back.

But maybe that's just because I'm not good with those editors. :)

I once asked my dive instructor about the debates surrounding various dive gear setups. He said, "Strive to be an excellent diver with any gear."


> feel like I have one hand tied behind my back

I’ve heard of an editor that can be used with two mice.


I've tried vim on and off for the past... almost 10 years.

I'll use it for months at a time, tell myself it's the editor for me, then go off it.

Not sure what sort of time commitment is needed, or if it's just the wrong editor for me.


I think it is not a great editor for people who want to like their editor.

Like I tried eclipse, but it was laggy. I tried Notepad++, but it is too GUI. I tried VSCode but getting it to be much better than vim requires tracking down a bunch of questionable extensions or the cool extension everyone is buzzing about doesn't have FORTRAN support.

I dunno. I use vim. I don't like vim. I don't like any editor. It is there, it doesn't do what I want it to all the time, but it reads and writes files, autocommands are easy to set up, and I can just plop whatever unix commands I want in there. vim is pretty boring and basic, but I go back to it because it doesn't do anything actively annoying to me.


The part "I can just plop whatever Unix commands I want in there" resonates with me. For example, I can select several lines and pass them to "sort | uniq -c". Or to "python -m json.tool"


I’ve used it for 22 years at this point. I still don’t know how to use more than the basics. I think you settle into a comfortable zone where you know enough and stop looking for progression. In my case that was fairly early on.

What makes me happy to use vim is the odd few hours here and there in visual studio with a large project loaded.


I used vi, but I realized it has a bunch of really powerful stuff I don't need. I have tr, sed, awk and grep for those things can heck, I have a whole shell built just for text processing.

Nano (and before it, pico) work better for me in 80% of use cases where I need to just edit text.

On windows I can use notepad++, which is probably the best win32 text editor in existence, bar none. Between it's plug-ins, and powershell (albeit with a hammer like coaxing), it's just about as powerful as the Unix environment.


I also like and use tools like sed and awk; using the vim internal tools are very easy to learn if you come from there, and they have the advantage of being better suited for working with whole buffer (multilines, paragraphs etc.), instead of on a line-by-line basis.

I believe vim is a great editor for the kind of people who like sed, awk, and working from/with the shell, since it's pretty much the same culture.


Example 1:

  bool ProcessFunkyParam(int nitems, bool properly);
  bool RecallClunkyItem(bool displace):
  bool DisposeOfAllParams(int ntrials);
This example is nice for I have used vim often if I have to look after servers, and I agree this is really nice.

In an VSCode or an IDE however, this is just as easy or easier:

- <End> to get to the end of the line

- shift + alt + <arrow down> twice to get to enable block editing and get a cursor on the end of all three lines simultaneously

- backspace once to delete all semicolons

- type <space> and one { and <enter> to get at new line, you'll also get the closing curly brace on a line below and your insertion points will be on the starting point for all the three new functions we created.

Example 2:

  if (!entry.used && equivalent(entry.key(). qk.key) && (curcontext & entry.contexts))
Here I just

- get my cursor anywhere inside the expression in question,

- press ctrl + alt + v for extract variable

- and IntelliJ pops a dialog that gives me options for how big chunk of the expression I want to extract. As I move between the options using my keyboard it highlights the expression.

- when I select it IntelliJ already creates it as a value on the line above, complete with a temporary name based on its content. The name is selected already to rename and if I type something else or accept it, it renames it both in the declaration and where it was substituted immediately.


For example 1 I bet Visual Studio or CLion or both have a context menu item, that creates implementations in the correct file and navigates you to it with ~ 4 key presses in total.

So vim loses before his example even starts, because it takes much more to select functions, copy them, switch to implementation, find a place and paste.


Exactly.

If people want to use vim and to use git only by cli, by all means, but if we could stop the cult like part of it that would be nice.

Same goes for telling students who are learning Java for the first time that it is smart to start with plain Notepad and javac.

Starting to program should be encouraging, not a hazing ritual.


One extra reason: An actual health benefit (at least for me) reducing the hand strain from switching to keyboard and mouse. Using tmux takes this to the next level.


Even in 2021, I love using vim. I can absolutely fly through the editor using keyboard shortcuts. I use it exclusively as a commandline editor though for managing remote systems.

It's not to say it isn't a bit quirky, but it is to say the tool you know how to use is far better than than one you don't.


I learned vi on Xenix, and used its clones several times since then.

Same applies to Emacs, first touch on DG/UX, although I was on the XEmacs side of the fence and it was my main programming editor until around 2005.

Both of them were a cruch for lack of proper IDE tooling on UNIX clones, thankfully those days are gone and I don't miss having them as my only option to work on UNIX clones.


They’re not willingly using vi. They just launched it and couldn’t figure out how to quit, and now they’re just kinda stuck.


That was always my intro to vi: I was (for example) doing a merge or something from git bash, then suddenly it dropped me into vi. I've made a few tries to learn vi, but I just don't edit text frequently enough to remember everything about it. I typically have to use Google to figure out how to exit it whenever some tool has it as the default and randomly drops me into it.

I remember a non-Linux friend of mine having a really poor introduction to Unix/Linux because he got bogged down in learning vi in addition to Unix's other foibles!


>he got bogged down in learning vi in addition to Unix's other foibles!

Check:

https://mobile.twitter.com/vasudevram/status/128967614667035...

It's a vi quickstart tutorial that I created.

From the start of that Twitter subthread:

[ Those new to vi / vim, hit the ground running with my short vi quickstart tutorial here:

https://gumroad.com/l/vi_quick

I first wrote that tutorial at the request of a couple of Windows system admin friends of mine (at a company where I worked earlier), who were tasked with managing a few Unix boxes, without knowing Unix. They used the tutorial and later told me that it helped them to quickly start using vi to do their work on those boxes, including editing config files, simple shell scripts, etc.

Edit: Since vi is mostly a subset of vim, the tutorial works for vim too. ]


Not that hard, just type this command and press enter:

:wa|:!kill -9 $PPID


I used to use Vim exclusively, but realized it got me into a bad habit of not separating files out well. The hassle of switching files makes me tend to create fewer of them, which can make it harder to find things later.

I still love it as a pure text editor, but for code, I've gone to an IDE and don't see myself returning.


Yes, if you want/need an IDE, by all means do. Vim is an editor, a very powerful one with all sorts of tools, but it's generally ill-advised to try and make it work like an IDE.

As far as I'm concerned, as a grey beard sysadmin, I don't need an IDE, so I value more the advanced editing features of Vim and I've been happy with it for years (more than I'd like to admit).


I have

  nmap Tl :tabnext<CR>
  nmap Th :tabprev<CR>
  nmap Tn :tabnew<CR>
in my .vimrc, to make it more convenient to work with multiple files.


I think when I edit services/jobs in rails I get some solid use of VIm, but I find navigating through files to be tedious. In rails I have to do this all the time, and short of installing plugins to make it more "many file friendly", I can't get past that limit.


`nnoremap <space><space> :ls<cr>:b<space>`

Is crucial for my personal workflow and one of the only bindings i require.

I use it in conjunction with

`nnoremap - :Explore<cr>` Which opens the best directory navigator in existence (actually dired should be named here)

This changes the game dramatically.

Read about :ls and :b


I have no issues with vscode as an editor for creating source code and the file explorer is essential. However, refactoring makes wish I'd have learned vim. I get the job done going mouse to keyboard to mouse to keyboard but it's definitely not optimal.


> I get the job done going mouse to keyboard to mouse to keyboard but it's definitely not optimal.

I've seen the rise of Vim popularity from the sidelines, I learned it at the same time as I learned eclipse, continued using vim while learning Sublime Text, IntelliJ, Netbeans and VSCode and I still use Vim.

Here are my thoughts:

If only people had spent half the time they waste on learning enough Vim to impress others learning and setting up VS Code, eclipse, IntelliJ (or tjeir language variant), NetBeans - or even I guess even though I don't like it myself - Visual Studio (the old one).

Please, please, please: at least for those who use modern languages with IDE support, take the time to consider learning the basics of an IDE.

The correct way to refactor moden code isn't to learn to study Vim for years to do it in half the time or with half the shortcuts, but to navigate to the correct line (down, down down), the correct place (2 x ctrl + arrow right) mark the code in question (5 x shift + arrow down to get the majority of it, then shift end to the end of the line) and ctrl + shift + p or something, extra(ct variable), name it and finished.

And this is just the straight forward way for someone knowing nothing but standard text navigation on Linux/Windows: if someone spends a fraction of the time some use on Vim they'll find that there are shortcuts to expand selection to scope built into modern IDEs by default.

The above can be shortened to:

- four times arrow down (we go into the middle of the mess)

- ide specific shortcut (or your chosen shortcut, they can be exported and imported) to expand selection to scope

- ctrl + shift + p to open command palette

- ext (since it is near the top of the list anyway), rename, done

Edit: there exist one good reason to use emacs and vim - they won't be integrated with Github and dumbed down over night, see for example https://news.ycombinator.com/item?id=29461226

Personally I rather learn IntelliJ, Netbeans, eclipse and VS Code somewhat fluently though.


If VSCode isn't giving you help with refactoring, either you haven't configured it properly, or the language you're using probably doesn't support refactoring in any environment.


Refactoring is one of the few things that I prefer an IDE for. I say that as someone who lives in VIM and uses IdeaVIM in the Jetbrains editors.


Vim is a text editor, not an IDE, and has limited refactoring capabilities and a poor plugin ecosystem. For fast code editing and refactoring, Vim will only slow you down.


Vim/NeoVim’s plugin support includes both native plugins in VimL or Lua and plugins via LSP.

An LSP client is built into NeoVim itself and support of VSCode extensions not covered by LSP is also available via plugin.


I’d be interested in a modal editor built with modern conventions in mind.

I love the modal editing model, but there’s no denying that vim can be a little clunky when dealing with things that have come along since, like the system clipboard.


All these features are available in IntelliJ (and sister) editors, even without the VI plugin. The keystokes are more intuitive especially with familiarity with practically any other non-vi, non-emacs text editor.


How much time have you spent with vim? How much with IntelliJ?


To be fair, lots of vim proponents obviously didn't spent much time in editors they're dunking on. The extent of sophistication mentioned for non-vim editors is "you can use ctrl+arrows to move around". Followed with "even if you like editor X, you can use vim emulation". And that vim emulation is usually just map of existing editor functionality to vim layer.

(I'm not saying that vi(m) doesn't have its merits, just that the argument can go both ways)


My perspective (limited use of IntelliJ) is that the editor is very geared towards Java, which I loath and despise. Maybe this is an unfair prejudiced. I also like working from the command line.


Ok let's be real for a second... only one of those has people googling for a way to exit it.

Like yes, a lot of people don't give vim a chance, but vim also uses a very specific style of shortcut. If you can cut and paste with your keyboard, you already use IntellJ-style shortcuts (because those are just the default style of hotkey people are used to). The same doesn't go for vim.


Based on the first example in the post, you could say that vi is a macro editor/runner, and not a text editor.

What is the first/main thing you can do when opening a file with vi? Shoot commands at it, not edit text.


Anyone using Colemak and vim? I see a lot of different ways to combine both but they all are different and I don’t know which is a good one besides remapping the home row.


Dvorak and vim here. Pro tip: don't remap. If you do it'll be hell when you have to use another "standard" vim (remote server, et.).

Good Luck suffering for some months though, it's worth it in the end :-)


Thank you! I’ll try this first.


I use Colemak and vim. I learned Colemak before I got comfortable in vim, so I also spent some time trying to figure out what is best to do.

I recommend just leaving hjkl in their default positions, no rebinding. That's what I ended up on and I don't regret it. They aren't in too awkward a position (all accessible by your right index finger). The default bindings are meant to be easily memorable, and you can use them anywhere you can find vim, even if you don't have your custom config.


Thanks I’ll give that a try first, it’s been paralyzing me from using it.


I'm getting close to be a 10-year Vim user and I've spent the last year learning Colemak slowly and paciently.

I tried remapping for Colemak's sake, but I quickly decided against it.

Now I've settled on Colemak-DH with an Extended Layer implemented with Kmonad and I'm a lot happier.

For text navigation (besides the extended layer) I just use the EasyMotion plugin, so no need of remapping. I'm really digging it.


I agree, it seems absurd when Emacs Makes All Computing Simple.


Yes, but not like ed.


cat is good enough for entering text (it’s a computer version of a typewriter), but ed is a real powerhouse.


Actually aren’t the vi commands a superset of ed? Though I suppose that means ed is simpler.


vi/emacs are old and reliable text editors for people who either like to show off or don't trust modern IDEs. their logic is reductionist and simplistic but not simple.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: