Vim is one of the most common text editors and is available on nearly every system. Most IDEs have vim-mode like Visual Studio Code and the Jetbrains IDEs.
Vim is an excellent tool for quickly writing and editing code and other text files. Once you learn how to use it, you’ll love it. It helps to have a basic understanding of the Unix command line, but if you don’t, that’s OK, too.
The (Vim) editor is a fundamental tool for developers, programmers, and sysadmins.
Here are some reasons to use vim:
- Vim is the only text editor you will ever need.
- Vim is free, and always will be.
- Vim can be used with any programming language.
- Vim can edit remotely over a TCP/IP connection.
- Vim runs on every operating system, but no other text editor runs on all of them.
- Vim runs in most IDE's as plugin
- Vim is the ultimate weapon in your programming arsenal, it should be your first choice for any code related tasks.
However, it takes some time to learn vim
To create a new file: type the command
where filename is the name of the file you want to edit. This creates a new file and opens it using Vim.
:w (write) command writes the file to disk.
To save and write the file when you exit: type
To open a file, press
:e followed by your file name. This can include the path to the filename, so you can type
To quit vim, type the command
:q!. If you want to save the file and exit type
:wq or if you are lazy just type
To write text, you need to enter insertion mode. You can do that by pressing
insert. Then you can write whatever you want. In vim, you can use the cursor keys to navigate around the text.
You can use the command
:r !cmd↵ to execute a command and insert the results in vim.
If you are familiar with Unix commands, it means you can directly get the output inside your editor with commands like
:r !ls /
There are many more commands in vim. You can do what any editor can do, but with only a few keystrokes.
So why work inefficiently when you can use vim?
Check the cheatsheet to see an overview of commands