Open, edit or create text files with Vim (Linux text editor) | Valentin Despa | Skillshare

Playback Speed


1.0x


  • 0.5x
  • 0.75x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 1.75x
  • 2x

Open, edit or create text files with Vim (Linux text editor)

teacher avatar Valentin Despa

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

    • 1.

      Introduction

      0:42

    • 2.

      Opening and closing Vim

      3:37

    • 3.

      Vim operating modes (insert mode, command mode)

      1:52

    • 4.

      Making changes to a file with Vim

      2:06

    • 5.

      Creating new files with Vim

      1:09

    • 6.

      Conclusion

      0:35

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

15

Students

--

Project

About This Class

Class Description

Unlock the power of Vim, the essential text editor for macOS and Linux users. In this beginner-friendly class, you’ll:

  • Understand the origins of Vim and why it’s a vital tool for developers and system administrators.
  • Master the basics of vim, including how to open, edit, save, and create text files.
  • Learn to navigate and utilize different vim modes for efficient text editing.
  • Gain confidence in exiting vim—solving the common challenge many face when starting out.
  • Explore practical examples, from editing existing files to creating new ones with ease.

By the end of this class, you’ll feel equipped to use Vim in your day-to-day workflows, boosting productivity in the terminal.

Meet Your Teacher

Level: All Levels

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Introduction: When using a terminal window in MacOS or Linux, VIM is probably the most popular text editor you should know to use. And the name VM actually comes from VI. This is because the original Unix text editor was called VI, which stands for visual, but it was later improved by VIM, which stands for VI improve. In this class, we learn the basics of VIM, which covers opening files, navigating through them, making changes, saving them, or creating completely new files from scratch. If this is what you're looking for, let's 2. Opening and closing Vim: So I already have a terminal window open on my computer. This is a Linux terminal. If you don't know how to open a terminal, simply go ahead and search on your system for a program called terminal. Now the next thing is to locate a TXT file. So if you don't already have a TXT file, you can also go ahead and use the following commands. You're going to use here Fine. Forward slash. This means we're going to search for the entire file system. Going to provide you a dash name. And we're going to see here that we want to find all the files that end with TXT. And this will bring us here a list of possible files, and just going to select one of them. I'm going to copy this with Control C or Command C, if you're on MacOS. I'm going to use the copy command, CP to copy this in the current directory, and just going to use here the data as a reference to the current directory. So this is an important data that you see here right at the end. So the only thing that we want you to do is to have this particular file here. So I'm using the LS command to list all the files in the current folder. I see here we have starting that TXT. This is the file that we're going to use initially. So how can we see the contents of this file with VIM? Well, that's super easy. All we have to do is type in the command VIM, and then the name of the file one open. So in this case, it's going to be starting that TXT and just going to type here SD and then press tab, and this will autocomplete, make sure that doesn't make any errors. And what do you see this file is actually the VIM reference manual, so it explains things about VIM. I haven't planned this. This is more by accident. Now, I have to tell you that a lot of people have a horrible experience when they're using VIM for the first time. And this is because it's so easy to open a file, but I have no idea how to exit VIM once they've opened the file. So I'm here to make sure that you have a much better experience. Now, what people try is to press Escape or Control C, then they start, I don't know, stuff happens and they don't know, Oh, my God, what has happened here? I don't know how to exit. I'm stuck. What should I do? Should I turn off my computer? Some people do that. Pun, computer is out, rebooting. Okay. So this is something that we want to avoid. So just in case you already tried something, you're not sure what has happened where you are, simply press Escape. So that's the first thing. You press Escape. Next thing that you want to do is type in column, and this will show up here right at the bottom of the screen. So this is the column character, and this allows us to type in something inside here, and we're going to type in Q exclamation mark, and then press Enter. And who managed to exit VIM. So let's go ahead and open it once again so that we can take a look around. You can use your error keys to navigate around so you can simply go down if you want to see what's the content or you can simply go up. So these are at least the basic things in terms of using VIM. Let's try again exiting again. I'm going to type in column, Q, exclamation mark, enter, and we have exited. 3. Vim operating modes (insert mode, command mode): VIM operates in different modes, which is a key concept to understand. So let's go over the modes that exist so that you know what they are and you can understand which mode you're currently into. So I'm going to use the VM command to open up the same file. And what we're seeing right now on the screen, this is the normal mode. This is the mode for navigating around. So for example, we can use the arrow keys and we can see what this file is all about. And that's fine. We have this cursor here that we can go to the specific point in the file and pretty much look around like we would do with any text editor. So this is how we're going up and down at the most basic way. But there's also the insert mode, and this is the mode for making changes to this file. So if you want to insert text, if you want to remove text. And the way we activate the insert mode is by pressing the Ikey on the keyboard. And what you will notice here at the end of the screen is this insert. So when you see here insert at the bottom of the screen, you know, Oh, I'm in insert mode. If I type something that is going to be then part of the file. So if you're like, Oh, no, no, I don't want to be in insert mode, all you need to do is press escape on your keyboard and you will see here at the bottom, insert will disappear. And last but not least, there's also command line mode. So command line mode is activated when we type in the column character on the keyboard, so you're going to see here we now have column. And again, we can type in a command. So the command as we currently know is simply Q and the exclamation mark, which tells VIM to exit without saving any changes. 4. Making changes to a file with Vim: Now, let's say we do want to make some changes to this file. So all we need to do is open it with VIM just as we did before, and we may want to navigate to a specific part where we want to make that change. So, for example, let's say, right here, we want to make a change. And then we're going to press I to Enter Insert mode. And now, if we type something, for example, I'm going to press Enter, I'm going to create a new line, and I can write something like this is a new line. So this is the change that we made. And now let's say we're done with making changes, then I press escape, and now we have exited the insert mode, but we are not done yet. We want to save these changes. So the way we are saving the changes is by simply activating here the command mode, so this is done by typing in column, and we can simply put here W, which stands for right. So this is going to save the changes. So we can type in here right. And then these changes that we did have been saved. You're going to say here right after button written. Now, quite often, we don't want to save the changes and still be inside VIM. So we are usually trying to do two things at the same time. We want to save and we want to quit. So again, we're going to activate here command line mode, go write here W for writing the changes, but also Q for quitting and press Enter. So the changes will be safe and we will exit. But this is not what I usually use to quickly exit VIM. Instead, what I'm doing is I'm simply entering command line mode and then I'm pressing here X. So X will quickly save if there's something to change and will exit. For me, it's just faster to just type in X, Enter and exit, then to press W and Q to pretty much have the same outcome. 5. Creating new files with Vim: A next, let's go ahead and create a completely new file with VIM. And we're going to do this in a very simple way. We're going to type in the command VIM. And let's say we want to create a new file which is called blog dot TXT. And I'm going to go ahead and press Enter so that we can enter VIM. What we're going to see here is this is the name of the file that says here U. You're going to see here, there's nothing in this file. So what this tilde here represent is just content that doesn't exist at this point. So if you want to start writing something, all we have to do is enter Insert mode by pressing I, and we can write a new line of text like today I'm earning VIM. Let's exit Insert mode by pressing Escape. And if you want to save the changes that we made to this file, I'm going to enter command mode with column, type in X, and then press Enter, and now our file has been saved. If you want to check its contents, we can use, again, VIM and the exact same file name. And we're going to see here that what we have entered here has been indeed safe. 6. Conclusion: So in this class, we have just learned the absolute basics in terms of using VIM. So I hope that you are now much more confident that you at least know how to exit VIM if you need to. But ideally, you should know how to make changes to a file, how you can navigate around by going up and down by creating a new file with VIM and the basic commands for exiting without saving and exiting with saving. Thank you so much for taking this course and hope to see you in another class.