Vim Basics
Just the basics you need to get started. Also for those who are trapped in classic vim situation, where you don't know how to quit! Vim is a powerful, keyboard-driven command-line text editor (an improved version of the classic Unix “vi”) used for efficiently editing code and plain-text files. Things you need Linux Mint or Ubuntu Vim 8.2 or above Alacritty terminal (Why? Just for feel!) Install…
Vim Basics: Getting Started
Vim is an advanced, keyboard-driven text editor that enhances the classic Unix "vi" command-line tool. It is a versatile editor used for editing both code and plain-text files efficiently. To use Vim, you'll need a Linux Mint or Ubuntu operating system with Vim 8.2 or higher installed, along with an Alacritty terminal for optimal performance.
Opening a File in Vim
Once you have Vim installed, you can open a file by typing "vim" followed by the filename. For example, if you have a folder named "hello" containing a file called "hello.txt," you can open it by typing "vim hello.txt" in your terminal.
Understanding Modes in Vim
When you open a file in Vim, you are automatically placed in Normal mode. There are three primary modes in Vim: Normal, Insert, and Command. Normal mode is the default mode, where you can view the file but cannot make changes. To enter Insert mode, press the "i" key, which allows you to type directly into the editor. To return to Normal mode, simply press the "Esc" key. Command mode is entered by pressing the ":" key while in Normal mode, where you can execute commands such as saving and quitting the file.
Navigating Modes and Saving Changes
Remember, when in Insert mode, press "Esc" to go back to Normal mode. To save your changes, also ensure you are in Normal mode. Type ":w" (without quotes) and press "Enter." To save and quit at the same time, type ":wq" (without quotes) and press "Enter." If you wish to quit without saving any changes, type ":q!" (without quotes) and press "Enter."
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.