Re:What Is the Most Valuable Thing You Can Learn in One Hour?
by bloopernova on Tuesday December 31, 2019 @10:02AM
(#21921374)
vim has its roots in a time when ed was widely used on teletype style user interfaces. The idea was that you didn't have a continuously-updating screen, so conservation of keystrokes and screen updates was very important.
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.
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.