Don't use Vim for the wrong reasons (2020)
gist.github.com
gist.github.com
Unrelated: Helix is a great vim-like editor that has a selection-first editing model that I prefer and requires much less configuration. https://helix-editor.com/
I usually get an okay ping(<100ms) and if its unacceptable (overseas travel) I change the vm location. Depending on what I am working on I can increase or decrease resources and since things I program usually end up running on ubuntu servers it feels right at home.
edit- Incase anyone is wondering, I actually started doing this since one of my laptops once got lost while traveling. Airline did find mybag later, but the two weeks without it drove me crazy. Now, if I want I can just show up anywhere get a fresh laptop load up my ssh keys and im all set lol.
1. You're already in your terminal.
2. You get to use Vim (if that's your thing).
3. You don't have to use VSCode (if it's not your thing).
4. Not MS.
Our school servers have a 200-process-per-user quota to prevent accidental fork bombs; students frequently hit this limit and become unable to log into a shell, because their entire quota is taken up by VSCode SSH processes that have accumulated over months.
The combination of these two effects have caused serious problems over the past couple years as VSCode adoption has rapidly increased among the student base, to the point that some professors have banned VSCode from their classes, due to the SSH extension making the class servers completely unusable for everyone during the big rush a few hours before an assignment is due.
VScode remote extensions are really good though, the best of any GUI editor. But that BLOB it installs on remotes can take a good chunk of scarce VM RAM.
For example:
> From sketchy terminal integration, to being single-threaded, via the lack of anything resembling a proper internal plugin API, nothing in Vim can be leveraged to give you a convincing Integrated Development Environment.
I think the ecosystem is amazing, but I hardly have the patience to set things up to feature parity with other editors. Debuggers are the biggest missing/hard to configure feature.
I do, however, use Vim bindings in every editor that supports them (and extensions for browsers like Vimium).
The extensions/Editor functionality are hit-or-miss; some are missing key bindings that I use often, or features don't quite work correctly, but I find it much more enjoyable to use than the "typical" approach.
The VSCode one is pretty good (even has EasyMotion/Sneak out of the box, if that's your style), but often seems to slow down and buffer keystrokes on heavy load/undo seems very hit or miss.
There were times, now and again, where I'd use vi, or vim, on solaris, or other "weird" systems. But basically I used vim for emails and emacs for everything else, and I think that was a good split.
Were I telling somebody to start a new editor these days I think I'd probably echo the recommendation to use the integrated tutorial, but after that just "jump in". gvim, emacs, and similar have menubars that help with many things before you learn the keystrokes required and there's no shame in using them. The article suggests learning and experimenting before switching, but to me that seems very counter-intuitive.
I found a lot of issues with trying to get a “good” setup, or got frustrated that moving from one job to another meant attempting to port my working setup to a new machine and new projects. I recently went back to NvChad and have done almost no custom config and I love it.
Do you know about :termdebug and what are you missing with it? It's just dbg hooked into vim, and you can use any other compatible debugger instead if you prefer, for example rr.
That's the beauty of vim, the tools you use are the tools you'd use in your terminal anyway.
See Unix as IDE (2012)
I use vim all the time now for simple text editing when logged in to a machine but I'd never dream of using it for programming. I know how to cut and paste lines in vim and how to save and exit, nothing more needed.
I'm sure there are better special tools but vim is the most general purpose tool you can learn and use. I never had regrets to invest time on it.
One of the counterpoint is vim not being available on Windows. But It is.
Not by default, but most critical stuff aren't there by default anyway and vim will be one of the easiest block to have ready.
Then Windows comes with WSL, where I think most people who even care in passing about vim will spend their time, so we're back to the editor they'd use on Linux anyway.
That was to me the main reason I went with Vim when I first touched an nuix system, and to this day that's still a good enough reason to keep using it where a full IDE isn't required.
Any system I've seen had a simple enough way to get vim, that hasn't changed.
The "counterpoint" is not that Vim is not _available_ on Windows. It is that Vim is not on Windows _out of the box_. You must install the native binary to have it or, like you suggest, install _another system_ on your machine… that actually comes with Vim.
"Can have X" is not the same as "has X".
FWIW, experimenting with Linux is also what got me hooked to Vim (and the shell and all the rest) in the first place, but rose-tinted glasses are not for me.
But I also feel that ship has sailed for most software. We joke that windows/macos's default browser is only there to go install Chrome/firefox or any other browser of choice, and I see the wider reality of it as most OSes requirement a decent amount of installation to get to a usable point, even for very basic tasks.
It's still easier to use software that is mostly available everywhere in mostly the same shape and form (also why so many people bet on VSCode I think)
Vim is either already installed or at one click/one command away almost whatever the system you use, that's the closest we'll ever have from "everywhere" in this day and age IMHO.
Here is how I think about it: the depth of these keyboard-based editors allows for a kind of progressive mastery and you decide how far to pursue it. Plenty of people use Vim in a very rudimentary way, barely using any of the features, and they still might prefer it. Others know certain slices of the functionality available, but everyone knows a different slice depending on how they want to edit. The point is it’s sort of an open space with lots of texture and customizability, which is sometimes how professionals like their tools. It lets you sort of build the tool into what you want it to be. And that can be true even without elaborate customization: even with a stock NeoVim install, figuring out over time which subset of features you care about is a kind of customization.
One tip I have: if you use VS Code, try the Vim extension. Or whatever IDE you use, see if it has a vim mode. That is by far the best way to learn, and it may well be the best way for you to use Vim long-term. You don’t have to change editors, you don’t have to configure anything, you can just focus on moving the cursor around in a new way.
And if I want to look around a single file, I feel like anything else besides scrolling would be quite inferior in terms of speed and accuracy.
And moving around lines and words is already quite optimal enough without a mouse, using arrows and option/command modifier.
So mostly I use mouse when I need to scroll around the file or click on a certain imported identifier to move to its definition.
And also I use a lot of ctrl + f to move around, which I find quite reliable.
> And if I want to look around a single file, I feel like anything else besides scrolling would be quite inferior in terms of speed and accuracy.
{ and } jump you to the previous/next new line, respectively. Also page up and down work of course, as well as arrows or j/k. But I’m rarely scrolling in vim because I know what I’m looking for and how to get there faster.
> And moving around lines and words is already quite optimal enough without a mouse, using arrows and option/command modifier.
Fair, and in vim you have a single key to jump words (w/W) or the f/F commands (along with ;) to quickly jump through a single character in a line. Example:
This is a string and I want to get to the last letter.
If your cursor is at the beginning of the line, you can just type “fr” and then hit ; until you’re at the “r” in “letter”. Or hit $ since really you just want to get to the end of the line. Or “f.” since there’s only one period. Or…
> And also I use a lot of ctrl + f to move around, which I find quite reliable.
And in Vim you can use / to search ahead, or ? to search behind. And n/N to jump to the next/previous match. Maybe your cursor is on the word you want to find more of in the file? Just hit * to jump to the next instance of it and n/N to jump next/previous.
The main drawback of all the keypresses you see is that Vim is an imperative editor: You have to tell Vim how to edit text by glueing together lots of small commands.* IDEs are declarative editors, you say "rename this variable" and they do it.
* Ask your local Vim nerd to rename the file they're editing. It will be entertaining!
Oh that’s easy though, friend :)
:!git mv % new-name
> IDEs are declarative editors, you say "rename this variable" and they do it.
Most NeoVim setups I’ve tried recently include LSPs with code actions, so now I just hover a variable and do “<Space>ra” and I get a little popup window asking me for a new name. I type it, hit enter, and the reference is updated in all relevant files.
With an LSP integration you get the exact same functionality in Vim/Neovim.
I think maybe you shouldn't focus on the "productivity" - that's a fairly arbitrary metric, and difficult to measure - it often has more to do with how many bugs you have, how organized you are, and what you are trying to accomplish, how good friends you are with your boss/customer, and very little to do with which editor or what keybindings (or which language, even).
Instead, it is better to think about communication protocols - for a second consider something like the internet - something like handwaves, gestures, while theoretically analog and hence containing infinitely more data, they are very difficult to transcribe, send to the other side of the planet, and interpret.
I'm not saying these things cannot be done, but I imagine the internet would not exist if we had resorted to using thumbs up/down as our method of transferring information between "computers". We used a more appropriate, binary-based, protocol, and now we can send characters and have discussions! Maybe even include a couple hand-wave emojis!
Editors like vim/emacs are similar, they "feel" more productive because they are in some sense, "closer" to the code than a mouse can be. If I mainly am using a mouse (nothing else), then I probably should not be writing code at all and instead should be recording my program with hand waves, or something.
I'm not saying IDE's aren't useful, but that's because programming is neither about those mad FPS skills (mouse) or nor mad text editing skills, they are built to manipulate and mangle symbols, which is what we actually use (for better or worse) to program computers.
That's one reason why I find IDEs (often coupled with an emacs keybinding) mad "productive" - I can mash shortcuts all day long and most of my code writes itself (I'm not even using AI). I'm much closer to communicating with my code/debugger than having to mouse click around. Some of the transforms/translations are sometimes odd, or the UI environment is restrictive, so I'm using the mouse then for those situations. I often, frequently, find myself "out-coding" my peers.
But a good IDE is mostly aimed at being really good at modifying/generating symbols (in the context of a project). Its not very good at text formatting (usually handled by some plugin), for instance. And where it really falls apart, there's no control, i.e. usually it is a complicated product, with lots of pitfalls, speedbumps, "I screwed up and jacked my cache please restart me". And that nixes a lot of the "productivity" gained.
So that remains where a tool like vim/emacs/notepad++ etc shines, when you need to communicate with (roughly structured) text, they won't crash on you, they won't "get in your way", they won't need you to define an AST syntax in order to understand your little mini-language, and, at least of the extensible ones, you can define whatever it is you need or want to. IDEs are usually really, really bad at that sort of thing, if you find yourself needing to do that, you'll often 1) learn to cobble something together in a script 2) learn to cobble together something approaching that in an extensible editor 3) writing a language 4) writing a plugin to write your language in your IDE, to solve whatever it was....
- grab my mouse and click where I want the cursor, fix the typo, and then click back to where I was (or hit End, or was it Ctrl+Right? Opt+End?)
- type <Esc>Faa<Delete><Delete>ar<Esc>$
Ok, that’s a lot of weird keystrokes, but in my brain my hands just did “jump back to the a in ‘rae’, delete the ‘ra’, type ‘ar’, jump to the end of the line”.
Over a decade of Vim later and these motions are second nature to me, and using my mouse is usually reserved for the times I’m not in Vim. I can’t say I’m faster or more efficient, but I know how to get my cursor to exactly where I want it and how to manipulate, move, copy, delete, etc, in a way that feels natural and intuitive.
2 + 2 + 2 + 2 = 8 keystrokes. It also works in every single text input on macOS
Your solution is 1+3+1+1+2+1+1 = 10 keystrokes and only works inside vim.
And every other tool that supports it. I use it everywhere, window manager, terminal and every terminal program I use (via readline), my browser, and the list goes on. I rarely have to reach for my mouse, if I do it's frustrating and breaks my flow and I will fix it next time I have a few minutes to spare. I even have a shell script to move the cursor out of the way.
My method is the default working method for every single piece of software.
Lots of tools for power-users come with vim keys today, and when I choose a tool it's one of the first things I look for.
Now do it for 3 different browsers and all browser-based services you need to use daily (Like Confluence, Jira and Github).
In my browsers I use vimium, and you can embed actual neovim into textboxes with a few different addons, one of them firenvim. I rarely use GUI though and that's my point, I don't have to since 95% of my work is in the terminal.
You can do as you want of course, but that feels like you're limiting yourself to the point of absurdity.
The biggest "productivity" changes for me in any IDE/Editor is the ability to fuzzy find for an arbitrary symbol, a keybinding to search for and subsequently open a file, LSP features like "goto definition", "find all references" (and jump back to where I was quickly) etc.
Or another example - you can analyze log files in terminal buffer by folding based on patterns, multi-color highlighting, etc.
Thankfully I’m somewhere with sane tooling that watches for changes and only runs relevant tests, but back then this little foray into “how do I make Vim do a thing” saved me a ton of time.
I learned Vim because I had to edit code through an ssh tunnel, limited to text only, and nano just wasn't cutting it any more. This is pretty much the exact thing vim was born to do, so it was a pretty clear win to learn Vim, despite the horrifying learning curve. And now I know Vim!
Of course, you say, driving some expensive car means you get more attention, right? Well, yes, and it doesn't make you any better of a person...if your text editor is your car and people care about what car you drive, then maybe it also gets you some attention...
But yes it is sad that we get wrapped up in the unimportant things in life. Good to have some escapes, too, though.
But sure I guess you're right, as long as there is an audience willing to listen you can brag about anything. I can count on one hand people in my real life circle who would care about me using emacs.
Cars are different, they are related to economical accomplishment, which is more universally accepted as something to brag about.
No?
Some people want to know how to get IDE features such as errors, goto definition and type inlay hints into their editor of choice.
It's frankly hilarious to think that "it's only for bragging rights". It says more about you than anyone else.
And I think the people who watch these would be better off using a regular IDE. The only reason someone would watch that is so they can haphazardly configure vim to mimic their existing workflow. I don't know. Maybe I'm being too judgemental.
> sed, awk, cut, a quick bash one-liner, a simpler editor, an infinitely more powerful IDE, an actual IRC or mail client, an actual presentation program, some online CSV-to-JSON converter, etc.
All of these will take time to learn or find. I know basic sed syntax but I'm never 100% sure that my edit does exactly what I want, so I end up running without -i and then with. I don't know awk at all. I use cut but always mess up the field numbers, and if there's multiple spaces involved then forget it. In all of these cases, it's faster for me to open the file in vim, make the change or grab the word I need, then exit. I'm not saying the tools are useless, but vim is flexible and covers a lot of use cases.
Half these examples are gui programs. Who is realistically trying to replace a presentation program with vim? These seem like strawmen to pad out the list.
Is vim the right tool for every job? No, definitely not. But I think it does well enough that it's okay to lean on it if you already know it.
Don't use Vim for the wrong reasons - https://news.ycombinator.com/item?id=33850674 - Dec 2022 (14 comments)
Vim’s :terminal is better than win10 terminal. And than Konsole too, for that matter. (Maybe I mistaken “integration” for something else.)
to being single-threaded
Is this a problem? All language servers run async in different processes. I don’t think vscode is multi-threaded either. Multi-processed sure. Threads are mostly dead.
I’m not a vim missionary, don’t use it, don’t learn it, don’t scratch where it doesn’t itch. But these arguments make little sense. The rest varies from okay to low quality bait, tbh.
Yes, you do. This is about how Vim integrates with the host terminal emulator and shell.
I do kinda get the feeling you get when you can transfer your thoughts to screen as efficiently as possible.
But really, if your typing speed is the only thing holding you back when coding, it's a bit suspicious to me.
For example, make a key binding that moves between only functions that have a particular signature. Or a shortcut that takes heap snapshots, filters and format the output to your liking, and have it displayed alongside the source file with the suspected memory leak your hunting.
Otherwise no I still can’t get used to using j and k to move up and down even after a decade of vim.
You learn it and if you enjoy it you can go deeper. I use VSCode on my desktop and I’m not about to give up a graphical IDE, but it’s great to be able to ssh into any linux server or container and be able to efficiently edit with just a keyboard when you need to.
I tended to par Atom down to the essentials, but just like everyone else got gradually more and more frustrated with the performance and instability, so I began to play with vim and quickly discovered it's not so easy to jump in. I didn't want an IDE, but I did want some modern features like git integration, so my initial vim plugin count was reasonable. What I really struggled with initially was the lack of standard cursor movement, with select/deselect (autoreturn to insert), i.e what basically everything other input field and editor behaves like - even once I was comfortable with the vim way, switching between browser input fields and vim just felt annoying - eventually I configured my way around that so I can have the best of both.
Going full vim took some back and forth. Using it on servers out of necessity really helped. One day, when an Atom update broke my configuration yet again, I deleted it and went all in on vim, I'm not sure how long it's been now, probably 6 years - and I'm still learning.
So yeah... one does not simply recommend vim, but it is awesome, and weird.
My favourite thing about vim... I've had the same config from the start, it has never broken due to an update. I value that so much.
I disagree. Neovim can be considered an IDE with the caveat that you have to configure it as such and use plugins.
> From sketchy terminal integration
What's so sketchy about it? The terminal integration in both Vim and Neovim are decent, and you can always do Ctrl+z to go back to your "proper" terminal and do whatever.
> to being single-threaded
Sure, everything isn't multithreaded although you can write asynchronous configurations and plugins.
Regardless, Neovim is more than fast enough (and certainly much faster than the comparable IDEs) so I don't see the critique being valid.
> via the lack of anything resembling a proper internal plugin API
Neovim has a very good API for writing plugins in Lua.
> nothing in Vim can be leveraged to give you a convincing Integrated Development Environment.
That's just false and ignorant.