303 points · by sadfdsgf · 3y ago · 204 comments
Is the text editor really a bottleneck for anyone? I find that no matter how slow I type, I need to spend more time thinking of what to type anyway, if I’m doing anything interesting.
When you're not proficient with the necessary tools, you're interrupting your flow with what you consider mundane. That you consider text editors mundane is more reason to move as much of that process into muscle memory as possible, not less!
Why are we pretending like mastery of our tools is unimportant? I hear this sort of opinion most eagerly expressed by engineers who in fact are quite handy with vim! Is this some new kind of flex where we're all pretending to take a purely academic approach to programming instead of becoming proficient with the tools of our trade?
On the other hand, tools like Vim, Kakoune and Helix shouldn't be treated like your average Java IDE, for example, which shifts the line of what I'd say is reasonable learning investment. What you're dealing with there is a programming language for text manipulation. If you're fluid enough in it, you open your mind for solutions you'd never have considered before. I'd say you'd need at least intermediate Vim skills and should know macros until that effect kicks in.
I have quite some anecdotes about e.g. creating integration tests where my colleagues wouldn't test something properly just because doing so would involve 10 minutes of drudge work in their simplistic editors, instead opting for "deploy & pray" when the task was totally doable in a couple of seconds with a Vim macro. I find that at least in this regard (as for all programming languages), Benjamin Lee Whorf's quote certainly holds true: "Language shapes the way we think and determines what we can think about."
That's why I also think GP had a point. I would probably be much more in your line of thought if we were only talking about the usual contestants like refactoring snippets etc. here, although even having them handy will already influence how many of us work with our code.
Edit: As another analogy, I feel that modal editing has about the same effect on thinking as switching from roman numerals to arabic ones. The reason why it hasn't completely caught on is just that it's less intuitive and text manipulation is not as fundamentally important as calculations for our civilization.
> I hear this sort of opinion most eagerly expressed by engineers who in fact are quite handy with vim!
But to me, that makes me think that you should wonder whether there's something to that. For me, you're right, I did get really handy with vim at one point. After I had been using it to a very basic level for two or three years, I felt kind of sheepish and guilty and endeavored to learn it properly. So I bought into doing it "right" for awhile, wrote a bunch of custom script to customize it, the whole shebang. And my conclusion after that was that it wasn't really worth it. I went back to just using the basic stuff. This is also, importantly, supported in every IDE's keybindings, so I can use modal navigation and editing anywhere without needing to customize anything, which is pretty great.
For example, is it really still OK to have little to no visual feedback when entering commands with range/count prefixes, or to have to fall back to custom commands and configs in order to search for strings containing "/"? Or have commands with tiny edit distance between them do radically different things (e.g. "w! " and "w !")? Vim's modal editing implementation also can't handle non-Latin keyboard layouts so I find myself switching keyboard layouts all the time (e.g. normal mode->insert mode->layout switch->type some text->layout switch->normal mode).
This issue is solved by langmap.
I think it is just not so tricky in the first place. If you start out with “you can use hjkl for directions, and y for copy, d for delete, these can be combined with directions and prepended with numbers; remember the modes, and :w and :q” vim is already as good as most others editors. Then I’d just start using it, rather than trying to learn from the top.
My filter for when I should learn a new feature is when it solves a task I find repetitive and annoying (or I will make a post on Hackernews that says learning Vim is useless, to get a list of features that people actually use day to day). Since we all have different idiosyncrasies, this filter will be different from person to person, so I don’t really get the idea of a guide.
That said, I’m just describing what worked for me; if someone wants a guide they should go for it, we all learn differently after all.
There! You said it so well... that's the #0 reason why I go RTFM'ing, because most likely my problem fits a pattern someone already encountered and figured a solution for. Or nobody did and I put together a less annoying workflow to deal with it.
Sometimes the effort is worth it, but often it is just fun trying out new things/techniques.
Besides that, I just find the whole method of navigating (skipping words, skipping an X amount of lines) counterintuitive. It's nothing I can get used to, I will always miss the precision of just taking the mouse and getting the cursor exactly where I want it in one sweep and click.
Then vim ain't it.
My "vim-empowered" colleagues spend significantly more time trying to find symbols, related configs and tests, function definitions and interface implementations than I do. Because their hodge-podge collection of vim plugins and extensions rarely amounts to anything more than a full-text search across the whole project.
But sure, you can count the number of lines where you need to go and then the number of characters/words you need to move in the line and code it in 3 characters. By the time you've done that I've clicked there with the mouse, found the definitions and done project-wide refactoring.
Some people just like playing with tools. They do it for loads of reasons, but end of the day it’s basically a hobby tangentially related to software development.
I torment a friend of mine who talks all the time about VIM and their most recent config/workflow. But end of day, he’s happy and having fun while being productive.
Every month or two I'd read a manpage for something and really experiment with using all the facilities - most of them wouldn't stick, but every now and again some would.
Just pick something like "less" or "bash", read the manpage, and try using something you've not done before. It's very helpful.
For Vim I went through the tutorial a few times a long time ago, and that really helps. (For twenty years I used emacs for "everything", and vim solely for email, via mutt and later my own client.)
Then I saw someone using Vim. I was instantly hocked. The sheer speed of everything happening in the screen, I needed to learn that. And so I did and it’s been an amazing ride.
It’s a pain at the beginning, the amount of time I invested in my .vimrc will probably never payoff, mathematically speaking. But the joy and delight you get from using it everyday, the freedom and efficiency is just addictive.
It’s not for everyone, I was raised on the Mac paradigm, where “modes are evil”, so it was a step learning curve. But few programs have brought me this much joy and excitement over the years.
It just removes a lot of frustration, that's the thing for me. Working less on fiddling with text is focusing more on the conceptual level. Again, I'm not claiming the output is better, I'm just happier doing it.
It really doesn't need to be this mystical uber-hacker thing to be useful.
I want to select from here to just after that letter P. With hjkl and visual mode I’m already halfway there. Whenever I try something clever I always find myself thinking “is that the end of a block? Or maybe I should cut directly to P but oh there’s another one on the line above so it’s the second, need to amend” etc etc etc.
Also "dd" and "p" a lot to move lines around and "J" to consolidate them.
So maybe I do use a pretty large amount of functionality pretty frequently :)
I've been thinking maybe that other comment nailed it and most of us who downplay how useful it is to really learn vim have just already done that and forgotten that it was really useful.
It true that thinking takes more time than typing/editing even you type slow and don't use any hotkeys for editing, but I have a feeling that the less time/effort I spent on typing/editing the less my thinking is interrupted.
With some practice one can use quite a few vim features relying on 'muscle memory' to spend less time/effort on editing and concentrate on what matters - thinking.
Though I no longer program, I am still a huge VIM enthusiast, but no it is not necessary to use VIM. I just love it because it made me more efficient, but at times I think that writing code really really fast might actually be a bug and not a feature.
For editing code it's amazing though. People looking over my shoulder used to think I was a wizard.
I normally build in a terminal anyways so this was a pretty nice little speedup for iterating on static analysis results or a build problem.
This means it can help keep out intrusions about editor maneuvering from your mind at work.
Some people see no value to this and fill their vim bundle with plugins that slow everything down a lot, but some of us really enjoy just surfing the high source and watching our thinking materialise on the screen seemingly effortlessly and immediately.
I use IntelliJ all day every day too, but it's mainly for admin and control stuff and certain types of refactors it can handle better. It's to my code editing as gitk is to my version control. It's where I run the tests, all the plugins, can get docs prerendered, things like that.
It's not where I can quickly navigate the code base, jumping immediately from file to file as fast as a fuzzy hint can get me, and then within the file as fast as Space+string can get me. You might have a keyboard layout with a forward slash easily available, mine doesn't so in normal mode space is /. Navigating in vim can be hjkl w b and so on, sure. But it can also be search. Just say the place and poof, you're there. It's wrong but very similar to where you want to go? n for next or try to name a new place.
This doesn't work in IntelliJ and it's a little off in emacs. I mean you can certainly technically do it but it's slow. There's waiting and the application twitches when it tries to imitate the vim way. Pretty much all finding tasks can be powered by fzf and ripgrep, and unlike IDE:s vim just does the thing when you tell it to. There's is no wait and then a dialog, there is none of 'ok, understand but Ide competent, knows many things, need more info before can do the thing' that tools like IntelliJ and Visual Studio do.
You also want jk to be Esc for sure. Esc is far away and CapsLock is for Control.
Ctrl-[ is the same keycode as escape in terminals, and it's much easier to reach. For me, remapping jk in insert mode results in lag after typing 'j'.
If you want a plugin that makes it so that the j appears immediately regardless of whether you're trying to invoke the keymap or not, you can use something like https://github.com/nvim-zh/better-escape.vim
It only creates lag if you actually want to type 'jk'. Otherwise, you keep typing like normal, and it doesn't matter. You should be able to config the delay, too. I use `fd`, and I can count the number I've noticed it.
That little lag on the j doesn't matter, when you notice you're already a few keys ahead anyway.
> 'ok, understand but Ide competent, knows many things, need more info before can do the thing'
Do you think everything through and then implement it? I do most of my thinking as I type.
This last weekend I gave LazyVim a try and it is by far the most sane config setup I have used and I will now be sticking with it.
There is a starter repo where you clone it, delete the .git directory and start customizing.
https://github.com/LazyVim/LazyVim My config is here, feel free to copy/steal it. https://github.com/curtbushko/nvim
- Most distros seem to like wrapping functionality and having you use their own convenience functions to get things done. For example, for AstroVim, astrovim.<function> is all over their config files. This is fine if you were a distro developer and you were trying to make things easy for yourself but I do not find it easier for the user when neovim already has simple lua based functions. It is another barrier to entry as you have to learn how the distro authors put things together. - The config for LazyVim is will thought out. For example, it has 2 directories: /config & /plugins. That makes it simple to figure out where things should go. keymaps go in keymaps.lua, options go in options.lua... it kind of makes sense. - The plugin config for disabling a builtin plugin is the same as where you would configure your own plugins. It is literally:
return {
{ "github/plugin.nvim", enabled = false },
}
vs return {
{ "github/myplugin.nvim", {config here if you want}},
}
- There are no weird plugin loaders and most examples you see from plugin authors are copy/paste into that bracket section.
- The LazyVim website is decent. Not perfect though. https://www.lazyvim.org/
- The starter is a great place to start your setup. https://github.com/LazyVim/starter
- The plugin manager, lazy.nvim, seems to be a lot simpler and well thought out compared to others plugin managers (like packer). It has autoloading, caching, a UI, etc.
- Folke, the distro creator, has written many popular plugins and knows quite a bit when it comes to configuring plugins. That seems to be paying off in the design.To be fair, there are some design decisions that I don't agree with when it comes to the LazyVim layout itself. Putting everything in editor.lua or ui.lua instead of per-plugin config is not how I would have done it. It was pretty easy to figure out where the plugin settings were though because they match the categories on the website.
Note: I mainly switched to Neovim as I am find that there just seems to be much more development in the ecosystem and the number of amazing plugins coming out is staggering.
For me, I was fed up maintaining code to run my neovim setup the way I want, so I was looking for a configuration distribution or... something else.
Helix was the dead simplicity I was looking for. It has its own warts and drawbacks, but the tradeoffs are well worth it in my experience. I absolutely love Helix!
But if you want your editor to work exactly the way you want and having maximum flexibility is more important, you will not like Helix, which is extremely opinionated and has 95% of what you want in a modern text editor. The other 5% may be a deal breaker for you.
And that's fine! Use the tools you love!
And no extension interface for helix another big positive for neovim and even vi
I can customize Neovim the way I want and the plugin ecosystem is huge. Maybe when Helix gets there it will be worth the switch.
p.s. kakoune style of modal editing makes so much sense and I wish vim had started out like that.
It's nuts, but if asked, I don't even know how to do certain things in VI; I just do them. Ask me what keys to press to go up, or down, or right or left? I dunno - I just do it. Yea it's nuts. It's like baby duckling bonding - the first editor mindset (aka EMACS vs VI) you use, you just bond to and it just is natural. Not better, just natural.
At the same time, I don't utilize it to its full strength. I probably do things that seem laborious to some, but no big deal to me.
You surely know those are not acronyms, yet I've seen VIM miscapitalized many times, even by experienced users, and it's always slightly irritating.
EMACS, while historically accurate, also isn't common anymore.
I see a way to get "VIM" out of that.
Though it looks like originally, in 1993, you'd have read: "Vi IMitation":
edit: clarity
1. instead of doing 4j I might do jjjj
2. if I'm in the middle of a word and want to change it, I'll do bcw instead if ciw
3. if I want to copy 3 lines, I'll do Shift-V+jjj+ESC, instead of just 3yy
4. (possibly other 100 items here...)
But I find it very hard to change those habits. Anyone else struggling with this? Any tips to share in case you managed to get rid of them?
You seem aware that there's an alternative way of doing the things you want, and seems like you've tried doing things the alternative way, but it "doesn't stick" with you.
You don't really have to start using the most absolutely 100% optimal way of achieving something in the least amount of keystrokes (unless that's actually your goal). As long as your editor doesn't get in the way, I consider it a win already.
So I don't think you're "losing" anything. If the alternative way really was something that actually benefited you, you'd have probably picked it up by now if you actually considered it better than your current habits.
For example:
> 1. instead of doing 4j I might do jjjj
> 2. if I'm in the middle of a word and want to change it, I'll do bcw instead if ciw
> 3. if I want to copy 3 lines, I'll do Shift-V+jjj+ESC, instead of just 3yy
If you want to copy all the body of a 100+ line function, I bet you probably do something like `Vi{Y` (or similar), even if it slows you down a little, because you know the slight pause is still better compared to mashing the `j` key 100 times.
Yes, you can probably do it like `yi{`, but the difference doesn't matter (especially once one of them is in muscle memory), and it's just preference.
Even something like `V50j50jjjj` for 103 lines (with the "50" being picked arbitrarily) is already a win.
A decade ago I decided that I should probably learn the idiomatic way to do things and went through different learn-to-vim tutorials but none of it ever stuck. I finally decided that the way I use vim is the way I use vim, and when I can’t figure out how to do something and can’t do it with another tool, I’ll learn a little more which may or may not be retained.
There’s a mountain of things vim can do and adding plugins on top of that makes it a never ending climb that I’m happy to climb as I need too.
That doesn’t really answer your question, except to say, me too, and that I’ve just let it go. (And vim is compete’s with a web browser as the program I spend the most time in).
You'll slow down, reason about your next best move, which slowly helps mastering those optimizations. Not only because they are shorter, but because sometimes they work, as opposed to visual selection etc.
An example: you might find doing jjjj easier when it's a one shot task, but for macros you mainly need "down to the end of the paragraph" (}) and so on.
It may even be counterproductive as non-trivial efforts to establish such habits will have cost. Less efforts will be spent on forming habits of spotting bugs in the code.
But then the question should be what is the end goal here? Is it faster edits in Vim or is it to get job done?
I've got an Emacs plugin installed that's kinda like easy-motion, and actually have started to use that.. but I think I'll be sticking to eg. `hhjjjj` for the rest of my life.
I write a lot of Lisp, so I wonder of learning more structural editing commands (eg. something like `jump-to-sibling-sexp`) could help me map my intents more cleanly, but wouldnt be able to carry that into other languages and expect I'd fall right back into my old ways.
Maybe it just isn't so bad. When your findger is on a key, there's a lot of value in not moving at all. Counting is taxing and lacks feedback, which is why I hate resizing terminal panes. Maybe there's more power in learning and integrating new habits, like easy-motion or search-forward (even for short distances), than in eliminating old ones.
As an aside, the most jarring thing about going back to Vim from Emacs (which I do multiple times a day) is not having nornal-mode & co. in the mini-buffer / command-line. Love how emacs treats it as just another buffer, so even eg. visual-mode works in there.
That's how I thought of it anyway, not delete n lines. Delete from here to here.
A new user coming to the Vim ecosystem in 2023 would be best served by using Neovim with Lua.
I went through trying to customise it perfectly but I found it is better--more portable for one thing--to learn its defaults. I enable a couple of things, like mkview and tabstop etc, but no more than 10 or 15 lines.
My only criticism relates to the fact it's an editor, not an IDE; there's vimscript and I've made various vimscripts to give it IDE-like functionality, but the plugin system, and plugin systems, or lack of a in-build one, let it down. And it doesn't seem, unlike emacs, that is was designed with extensibility in mind.
But as an editor: it's unparalleled.
The author also quickly introduces helpful concepts like :h, .vimrc without going into too much detail up front.
From the first chapters this seems to be well structured according to what you need to know when learning not according to some natural structure of the topic as perceived by someone who is an expert already.
I feel like I should be able to use a tool without thinking and without having to learn how the tool works, at least in regards to text editing.
And I feel that nano or pretty much any other editor except vim can be used the same way, just like a notepad on Windows or gedit or geany, you open a file and you start editing or you move to the desired location using the arrow keys or a mouse and start editing.
The very joke of "How to exit vim" feels like a good example of bad user experience and poorly developed tools.
Crude example: Imagine if you couldn't drop a hammer and it was just stuck to your hand just because you didn't know that you had to type :q!.
But since I know how to use it at least the basics it is somewhat comforting knowing that pretty much any machine I'll touch will probably have vim pre-installed, so I don't have to spend time searching what is the name of the program to edit files. I have seen that some have an alias 'edit' to whichever is the default one, but thus far 'edit' hasn't worked on any of the machines I've tried.
Yes, vim can do a lot more then just edit files, but at the end of the day...
I just want to edit, compile, fix, repeat. (https://youtu.be/wBoRkg5-Ieg)
https://gumroad.com/l/vi_quick
From the start of a Twitter subthread I wrote about the tutorial (thread unfortunately deleted later by accident - Twitter should have an undo feature like vim, heh):
[ 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. ]
On the other hand, I've never considered typing speed or editing speed the bottleneck in programming, it's usually debugging, solving problems, or reading files with 10k+ LOC and multi-hundred line files figuring out what they are doing.
I have a vim config I have used for years, but I have just gone with it now and embraced VS code, it's a brilliant tool.
There's very little in the ways of needing to configure Helix; it has built-in most functionality that you'd find with batteries-included vim "distributions" and it works out of the box with the installed LSP servers on your system.
I can't use it yet because of the lack of addons/an ecosystem, but I hope to one day either move to helix or bring as much of this sensible keybindings system over to neovim as possible.
I've tried vim-as-IDE many times and personally I've found that I just don't have the patience/discipline to get it all set up and not have it become a huge time sink. I end up getting frustrated and start up VS code and what do you know, everything works absolutely perfectly with zero config. So why bother. New programming language? It literally pops up telling me what extension to install and < 5 seconds later it's working.
Installed helix, and nothing 'worked'. LSP wouldn't start, syntax highlighting didn't work, and once I did get them working, editing JSX caused strange issues where the autopair functionality created a duplicate of my code several lines above where I was working..
Not particularly impressed tbh.
It was very fast to start and use the fuzzy search though.
Personally I have one hell of a config, but since you’re fine with vscode defaults, the only thing I’ve really done to vim that counts was cloning ale into a specific vimfiles directory. What was your package set?
jvm language goes to the IDE. Others can use vim.
Your comment makes it sound like you think it's a small amount? I get that it's over 35 years, but still!
I'm happy enough with config generated from: https://vim-bootstrap.com/
(I still love it though)
I don't get why there is so much talk about RSI. Speed is nice, but it is not the end-all be-all as far as I am concerned.
If you're coming from nano, I'd point to:
1) UI improvements like better syntax highlighting, split windows and tabs, and mouse support.
2) A cohesive language of key bindings that allows you to easily construct and perform commands like "delete everything from the cursor up to the next quotation mark" or "lower-case this paragraph".
3) A huge library of scripts and extensions to add or extend features like syntax highlighting and indentation rules for new languages, Git integration, or language server support (which provides IDE-style features like jump-to-definition, error/warning indications, and autocompletion)
Speaking as a life-long vim user.
- LSP and all its uses - jump to definition is a big one.
- Window management - while you can use a multiplexer, using one session allows copy/paste to work, saves your file/search/command history, etc.
- While often overstated, it is undeniably more efficient... once you've learnt it.
However, if you are not doing programming, but are just editing e.g. Linux config files, then I would probably stick to nano (in fact, I usually use nano for these jobs, since getting my neovim config to work when running as sudo failed).
And on this note, I'd recommend not jumping in and trying to learn everything. Too easy to get overwhelmed.
Start with the bare basics and treat it like nano with syntax highlighting, then start learning and getting used to its broader functionality in small bursts.
I love vim and find it an incredibly productive tool, but it's rare that my editing speed is the limiting factor.
However, in recent years with LSPs, the suggestions and completion are something I really wouldn't want to give up.
I'll do a simple one then, as an example: In vim you can select a range of lines and indent or dedent those lines. With spaces or tabs as appropriate, set per filetype (or other ways of configuring). Can this be done in nano?
You can easily control exactly what portion of the line or file you are making the edit to, and Vi will not allow you to change beyond that area without a further intentional command.
But if you occasionally use other editors, many of them have plugins or modes enabling Vim keybindings. In my daily work I switch between Emacs, IntelliJ, Vim and XCode, and all of them have varying degrees of Vim emulation, which makes switching a lot easier.
There's however one thing I don't hear very often: Vim is not a text editor with "powerful" features such as useful keybindings. It's more a language for editing text. As with programming languages your ability increases super-linearly as you learn to compose keys.
Google for „Emacs from scratch“ which will guide you through.