6 ms·
Vim Language, Motions, and Modes Explained (2023)
- 000ooo000 1y agoHere come the "[..] anyway I'm happy with VSCode" comments
- vachina 1y agoVim feels equivalent to a horse carrier in comparison to vscode to a modern car.
- PaulRobinson 1y agoTo me, vscode feels like a huge truck with too small an engine, and vim feels like a sports car.
- wildknocker 1y agoAlso comes with all the downsides of a modern car (ads, random BS, blackboxes, etc...)
- w4yai 1y agoI feel like those trying to teach me Vim are the same who refused to learn to use VsCode. Once configured, I can do the same than Vim. With more features.
- sussmannbaka 1y ago> Once configured is doing some heavy lifting here. "Once configured" vim can do the same you can do in VsCode. Editor wars are really the dumbest nerd fight.
- PaulRobinson 1y agoYou do you, but I'd be curious to hear what you think you can do in VS Code that you can't do in vim - what these "more features" are. Vim, and Neovim, have an expansive plugin culture. They are designed to be very configurable and customisable, so that the software fits around you and what you need to do. What features do you find missing? Also, I get that you feel vim users are being a bit evangelical - "trying to teach", as you put it - but I can assure you that I, for one, have used VS Code plenty (including using vim keybindings), and it's just not very good for me. It doesn't fit me. It's slow, it's not as configurable to my needs. I sometimes have nothing more than my iPad Pro (and magic keyboard), with me - I can mosh/ssh into a dev box, tmux up a session get to work easily, I never found a nice way to make VS Code work in this pattern. What's the point in being a software engineer if you can't have software that fits you? Yes, vim has a learning curve, but then I get to make it my own and make it fit what I need. Same with tmux, my shell, and so on. In my experience, VS Code forced me a little more to fit to it rather than the other way around. Like I say, you do you, but don't think all vim fans are talking from a place of ignorance.
- cess11 1y agoI find VSCode to be sluggish and buggy, especially plugins, and also gave up on figuring out how to rebind jk to Esc. I also don't trust the telemetry flag, so I'd rather not open any proprietary projects in it. It also can't run in a terminal, as far as I know.
- lawn 1y agoSuch a bad take as once configured Vim can do everything VSCode can and more.
- quotemstr 1y agoTechnical moncultures are bad. The VSCode people ought to at least tolerate VSCode refuseniks as a kind of endangered species, worth keeping around out of a mixture of sentiment and insurance against memetic stagnation
- tgv 1y agoI've grown up on vi and later emacs, but VSCode is no joke. It does almost everything, and most of it better, and more intuitively. There's no reason to torture yourself with counting characters, words or lines in order to get the delete command correct in one go.
- sgarland 1y agoThe single most intuitive ah-ha moment I’ve had in Vi was the change verb. Change In <object>: ci( means “change the text within parentheses.” Change unTil <object>: ct& means “change the text until an ampersand.” And so on. It just makes sense. VSCode never had moments like that for me. It’s fine, sure, but it wasn’t anything special.
- tgv 1y agoNo, it isn't, but that's perhaps the point: it's so direct. It rarely gets in the way. Sure, some things are easier done in emacs, but that's when you just copy the text to emacs, do your thing, and copy it back. What VSCode isn't, is elegant. I think the OP likes that very much, and VSCode has forsaken that in favor of simplicity and a kind of free-for-all extension mechanism.
- Izkata 1y agoYou may love to learn then: Those aren't part of change. "i(" is a selector (see ":help object-select"), and it also works with "y" or "d" or even in visual mode. Likewise "t" is a movement that can even be used on its own. There's also a sibling to "i", "a", that includes the delimiter used, and "t" is a valid delimiter for HTML or XML tags.
- metaltyphoon 1y ago> There's no reason to torture yourself with counting characters, words or lines in order to get the delete command correct in one go No one proficient in vim does this. Just use relative line line numbers or delete words in full with ciw.
- 000ooo000 1y agoThat's such an overtly bad characterisation of Vim editing that I can't take your reply seriously.
- 1oooqooq 1y agodon't forget to do a conversation class on speaking regex fluently.
- rgoulter 1y agoIt's funny to see Helix mentioned, without kakoune being mentioned. Helix is a really nifty terminal editor. It aims to be nice out-of-the-box, to have good LSP support, DAP support, and Tree-Sitter support. Compared to vim's "action motion" keybindings, Helix goes for "motion action" (which kakoune popularised). I find this is frequently more intuitive. Helix also has neat discoverability.. with pop-ups showing you what the available keybindings are.
- drekipus 1y agoI think kakoune invented motion action keybinds, but Helix is the one popularizing it. I love helix because it is very fast, it supports everything it needs to, and the built-in help/which key. It's what I wish vim was. Shameless self-promotion of a discussion thread I started. https://github.com/helix-editor/helix/discussions/13399 https://github.com/helix-editor/helix/discussions/13399
- klauserc 1y agoI found Helix much easier to get into than vim because you can see and experiment with the selection before committing to an action. It's also much more familiar to users of modern software (where you generally first select an object and then apply an action).
- inatreecrown2 1y agoI want to use Helix but can't until it supports running external commands.
- mac9 1y ago[dead]
- Macha 1y agoI've been experimenting with Helix in the last month. One thing that's slightly frustrating is the key binds are running interference in my brain with the vim keybinds. Especially the x/d swap. It might be because I still use vim keybindings in other programs, but I find I'm now also worse at vim than I was before I started helix. The discoverability is definitely a big nice feature, I definitely use more e.g. tree-sitter motions because I can actually remember them unlike in my plugins in nvim.
- hatmatrix 1y agoI've tried Vi/Vim key bindings on several occasions, but just couldn't be efficient in it. It's often touted as the "superior" form that confers benefit to those who invest time to learn it, but discussions with other coders have led me to believe this is just confirmation bias by people who prefer these key bindings. There are people like myself who edit frequently while writing (even with in a single sentence or word), so this switching between normal and insert modes to do chunks of each operation at a time incurs a heavy cost. Yes, there is Ctrl+[ for single commands, but this is still an additional step compared to the key chord model of Emacs for instance.
- susam 1y agoI use both Vim and Emacs, extensively, so I'd just like to share my experience with mode switching in Vim. Personally, I don't find Vim mode switching to be much of a problem while editing text. It has become muscle memory to stay in normal mode by default. After any insert-mode operation, I instinctively return to normal mode. It's just a habit at this point. Take, for example, writing a for loop. I might type: for (int Then, say, I pause briefly to think about the variable name. If you happened to look over my shoulder at that moment, you would find me in normal mode. Even if I only pause for a second, I reflexively return to normal mode the moment I stop typing. Because of that, I don't really treat insert mode as a separate "place" in my mind. Let's say I want to insert the text "abc". I don't think, enter insert mode, type "abc", then return to normal mode. I just see it as a single action in normal mode that includes the key sequence "i a b c ESC". Or say, I want to open a new line above and insert "xyz". Again, I think of it as a single operation in normal mode that includes the key sequence "shift+o x y z ESC". This applies to all insert-mode operations for me. Normal mode feels like "home" and insert mode is just an editing phase I dip into when I need and exit. That's why it doesn't feel like I am constantly switching modes (even though I am).
- quotemstr 1y agoIt never made any sense to me that people claim Emacs has no modes. What do you think you're doing when you hold down a modifier key? What else would it be except entering a mode in which other keys have a different meaning? Is that really different from vim's mode switching? They're just different ways of expressing modifiers.
- JSR_FDED 1y agoSeparate from the usually mentioned benefits of Vim, it cured my RSI completely.
- rochak 1y agoThis is such a big pro imo. Gone are those days when my hands/wrists used to be in pain from all the typing. Vim removed all that pain and made me look forward to typing as a fun activity. God bless Bram.
- loloquwowndueo 1y agoDitto, I switched to vim after horrible pain from eMacs’s required multi finger contortions and it helped to the point rsi hasn’t been an issue for me for 20 years.
- deleted 1y ago[deleted]
- seafoamteal 1y agoYesterday, I used vim motions to clean up some JMH benchmark log data to a CSV. It was genuinely so useful to be able to precisely delete and replace based on regexes. I'm sure I could have done with a graphical find and replace, but it was definitely faster via vim, especially after recording macros to automate the repetitive edits.
- Kichererbsen 1y agoYes. So much this. I've also always loved combining that with the macro functionality. Except: Yesterday, I used an LLM (4o-mini-high) to do this kind of task instead and i might never go back.
- seafoamteal 1y agoI considered it, but there were hundreds of lines of data and I cba to verify all of them once they'd been through the LLM.
- gcarvalho 1y agoOne thing I really appreciate about Vim is that it just opens. And I don't mean speed, I mean not getting bunch of pop-ups nagging me to do something about a configuration, extension, feedback or whatever. I'm not going to claim Vim's defaults are usable for most people, but my god can these IDEs just shut up and let me see my code? I'll go to the settings if I want to.
- volemo 1y ago> can these IDEs just shut up and let me see my code? May I interest you in some Emacs? It’s arguably much more of an IDE than Vim, but it still “just opens”. And you can bring your muscle memory with you thanks to the Evil mode.
- PhilipRoman 1y agoSorry Dave, you'll need to create a project, configure the SDK and log in with your GitHub credentials before I can let you edit README.md
- submeta 1y agoYes, it’s super handy to be able to record an Emacs macro and modify large text within seconds, something that would take me half an hour. Yes, it’s super cool to navigate text at lightning speed. But honestly, I have seen engineers who work with the mouse to navigate, and use nano to edit text in the terminal, and IDEs from intelliJ to navigate their codebase, engineers who were 10x as productive as I was. Why? Because in the end navigating your text is not what determines engineering success. It’s convenient, yes, but that’s not the core challenge. These days devs using VS Code can be magnitudes more productive just because they focus on the things that matter. Edit: Don’t get me wrong. I love my (mechanical) keyboard. I hardly use the mouse. I have a shortcut for everything using Keyboard Maestro, Karabiner elements, and I use Emacs for text editing, and all of that makes me super fast using my computer. But all of that does not make you a better engineer (I am not an engineer anyway). So spending time on other qualities (being able to do research, to solve problems, to manage knowledge, to communicate well, to document well) is way more relevant for your success as an engineer.
- bspammer 1y agoYes people who talk about vim being more efficient, are in my opinion, misguided. For me it's very little to do with efficiency, and much more to do with creating a more pleasant experience writing text, especially text with an exploitable structure (code). I really enjoy precision, and that's what vim provides. It's the same reason I'd much rather play an FPS video game with a mouse and keyboard, than an analog control stick. And the same reason I hate doing anything important on a touch screen.
- lawn 1y ago> Because in the end navigating your text is not what determines engineering success. It’s convenient, yes, but that’s not the core challenge. That's true, but it's still very helpful. I'd argue that programming isn't the core challenge either, but it would be foolish to dismiss it entirely.
- skydhash 1y agoVim is not about speed. It’s about efficiency (less effort) and programmability. You can do the same or more editing actions with other tools, but with Vim (and also Emacs), you can make it effortless.
- bcrack 1y agoI think an important part of the Vim workflow that I haven't seen mentioned is the fact that -at least for myself- it keeps the mind engaged during "menial" operations. When switching from dealing with the information included in the text (typically thinking about code content) to operations of moving text around and other text logistics, I often find my mind "waiting" impatiently for my hands when using non-vim editors. In contrary, when using vim (I consider myself a mid-range user), I can somewhat remain closer to the flow. At the same time, I still remember (albeit vaguely) a significant overhead of the Vim language before becoming acclimated.
- lukasstoecklein 1y agoI don't understand why people say there is an overhead. Press 'I' for insert mode gives you the same behavior as non-vim, so your immediately at the same efficiency. What am I missing?
- bcrack 1y agoThe overhead exists when a novice is trying to use Vim the way it is intended to be used in order to learn. Using insert mode to get the same behavior as non-vim and avoid normal mode is, in my opinion, bad learning practice.
- SaintRomuald 1y agoI tried vim motions as a daily driver many times but, I don't think that with today's expansive IDEs vim motions are all that superior. IDEs have very competent shortcuts and features built in. My biggest problems with vim are lack of feature discoverability and the fact that you can't change the keybindings. It's very hard to learn new things in Vim without specifically googling for them. It's highly likely that if I sat down to some online course I could learn a lot more about the Vim way of editing but I could never sit through one long enough to discover new things, so most of the things I learn about Vim come from me specifically looking up how to do certain things, not a bad way to learn, but I feel like I never got extremely proficient becasue I didn't go deep enough. I find a lot of the keybinding to be unintuitive or not very ergonomic or inconsistent, but I also don't want to rebind anything because part of the reason vim is so useful is the fact that you get this tool with every linux install and changing things means you're no longer using The Vim. On the contrary it feels perfectly fine to tweak your IDE's keybindings because that IDE is already very specific to your needs.
- chongli 1y agoYes, vim is not intuitive. It doesn’t teach itself to you. It takes hard work. I bought the O’Reilly vi/vim book [1] and read it cover to cover. I practiced a lot of things and was very deliberate about it. To me, learning vim is like learning a musical instrument. You’re not going to get there without committing to it. For many people that’s just not going to happen: they have neither the time nor the inclination/energy to do it. That’s totally fine! There are loads of other tools for people to use and they get by just fine without vim! I think my main complaint is that there aren’t a few more tools like vim. Almost all software is designed for people to be able to pick up casually and be able to get work done at a passable level of productivity without ever reaching mastery and flow state. Tools like that (easy to use but with no real incentive for mastery) are deeply unsatisfying to me for a lot of reasons. I guess what I’m saying here is really just a restatement of “Worse is better” [2]. [1] https://www.oreilly.com/library/view/learning-the-vi/1565924266/ https://www.oreilly.com/library/view/learning-the-vi/1565924... [2] https://en.wikipedia.org/wiki/Worse_is_better https://en.wikipedia.org/wiki/Worse_is_better
- 1y ago
- kavith 1y agoI’ve been using vim-extensions on VSCode/ Zed/ SQL Editors for a few years now and always thought I had the best of both worlds with this setup. But after switching to Cursor it seems like simply hitting tab is a lot faster than performing a vim motion in most cases and so I don’t see why people would still need Vim in 10 years time.
- lawn 1y agoYou can integrate AI tools into Vim too if you want. I'd wager that in 10 years people may have moved on way from Cursor while people will still thrive with (neo)vim.
- lkuty 1y agoI like https://www.barbarianmeetscoding.com/wizards-use-vim/introduction/ https://www.barbarianmeetscoding.com/wizards-use-vim/introdu... but it looks like it is not complete, unless I am mistaken
- palata 1y agoI have been using vim for 15 years. I disagree with the idea that it makes me more efficient than someone else. First, because I have friends who don't use vim and are very fast. Second because most of my time as a developer is not spent writing/editing text. No, I love vim because of its ergonomics. If I use a mouse for too long, my arm/shoulder starts hurting. Maybe I could improve the ergonomics of my mouse (having a vertical mouse already helped), but using vim and a tiling window manager allow me to drastically reduce my use of the mouse. It makes me more efficient than me when I use a less ergonomic setup, sure. But that's me. It's all about ergonomics, and everyone is different. It's okay to be faster with a mouse or on an iPad.
- BrouteMinou 1y agoI use vim to avoid the mouse-keyboard back and forth. I also happen to edit multiple types of file, which I find useful to have / learn only 1 editor/IDE. I am also often, if not always, in a terminal. Some people use vim to brag, some say it's for speed, for me it's because "it's there".
- danielvaughn 1y agoDo you modify your keyboard layout at all? I’ve tried Vim several times and many of the motions just feel awkward as hell for my fingers, but I’m on a standard wasd keyboard.
- palata 1y agoI don't. I like to keep it as close as possible to the defaults so that it just works everywhere. I don't want to have to import my vimrc whenever I SSH somewhere :-). I am on a standard qwerty keyboard, nothing fancy here either! And I almost don't use vim plugins: I enable syntax highlighting, relative line numbers and I add CtrlP as a plugin. That's all. Whenever I need more than that, I start an IDE (configured with the vim bindings of course :-)).
- captaincrisp 1y agoI have a qwerty keyboard also and all I have done to change my layout is remap caps lock to escape. Which is definitely vim relevant. I am a vim guy.
- yanis_t 1y agoVim is great. Several years ago I noticed the lack of books focused on the development experience, e.g. how to build an IDE-like experience in the era of language servers, and wrote a book about it[1] A sad thing is that many people still believe that Vim is something mosty outdated and it’s hard to make it as useful as VS Code. But in fact it’s pretty much the opposite. I also think that the infamous steep curve is not so steep in reality. [1] https://yanis-t.gumroad.com/l/vim4devs https://yanis-t.gumroad.com/l/vim4devs
- NalNezumi 1y agoI use vim & vim bindings for most editors I have (VS Code, Obsidian) and I think there's one thing always missed in this conversation (at least on HN): The changes that happens in your thinking when you start using a tool. Instead we get stuck on pros/cons of tool A vs tool B. I got in to vim in college for two reasons (the real) one was just that I wanted to look cool, and the second one was to relive my hands of discomfort. It was also around the same time I started to look in to QWERTY vs Colemak vs Dvorak, although I didn't go further with that, I quickly realized that the keyboard layout of my country (Sweden), while similar to US/UK QWERTY placed brackets in absolute garbage positions that caused strain in my right hand a lot. Then also the excessive pressing of left/right arrow + moving right hand between mouse & keyboard caused further strain. Vim alleviated that with the word/Word/sentence navigation being more spread out, and "stick to home-row" philosophy. But there was an additional "shift of thinking": editor as a (limited) programming language. Being able to store macros, navigate depending not just on line/character but chunks such as word & sentences made me realize I could do things such as: "In this XML/URDF file, replace all elements with the name=X with the logic Y, which might including adding/removing xml elements/attribute" without having to use some scripting (python + parsing etc). The process of figuring that out is also interactive. Try out a bunch of commands, stitch them together as "macros" and then make macros that calls macros that use copy-paste registry. If I stuck with Sublime, or VS Code, I don't think I would've had that epiphany. It even helped me (non-CS guy) to understand programming better.
- Perizors 1y agoAre you using qwerty still?
- NalNezumi 1y agoI'm still using QWERTY yes, but I use US/UK keyboard layout for coding, and others for writing messages (SWE/JP for me). I realized that it didn't make much sense when I already have 3 QWERTY mappings in my head, and moving all of those 3 mappings to Dvorak / Colemak when those two are based on ergonomics pattern of the English language, when I type in 3 languages.
- tdiff 1y agoIs not vim a tool from an age of very much different terminals to what we have today, with different limitations that are no longer actual? Yearly(!) emergence of new tutorials trying to finally explain how to navigate with vim is a consequence of this disconnect.
- palata 1y agoWell vim comes from a different age, but it is still completely viable today. Because you can have a GUI and a mouse today does not mean that you should not use the vim bindings. I use vim a lot in terminal (both locally or over SSH), but I also use vim bindings in graphical IDEs. Actually, I struggle if the editor doesn't have vim bindings. VScode, IntelliJ, even Xcode has vim bindings.
- ablob 1y agoFunny enough, I believe that there are quite a lot of tutorials and that itself is the issue. Everyone wants to make their own since they deem the others to be bad and then a new subpar tutorial is created, making it even more difficult to find the few helpful articles. This ends up becoming a vicious cycle. In the end I find comparing vim to something like snowboarding or skateboarding intriguing. It doesn't matter how much you explain it, it won't be enough. You just have to try it out for yourself and see if you can get the hang of it. Once that initial step is done, that's when reading about all the intricacies becomes useful.
- windowliker 1y agoBadly titled post. "Vim Language" is usually used in reference to the "VimL" scripting engine inside Vim.
- Perizors 1y agoOne of the problems is that vim is so entrenched with the QWERTY layout that any shortcut is too cumbersome in colemak
- pandemic_region 1y ago... or dvorak.
- myaccountonhn 1y agoI've used colemak and vim (well kakoune nowadays) for over a decade. The only change I've needed is changing : to ,
- nickandbro 1y agoI am actually trying to make a site that allows users to learn vim commands by trying to beat a bot! It’s currently half baked at the moment but live at: https://vimgolf.ai https://vimgolf.ai Feel free to give it a try. Might motivate me to finish it!
- javier_e06 1y agoThe dudes in the https://ytch.xyz https://ytch.xyz Programming channel display their vim editors with all kind of plugins that make me jealous. Pure fireworks. There is a plugin feature that enhances the line number where your cursor is located in the leftmost column for line numbers and looks super cool. I wish I knew the name of that plugin/feature since I don't want to go into the trial an error. I also use the vim plugin for Eclipse and MS Code in my Linux boxes. Yet, when the shit hits fan ... its vim-console time baby!
- pandemic_region 1y ago> There is a plugin feature that enhances the line number where your cursor is located in the leftmost column for line numbers and looks super cool. You mean :set relativenumber
- javier_e06 1y agoI just discovered the relative number after all this years counting lines to yank. OMG. This guy I am talking has that feature up but the relative number in the gutter but also, as he scrolled up and down, the number showing the actual line number was a bit bigger and different color. Maybe he was using neovim? I don't like to highlight the whole line where my cursor is. Its too distracting. But if the cursor non-relative line number in the gutter was bigger or different color, it would be big difference.
- 404NotBoring 1y agoI wonder if learning Vim is similar to learning a musical instrument - where the real benefit isn't just speed, but the way it changes how you think about text editing?
- lordleft 1y agoEven if you bounce off of Vim or modern implementations like Nvim, it's worth learning the bindings. Once you get used to them, you will never go back.
- deleted 1y ago[deleted]
- eestrada 1y agoI mostly like Vim because it is available everywhere and in the terminal. In its default configuration it isn't the most powerful IDE, but it is vastly more powerful that any other default experience in any other text editor (IMO). It also makes it trivially easy to shell out to external tools for modifying the text, so even for a set up that isn't heavily riced you can still do a ton. Even when I'm forced to use another IDE for work, I try to find Vim keybindings ASAP. I like that I can learn Vim motions and actions once and use them in nearly every IDE.
- outlore 1y agoHelix and Kakoune motions seem to make more intuitive sense to me, but it's unfortunate that editor support in VSCode and Zed is quite poor. I am waiting on adopting Helix as my terminal editor until the motions become more universal. I also try LunarVim and quite liked it, but for some reason the motions didn't click, perhaps it is just a matter of practice..