How to Use the Vim Text Editor in Linux | Vim has other modes | Vim Text Editor

5K views Aug 20, 2023
publisher-humix monibe.com

How to Use the Vim Text Editor in Linux Step 1: Create and close a Vim file without saving Remember when I said I was scared to use Vim at first? Well, the scary part was thinking, "what if I change an existing file and mess things up?" After all, several computer science assignments required me to work on existing files by modifying them. I wanted to know: How can I open and close a file without saving my changes? The good news is you can use the same command to create or open a file in Vim: vim <FILE_NAME>, where <FILE_NAME> represents the target file name you want to create or modify. Let's create a file named HelloWorld.java by typing vim HelloWorld.java. Hello, Vim! Now, here is a very important concept in Vim, possibly the most important to remember: Vim has multiple modes. Here are three you need to know to do Vim basics: Vim has other modes, like Visual, Select, and Ex-Mode, but Normal, Insert, and Command Line modes are good enough for us. You are now in Normal mode. If you have text, you can move around with your arrow keys or other navigation keystrokes (which you will see later). To make sure you are in Normal mode, simply hit the Esc (Escape) key. Tip: Esc switches to Normal mode. Even though you are already in Normal mode, hit Esc just for practice's sake. Now, this will be interesting. Press : (the colon key) followed by q! (i.e., :q!). Your screen will look like this:

#Computers & Electronics