Editing Tools within HPC (Vim) | 2026 HPC Training Series #2

Okay. So, hello everyone, welcome to the Research Computing workshop series Part 2. Today, we are learning about VI, or VIM, Linux Text Editor. And, this is catered more towards the beginning, beginner level. So if you're already a power user, you might not find it, this workshop, very useful, but if you're new, I will try to move… the beginner piece. And, so my name's Halyna, I am a research systems engineer on our high-performance computing team at Columbia. Some of my other co-workers are also on the call, and they will help out in the chat with any questions you might have. I reserve some time slots for questions during the class and at the end. You're welcome to speak up and ask. anything during that time, but while I'm talking, and you have questions or issues, please just, post in the chat, and somebody from my team will help. So, let's, jump right into it. What is VI, or VIM? Like we said, it's a visual editor for Linux. Originally created in 1976, VIM is VI improved. It's a newer version, it is free, open source, highly configurable, designed for efficiency, and programmers often use it to edit code directly in the terminal versus VS Code or PyCharm. And an important thing to remember about VI, that it's a modal editor. It means that it has separate modes for inserting text, issuing commands, and it has some other modes that we will also briefly touch upon. But this allows user to edit text rapidly without a mouse. As you might sometimes not have in a Linux terminal. A little bit of history. So VI was created in 76 by Bill Joy. It was designed as a lightweight Unix text editor, and is standard on most Unix Linux systems. And VAM was released in 91 by Bram Mulinar. It… add some other features, including syntax highlights, plugins, but it does maintain full compatibility with VI, so whatever commands work in VI, will work in VIM as well. And, actually, in many most modern Linux distributions, VI is just a SIM link to VAM. And maybe I can actually show you… How it is on our clusters. So, I am already logged into Insomnia here. I'm gonna do… with the eye. Oh, Venom AI, and then them. I see it's seemingly two different files. I'm just gonna see what kind of file it is. And we see that VIM, it's… an executable, and curiously, VI is a shell script, so maybe we can take a quick look. Oh, interesting. So, if you do have VIM on the system, it says start VIM, but otherwise it will look for VI executable. And since in our system we do have VIM, if you type VI, you essentially will end up in VIM anyway. So, some of the differences, again, VI is just basic editor, minimal features. VIM has more advanced features, it's customizable, has plug-in support. VI has single-level undo. VIM has multiple. A limited extensibility with the eye, then much more configurable, more powerful and modern, while the eye is a little more lightweight. What about other editors? on Linux Unix systems, you might be familiar with Nano and Emacs, and just to highlight what might be some pros and cons for each. So, Nano is very easy to use. But it does have limited features. Emacs, extremely powerful, but a steep learning curve, perhaps more than VI. For VI, of course, it's fast, efficient, available everywhere, and the con is that it might be a little bit of a learning curve for the beginners. But I… I trust that we can… get and learn about it today. So, why does VI still matter? Why not just use any text editor? First of all, it's available on all Linux Unix systems. It works over SSH. You don't need a GUI, you don't need X windows with it. And for sysadmins and DevOps engineers, it is pretty important when Something happens with servers, and they are in recovery mode, and you don't have keyboard… well, you don't have use of the mouse. And any questions at this point? Right. I think none. I think that's all pretty straightforward. So, what are our objectives for today? To be able to use VI efficiently, obviously. We will learn to open exit files safely, navigate, edit text without getting lost and panicking and saving, quitting. Recovering from mistakes. And so, why are we asking you to log into the cluster for today's class? You might have VI on your Mac, or your Linux, personal Linux computer, but for this consistency, because your version could be a little bit different on a Mac. And also because we will have some test tiles to play with, it might be a little more efficient if we all are looking at the same thing, but if you cannot log in for some reason, and you just want to use VI on your computer, that's also totally fine. So, just a quick reminder, especially for those who are new to the cluster, we SSH in was this command that's in the slides. It's a Sage Uni. at insomniARCSColumbia.edu. So, I typed this in, my uni. Password prompt. Asking me for Duo. I'm choosing one for push. I got a prompt to my phone. Hopefully. Approve. I am N. So… I, I'm in my home directory, I'm gonna confirm by typing PWD command. And I'm just gonna do LS to see what's in here. And I have some of my old files in a folder, but those of you who are new will not have anything. I'm gonna give everybody just a minute to catch up, and If anybody is having issues logging in. Please, let us know in the chat, and we'll help you. But… Once everybody is logged in, let's copy some of our files. Into the home directory. Explain in a second. So, CP, copy command, copy, dash r for recursively. I'm giving a path to this Directory in our intro series. Folder, and a star at the end to copy everything, space, dot, For copy adhere. Enter. I do LS now, so I should have… 3 new files, Columbia History, AMLS, MyCat Story. Can do a long listing here. So… you should… you should have something similar in, your directories. And should I… should I give everybody a minute to catch up? Or are we all good? And sorry, I'm not seeing the chat, so maybe somebody can let me know. Max Shortte: I think we're pretty much good. I see Sam is helping out a couple of users, copying the files. Give it maybe 60 seconds, and we should be good to go, Helena. Okay, perfect, yeah. Let's, let's give… Everybody, a minute. Max Shortte: Okay, that's great. Okay, Sam actually copied and pasted the copy command, so I think we're good to go. Okay, excellent. Okay. So… Let's… let's say the file's for later, let's, just do some quick exercise first with creating a new file and opening it. So I will do VI, and… Test DXT. it's a new file, it doesn't have to be TXT extension, you can name it pretty much anything, within reason, obviously don't use, Linux command words and, things like that. So, but, test.txt, I'm gonna hit enter, and here I am inside a file. You see on the bottom, it says test.txt new. Okay, now I can work with it, but… let's just quickly learn how to exit safely, and Skipping ahead a little bit for that, I will have to quickly go into the command mode, and for that, I would have to hit colon. You see, colon appeared on the bottom with my cursor, and I'm just going to type a letter Q for quit. And enter, and I'm back to the shell. I'm… Gonna go back into the file for a second, I'm gonna enter some text, and maybe I want to save it. In that case, I will type WQ for right and quit. And now, if I look inside the file, I see the text there. And while you're working with it, of course, you can just type W for save. If you don't want to save your changes, colon queue and exclamation point. So we, we will do a little bit of navigating around the file, and for that, let's open Columbia History, because it's kind of long, and it's easy to see. the navigation in it. As we mentioned, VI is modal, right? So it has normal, it has command, insert modes. By default, you end up in a normal mode, and you can do navigation and commands. If you're unsure what mode you're in, just hit escape, and you will end up in a normal mode. Insert mode is for typing text. There are several ways to get into insert mode, but the easiest is typing I in a normal mode, so I just did that, and you see insert appears at the bottom of the screen. So, now I can type, test, something… and I hit escape, I'm back into normal mode. Command mode is for issuing commands, and you get to it by just typing colon in a normal mode, and we just saw that with the quitting. the cursor is right here at the bottom. I can quit, as we learned. I can… Do other commands, like help. The things appear. quit from the help with Q. And we'll… we'll take a look at some other quick… Commands and more complex ones in the command mode. So, just, you know, to build on this and reiterate, because it's important to remember. So, normal mode, default for navigation and editing, for moving around, deleting, copying, pasting. shortcuts. Insert is for typing and editing text like a regular editor. press escape to get to normal, and you enter it with I, A, or O in normal mode. Oops. Apologies. So I will insert Add the cursor. If you tape A, it will insert after the cursor. O will insert on a new line. There are some other shortcuts how to get into the insert mode, but, you know, you don't need it for this class. These are good to remember. The command line mode, like we discussed, with a colon. commands at the bottom of the screen, you can save, quit, replace, search, configure settings, etc. And, we will also cover visual mode today a little bit. It's where you can highlight text, and, execute commands. And let's do a little bit more navigation here in this big file. And, obviously, generally in modern versions of the IVM, you can just use arrow keys. But sometimes, when you are in rescue mode, that doesn't work, so you would use HJKL for navigating left, down, upright. You can try that. But, of course, it's a little tedious to just do one keystroke at a time, and then sometimes you just, like, want to jump some words ahead. So, W… We'll jump to the next word. the previous word. And, VI is pretty flexible in a way that you can combine, those shortcuts with, with numbers, so if I do 2W, I will jump two words. or 4B, I'm jumping forwards, backwards, and, you know, comma is counted as a word, so… Just keep that in mind. Zero, go to the beginning of the line. Dollar sign, go to the end of the line. What else is useful? Gigi… the beginning of the file, capital G at the bottom. If I do 10G, I will go to line number 10. And what, It's not in the slides, but CTRL-G will tell me some information about the file. It has 41 lines, and I'm currently 24% into the file. So, I don't know, line 10, I guess. And, we… covered the inserting with I, A, oh, just refreshing here. But, undo operation. Let's say I added some lines here. This is, best. If I want to undo it, I would hit a letter U. And it's undone. And as we mentioned, VIM has many undo levels. I can keep hitting U, and it will undo the changes that I have made. You can also, do commands to undo up until a certain point in time. So, I've got into the command mode again. Here. And… Earlier… 5 minutes. it will… change the file to the state it was in 5 minutes ago. Unfortunately, yes, I don't… I don't have any changes that old. Maybe we can try one minute. Mo. Also, no… no changes, because I just undid all of them, but you get the idea. what else, what else is useful? To delete, I'm in normal mode, and I can delete characters with X. Or, you know, 2X to delete 2 characters. DD, delete blind. Dw, delete word. And, copy the line, YY for Yank. P for paste. And lowercase p will, insert the line at the bottom. Uppercase, we'll insert it. On top of the current line. To repeat the lost command. Just dot. And, you know, I can repeat my command indefinitely. But, yeah, actually, and let's now return to our version from a minute ago. Gonna do earlier one minute. And erase all of that. Questions? comments? Okay. Good. I guess not. Let's, demo the search, and… Replace functions, and let's go for that into another file. I'm gonna quit out of here. I'm gonna go into my cat's story, a short file, but it illustrates replacing and searching a little better. So, to search, I would need to be in normal mode, I just have to hit the forward slash, see my cursor here at the bottom? And, I'm gonna… Search for word kept in this file. Immediately the AI highlighted for you all the instances. I hit enter, I get to the next, occurrence of the word after my cursor. I… when I hit N, I jump to the next one. This we already covered. Ignore it. Boop-boom. So, And to help us with, the next… some of the next exercises, let's do a few more command, Commands on the command mode. Help we already covered, sad. number, or set a new is really useful, especially when you're programming. It will set numbers for the lines. To undo it. You would do set null, number, like this. Set list, also useful, shows you hidden characters. Here it shows it's the end of the line. Sometimes when you paste files from Windows, it will show, hidden characters that can get in the way, and you can replace them more easily. What else? Yeah, we can also open new files. And… We can… Wet out of here. Let me go back to the cat story. So searching is good, but it's also useful to maybe replace the text, especially if you're coding, you want to rename a variable. How do you do that? And you can use, command mode, regular expressions. And… just a quick refresher for those who are not familiar with regular expressions, what are they? They are a specialized, compact sequence of characters, that defines a search pattern for the text. It's used in programming, text editing, and acts, sort of like find and replace function. You can extract patterns, like phone numbers, email addresses, or you can manipulate text. And, here are some examples. You can match a word, match email pattern, just letters and not numbers, and of course, it's, a very long subject that is a lot of material, probably, worth of another class. We're not gonna cover it extensively, we're just gonna learn some useful, regular expressions in the eye command mode. So… I'm gonna go into command mode again with Colin. And… Let's say I want to replace all the instances of the word cat with the word dog. This is the syntax I would use, percentage sign for the entire file. As for substitute, forward slash cat, Dog. forward slash. Enter. Okay, and we see that most of the instances of cat were replaced with dog. How come not all? Because it only matched the first occurrence of the word on the line? Let's say… but let's say I wanted to replace everything. I'm gonna go back to my command mode regular expression. So, and you can always, go into command mode and hit an up arrow. To get your latest, or you can, you know, you can scroll through the commands also. And in order to make it apply to all the instances, I'm gonna say G at the end for global. Enter. But, wait, what just happened? Now, like, it butchered my catch's word as well? So… Generally, I probably want to leave space here when I'm replacing. We can… and we can undo. And replace cat with dog. Like this. So now I didn't. Match this other word. But, let's say I don't want to replace a word in the entire file, I just want to rename it in some line numbers, and, you know, and for instance, you have a function, you just want to rename your variable. within the function, not the entire file. Well, first we're gonna… Put the line numbering back on so that it's more clear. Set a new. And… We're gonna replace, but instead of percentage sign, we're gonna say lines 3 and 4. Or, let's say, 3 and 5. - Oh. And I forgot that I changed cat to dog, so let's do it the other way around. Oop. So we'll, we'll replace, on lines 3 through 5, dog to cat. Boom. Done. And, I know it's a coma, but it will… cover, which is not very intuitive. It will cover lines in between as well. And you can… you can do a lot with these replace regexes, all sorts of things. Let's… we can demo a few. Like, you can duplicate words, you can erase specific words, so we can… If I do double ampersands with a space, I can just… duplicate each instance of the word cat. Very useful appending text at the end of the line. let's say I just… a dollar sign for the end of the line. Let's say I just want some value. True. For the beginning of the line, you would… use, carrot instead of… Dollar sign, like this. And I'm gonna undo that. Okay, some… more examples that might be a little more useful when you're coding. If, let's say, you want to rename your variables, you want to make camel case instead of snake case, so this is regular expressions you could use. It will match the underscores, and it will replace the next letter with a capital. etc. This is deleting blank lines. D-do-do. Excellent. And, I guess we are now at the… visual block. section of the class, but, actually, I do want to leave a minute for questions. If, anybody has any… Jessica Eaton: There was a question about, like. Jessica Eaton: how you actually get good at this. Do you… did you… do you, like, have a cheat sheet by your laptop, or do you think it's just, like, practice, practice? I… I think if you use this, regularly for some time, you know, even, like, a month, you will… you will just memorize all… all of the shortcuts. And, of course, I don't remember by heart all these, regexes, But, the navigation, it just… yeah, you… you get a hang of it. Jessica Eaton: becomes the intuitive. Well, you just… Memorize it, pretty much, yes. Jessica Eaton: Got it. Anything else? Max Shortte: Did you replace… did you remove the cheat sheet at the end, or did you keep it, Helena? I'm not hearing you very clearly. What about the cheat sheet? Max Shortte: And when we had a debate, if we should have a cheat sheet at the end, did you remove it in the end, or did you manage… No, no, it's there, but it's a little limited. But honestly, there are really good, like, quick VI cheat sheets online with all the basic navigation commands. That, you know, perhaps for beginner users, it's useful to print it out, put it next to your computer. If you want to use VI. But, so let me just also quickly show you Visual Block, which I find very useful and like using. It's another mode in addition to insert command, and, you would enter it with hitting CTRL-V. And I'm gonna get out of this file, I'm gonna open… Email list, this one. So basically, this mode is for editing columns of text quickly, and I'm gonna hit CTRL-V. And when I move my cursor, you see that it is highlighting. Things. And let's say, you know, this is just, like, a list of names, email addresses, but, like, it could be code, right? It could be some config files. I just want to get rid of too much of this white space. So, Ctrl-V… I move cursor, I highlight all of this, and in order to erase, I hit X, and… yeah, we just quickly erased all of this. But what else? If I'm coding, and I just want to comment out some lines, and quickly insert a hashtag, you know, I don't want to go to each line, type it in, I'm also just gonna use visual block, so Ctrl-V… I'm gonna move down some lines. I'm gonna hit capital II for insert. Hashtag. And escape. And you see hashtag populated on the other lines as well. And you can… you can do a little bit more with visual log, but we're just touching upon it briefly. Today… And that pretty much concludes our lesson for today. This is the quick cheat sheet that we have, but like I said, you probably want a fuller set of commands, and better if you Google and grab a fuller set of commands from the internets. And, a little bit of humor. I know that all of these, VI shortcuts can be exciting to learn, and… but… It can take over your brain, so don't let that happen to you, like… this guy, which is… has all the VIN keybindings memorized, but can't remember anything else. All right. If anybody has any questions, please speak up. Jessica Eaton: And, I'm gonna drop a link about the feedback form here. This is a new session for us, and so if you have anything that you think worked really well, or anything that you would be interested in learning in the future, please let us know. I will also email out the slides and recording in the next day or two. Go ahead. Thank you for attending, everybody. Gonna stop sharing. Jessica Eaton: Yeah, I think those… that's a wrap. Okay. ˙ Jessica Eaton: Thanks, everybody.

This workshop focuses on the VI/VIM Linux text editor, teaching beginner users how to use it efficiently for tasks like safely opening and exiting files, navigating, editing text, and recovering from mistakes. The session covers key concepts such as VI being a modal editor with separate normal, insert, command, and visual block modes, and demonstrates commands for file navigation (HJKL, W, B, 0, $, G), text manipulation (I, A, O, U, X, D, Y, P), searching, and replacing text using regular expressions. The material highlights that VI's value due to its availability on all Linux/Unix systems and the fact that it works over SSH without a GUI.