I think it can be in the list as well. It takes a long time to properly learn. But one hours is defiantly enough to get to know the main Vim bindings, to be as productive as in other editors. In the end it makes you super productive.
I think it can be in the list as well. It takes a long time to properly learn. But one hours is defiantly enough to get to know the main Vim bindings, to be as productive as in other editors. In the end it makes you super productive.
I'm going to do an experiment. I've been struggling with Vim for a long time. I need to leave in about one hour. Instead of wasting time here on HN, I'll now spend an hour learning Vim.
I doubt that this will get me very far, but I'll let you know how far I got.
- there's a visual mode for selecting text
- I can now yank and paste text in normal mode
- I learned to use :split and :vsplit to open new files, and ctrl-w to switch between them
- I learned a few new navigation commands
- I learned that there's a replace mode (R)
Definitely useful, and I hope I remember everything the next time I open vim!
But I still feel like I'm just scraping the surface. One hour is very little time to learn about the power of vim.
The first and most important things to understand are:
- Normal mode is the default mode. Only leave it when you already know what you want to write.
- Movement follows the [<count>] <verb> <target> model. The most used verbs are: d, y, p
The most used targets are j, k, f, F, /, w, W, e, b
Other useful keys to know and use: a, A, o, O, *, ., %
And lastly, learn how to use macros! (q, @)
If you just learn everything I listed here (and it isn't much), until it feels natural, you already know 90% of what you need to boost your editing speed and use vim like a pro.
My struggle with vim is that it just slows me down. I'm used to the way that text editors work on the Mac, and I'm really fast with them. Working in Textmate or Sublime or Xcode or even BBedit feels natural to me. But as soon as I switch to Vim, everything feels difficult.
I think a big problem with Vim is that it's really hard to learn when it's not your primary editor.
> In the last year, How to exit the Vim editor has made up about .005% of question traffic: that is, one out of every 20,000 visits to Stack Overflow questions. That means during peak traffic hours on weekdays, there are about 80 people per hour that need help getting out of Vim.
Next time you're stuck somewhere without internet, as I was, give vimtutor a shot.
Nothing has influenced my use of computers as much as Vim, and I'm really glad this tool exists. It makes editing text a great experience, and has a couple feature you can't find anywhere else(not even Emacs offers such a flexible, intuitive keybinding functionality or reliable, quirk-free controls).
It's not. People tend to be religious about their choices, you can achieve the same result in any editor. Also most likely the bottleneck in your productivity is not the speed at which you manipulate text.
Anyway I will highlight few things that I consider great about vim.
1. It's more about consistency. (vim shortcuts are used in a lot of other places, ex: linux commands like `less`, `screen` etc.., tmux or other pane manager, etc..) When you learn linux you start to get a feeling about it, at some point you enter a command you somehow magically know the shortcuts to navigate/close/search inside there, Vim feels like a complementary thing to the whole linux environment knowledge.
2. It is everywhere! You need 0 time to prepare your work environment if you switch your job/workstation, and you also don't need to exit the remote machine/datacenter to write your stuff. You basically ssh into the machine[s]/datacenter and there you go, at the end of you day you just detach from the session, go home, and next day attach back and continue, all the commands, fancy log searches, processes monitoring, everything is there still running and waiting for you.
P.S. I also use VS Code sometimes especially for pet projects.
Most of what programmers do is a lot of navigation and text manipulation correct? In normal scenarios, what keys are available to us to do that? Just the arrow keys and modifiers (Ctrl, Alt, Command).
But what if we had essentially the entire keyboard available to us for either text manipulation or navigation? We could move around or manipulate text in more efficient ways because we have more keys available to us to do different things (like say "delete until the next closed parenthesis" rather than control shift right-arrow 20 times).
That's why VIM is useful for programmers or anyone who manipulates plain text all day.
Possibly I'm a terrible programmer, but most of what I do is thinking and looking shit up. Entering or modifying code, and navigating non-linearly within one file is like... a couple percent of what I do on an average day? Maybe 5% tops? Some days it may get as high as 20% of my time. Maybe.
[EDIT] add "communicating", broadly, to the list of things I do a lot of at work that's not editing code.
A perennial answer to this question: https://gist.github.com/nifl/1178878
The problem is, the opposite is true until you reach some level of proficiency. Until then, vim is hard to get used to.
I know I haven't provided a concrete answer, but many blog posts have been written on the matter. I personally started learning vim by running through vimtutor once a day as part of a New Year's resolution about ten years ago.
Touching your mouse less.
Might sound weird, but that's honestly my main reason for learning modal editing and emacs with evil.
Less flip flopping between mouse and keyboard might not be "more productive", but it's more comfortable.
And beneath that you start to find better fuzzy project searching with tools like ripgrep, an easier time navigating your project, powerful in-file movement commands, etc.
I'm mostly an emacs evil user, so I also have workspaces, projectile, magit, and a whole host of other extremely powerful tools.
And I don't really lose out on much wrt code completion, or other functionalities you normally get from an IDE. Since I can use the same language servers you would use in vscode.
That's not to say there aren't things that suck though. Emacs in particular isn't for someone that's unwilling to make changes to their config.
Still, I always use vim plugins in my IDE, it's just not as useful there, but it can save a small amount of time depending on your level of vim skills.
For example, right now, how do you make a blank line above your cursor and move your cursor there? Do you maybe go ctrl-a to move the cursor to the front of the current line, carriage return to move the current line own, then press up-arrow to move your cursor to the new, empty line? In Vim, it's just capital O. lower-case o to create an empty line below you and move your cursor there. And I could go on for all sorts of simple tasks that have most people reaching for their mouse.
Entry-level Vim keybindings just make these basic tasks more pleasant.
I got pretty hard-core into Vim when I was in uni and had time to care and credentialize in Vim. Nowadays, I'm switching between so many editors that I'm happy just using basic Vim keybindings.
It just so happens that this paradigm (which is a much-maligned word!) is still useful today.
You interact with text in a couple of different ways, which vim maps onto "modes". You type in text, you select text, and you transform text. Insert mode, where you type in text, is how most editors work these days.
Let's look at an example, I hope I can do this justice:
You've been asked to refactor and update some code. In vim, you open up the right file and you hit '}' a few times to jump down "paragraphs" to get to the right spot to add your code. You hit 'i' to enter insert mode, then type in the extra class methods or whatever you need. Once done typing, you hit escape to exit insert mode. Now you have to remove some methods, so you type '/' to search, followed by the method name, then hit enter until you find the right part of the code. You hit '^' to go to the beginning of the line, then you hit 'd}'. That's the combination of an action 'd' and movement '}'. That removes up to the next blank line. Now you need to update places within this file that reference that method, and update them to the new method you added. You type ':%s/productComponent/productExponent/gc' which is a search and replace, 'g'lobally with 'c'onfirmation. Once the changes are made, you type ':wq' to write the file and exit out of vim. Your consulting firm charge the client $50,000.
And your hands didn't leave the keyboard to mess with the mouse.
Think of vim like a computer game where you have to learn a bunch of moves, or a simulator where you have to learn a lot of key combos to control a spaceship or aeroplane.
I hope that helped, I don't advocate trying to jump in and replace vscode with vim immediately. But definitely install vim and try some tutorials and experiment with your normal workflows to see if you feel it is a good match to your keyboard usage/style.
If your productivity is limited by how fast you can type then you are either a far, far better programmer than most people or your skills are being under utilized.
I can get to any location in a massive codebase within seconds. I can drop the cursor to any character I see damn near instantly. I can construct entire macros on the fly and repeat them endlessly until I’m satisfied and destroy repetitive tasks. I can move entire sections of code to anywhere else I please, just tell the line numbers and it’s done. I don’t even have to open the files. When you’re working really fast in Vim it’s easy to get a high from the amount of code you are slicing through.
In short, classical editors are like a ball and chain for developers trying to get shit done, and I cringe every time I see a developer using a mouse or trackpad while working. It’s so slow, so inefficient, I can’t stand it anymore. I need vim-like shortcuts in every application I use.
I think just about any modern programmer's editor can do all the things you describe. I work most of the day in Visual Studio and I know it can do all that.
For programming I think vim is handicapped somewhat because it doesn't "understand" what it's working on.
I'm digging moving things around quickly and all that. But I don't know how to get my cursor where I want it quickly.
This makes it really easy to get to the line you are looking at. You look at the relative line number, see it's 9 lines above, so you start out with pressing 9k to jump up 9 lines.
Let's say you're trying to get to an instance of the 'a' character. The character is to the right of your cursor, so you press fa to jump to the next instance of the 'a' character. However, it turns out that there are multiple instances of the 'a' character before the one you are trying to get to. So you repeatedly press ; to keep going to the next 'a' character until you get to the one you want. You've accidentally passed the one you want, so you press , to go back one.
So all together you something like 9kfa;;
Also related to the f motion are the F, t, and T motions. I use the t motion all the time. t and T are like f and F but they put you on the character before the one you specify. Very useful for jumping to the first character before the next parentheses and things like that.
purely for putting the cursor exactly where you want it there are more powerful things like the emacs acejump plugin or easymotion for vim but they aren't all that necessary IMO.
The reason folks talk about feeling crippled when they use a regular editor is that you get used to things like `f(` to take you to the front of some function's arg list, or `ci{` to quickly change some block of code.
I get that. My point is that I decide to move that chunk of code after looking at the screen for 4 minutes so it doesn't matter if it's 3 or 4 keystrokes or 5 or 6.
Once you know your editor well, you aren't thinking about the keystrokes anyway. It becomes entirely automatic. There are lots of editor operations that I couldn't tell you what the keystrokes actually are without sitting at a keyboard and doing it.
Fun way to get used to vim