5 ms·
I'm using vim for 10 years and I know I have a lot of "bad" habits that I'm trying to eliminate, but it's hard. For example: 1. instead of doing 4j I might do
by endorphine 4y ago
I'm using vim for 10 years and I know I have a lot of "bad" habits that I'm trying to eliminate, but it's hard. 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
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?
- nbonaparte 4y agoFor 1, I use https://github.com/ja-ford/delaytrain.nvim https://github.com/ja-ford/delaytrain.nvim (for nvim only); it basically stops repeated navigation keys from working for a short while.
- endorphine 4y agoAwesome, I might try that!
- jonhohle 4y agoMe too, after 18 years! 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).
- LanternLight83 4y agoI don't have any answers. 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.
- _0w8t 4y agoUnconsciousness is not good at doing even simple math like counting, so habits like 4j or 3yy are hard to form. 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.
- endorphine 4y agoAs in my other comment: what if you use relative line numbers though?
- _0w8t 4y agoI suspect just by making sure that the cursor never leaves the middle of the screen may help better with habit formation than relative line numbers. This way, when one looks few lines below or above the middle it is easier to associate the distance to the center of the screen with numbers on the keyboard compared with distance to an arbitrary line in the screen. Plus relative line numbers will be perceived by the side vision which is rather poor in humans so they mostly help when one consciously looks into them. 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?
- vasac 4y agoI often use jjj and don't plan to change that. Forty years ago, when working on slow terminals, it may have made sense to optimize movement but not today. For small movements, I tend to spam keys. For larger jumps, I use an easy-motion like plugin such as Svart. Counting lines and words simply makes no sense to me for frequent operations.
- kmarc 4y agoStart using macros for bulk editing. 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.
- vasac 4y agoI do, but mostly when massaging data. With plugins such as multi-cursor and LSP, I rarely have the need to bulk edit code.
- mcluck 4y agoI'm definitely not a vim master but I've made an active choice to avoid 4j style movement. The main benefit of vim, for me, is the mind-body connection. Commands are either muscle memory or like saying a short phrase in my head so it flows out naturally. Counting lines before executing breaks that natural flow
- schemathings 4y agoFor more than a few lines I'll go to a spot and mark it (ma), navigate to the next spot and delete to the mark (d'a). That's how I thought of it anyway, not delete n lines. Delete from here to here.
- endorphine 4y agoWhat if you use relative line numbers though?
- mcluck 4y agoThat could help and I have experimented with relative line numbers but have decided against it. I want to see absolute line numbers for matching up error messages and I find it's easier to communicate in absolute line numbers when doing code reviews or pair programming
- quectophoton 4y agoI don't think those are "bad" habits, to me it seems like you've already found your own way of using your editor. 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.
- eviks 4y ago1. is not bad, continuous visual feedback is awesome and more ergonomic that switching to a "counting" mental mode, especially for shorter distances (of which 4 is a part) 3. similarly, it's just a deficiency in vim that 3yy is invisible, so using a command that provides visual feedback is superior. Maybe try to fit a Shift-V to a non-modifier keybind, and depending on how ESC is convenient, a better exit would also be nice
- tomerbd 4y agoLife is short, jjjj is perfect, peace and tranquility for us all vim users.