How I Use Vim for Productivity and Efficiency

I use vim (a text editor) for my product development work, which is full of repetitive tasks. For example, I’m currently working on a project that has many, many files and many, many lines of code. In total, there are over 10,000 lines of code that I h…


This content originally appeared on DEV Community and was authored by jones268

I use vim (a text editor) for my product development work, which is full of repetitive tasks. For example, I’m currently working on a project that has many, many files and many, many lines of code. In total, there are over 10,000 lines of code that I have to navigate through. It would take me forever if I didn’t have vim on my side.

I have used a variety of text editors in my career. I started with pico on my workstations, worked briefly with joe on Solaris and then moved to emacs and nano. When I moved to Linux as my primary operating system, I started using vim to edit text files. Then I learned about vim and how to use it and that is when I really fell in love with vim.

I am not going to go into all of the details about vim but if you are new to vim I recommend this tutorial.

Vim Tricks

I am just going to highlight some tricks that I have found useful.

So how exactly does a guy like me get used to typing commands left and right? It took some time and patience, but it was well worth it.

  • keyboard macros You can start recording your keys with ESC followed by qh. Then whatever you type in vim (including commands) will be recorded. Press ESC q to stop recording. Now press @h to replay your key strokes.

  • repeat action if you want to repeat an action, just type a number followed by the action. To delete 10 lines press 10dd. To press 50 lines type 50dd. You can do this for keyboard recording too, 50@h.

  • run commands you can run commands right from within vim. !ls runs the command ls in your terminal. You can do this for any command.

  • scrolling you can scroll inside vim with the keys ctrl+e and ctrl+y, no need to use the mouse

  • move to end/begin you can use the keys 0 and $ to move to the beginning and end of a line. No need to hold down the cursor key for several seconds.

  • jump to line press the keys 140G to jump to line 140. You can also use :140 if you prefer those keys.

  • set your .vimrc you should have a good .vimrc file in place so that you have all the settings ready to go. This means options for colours, font, tab settings etc. You can put this on git and pull whenever you access another computer. That way your settings stay in sync no matter what computer you use.

  • vim mode if you have to use an IDE for work, you can enable vim emulation. This works in visual studio, jetbrains IDEs and probably tons of others.


This content originally appeared on DEV Community and was authored by jones268


Print Share Comment Cite Upload Translate Updates
APA

jones268 | Sciencx (2021-05-11T19:04:57+00:00) How I Use Vim for Productivity and Efficiency. Retrieved from https://www.scien.cx/2021/05/11/how-i-use-vim-for-productivity-and-efficiency/

MLA
" » How I Use Vim for Productivity and Efficiency." jones268 | Sciencx - Tuesday May 11, 2021, https://www.scien.cx/2021/05/11/how-i-use-vim-for-productivity-and-efficiency/
HARVARD
jones268 | Sciencx Tuesday May 11, 2021 » How I Use Vim for Productivity and Efficiency., viewed ,<https://www.scien.cx/2021/05/11/how-i-use-vim-for-productivity-and-efficiency/>
VANCOUVER
jones268 | Sciencx - » How I Use Vim for Productivity and Efficiency. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/11/how-i-use-vim-for-productivity-and-efficiency/
CHICAGO
" » How I Use Vim for Productivity and Efficiency." jones268 | Sciencx - Accessed . https://www.scien.cx/2021/05/11/how-i-use-vim-for-productivity-and-efficiency/
IEEE
" » How I Use Vim for Productivity and Efficiency." jones268 | Sciencx [Online]. Available: https://www.scien.cx/2021/05/11/how-i-use-vim-for-productivity-and-efficiency/. [Accessed: ]
rf:citation
» How I Use Vim for Productivity and Efficiency | jones268 | Sciencx | https://www.scien.cx/2021/05/11/how-i-use-vim-for-productivity-and-efficiency/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.