Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 20, 2021 08:58 am GMT

Vim .. best code editor ?

Vim, a text editor for writing code where you navigate around the screen with your keyboard instead of a mouse.
It's based on the original Unix text editor VI which was created by Bill Joy in 1976,

Alt Text

then VI improved or VIM followed it in 1991; but why would you ever want to use a keyboard-based text editor in 2021 if you have a lot of easy to use mouse-based IDEs ?

When you write code everyday, your fingers should be glued to the keyboard at all times, every time you touch your productivity declines; and learning to code with VIM is like learning to play an instrument, it will be painful at first but that pain will lead to more precise and productive code editing in the future.

VIM runs in the terminal and it's installed on almost every machine, and at some point you'll likely find yourself accidently dropped into VIM with no way to escape - which is a joke I always heard in my classes , if you want to mess with someone who doesn't know VIM, let them enter nonsense/crap in VIM editor on their machine, but they don't know how unpredictable it is to escape the main page - in other words, shut down VIM.

If you find yourself there you can quit VIM by typing :q that will close and modify the file, or if it has been modified and saved, you can use :q! to discard any other changes, or :wq to save and quit VIM peacefully.

You can open a file in VIM like so :

terminal > vim bek.py

You can toggle between different modes
Normal mode, where you can navigate with your H J K L keys

H -> Left
J -> Up
K -> Down
L -> Right

You have INSERT mode, you can access it by hitting i for insert, logical right?
You have COMMMAND mode, and for that to happen you can hit on :
And VISUAL mode by hitting v

Alt Text

If there is a character you want to delete, you can hit (x) [ Delete Character ]
Or, double (d) to quickly delete an entire line.
To undo it, hit (u) to Undo it.
To add line number, got to command mode by hitting semicolon : then type set number, and now you can navigate any line with :(number), so to got to line 5 -> :5 and so on.

While navigating the document, if you want to modify something, you can hit (i) for insert mode , modify what you want then hit (Esc) button to exit to normal mode.

If you want to copy and paste code, you can paste from system clipboard using (+p).
To save the changes, you can hit (:w) to save it, then run the program directly using (:!) followed by the command we want to run, in this example it will be:
terminal > :! python bek.py


Original Link: https://dev.to/bekbrace/vim-best-code-editor-g4h

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To