Longwood University



Beginners Guide toFigure 0: PatelLongwood University Beginners Guide to Vim This is a guide for beginners who are interested in learning vim on a Linux operating system. This manual will show why vim is very useful for people who code. It will also show the new user how to navigate through vim and see the features that it offers to coders. This manual will be more helpful to readers who uses and understand Linux. The manual will first start off talking about what is vim and why you should use it. Then the manual will go into detail on how to use vim and how to navigate it. Pictures, diagrams, and tables will be shown to help you follow the instructions. By the end of the guide, you will understand and will be comfortable in using vim. What is Vim and why use it?Vim is a type of editor that is very known to be used in a Linux operating system. This editor is a modal text editor, which means that you use the keyboard to navigate and to use vim. Why coders should use vim is because of it being a modal text editor. This allows the user to keep their hands on the keyboard, making it faster and more efficient for the user to code. It is difficult to get a grasp on using vim, but once you get it, you will see an improvement in your coding. Any type of coding language can be used by vim, and you will see that vim will help you understand more of your favorite language. How to use VimLet’s get started! First let’s talk about what you will need to start! Here is a list to help you know what you will need. A computer that has any type of Linux operating systemA working keyboardYou would need to know how to open your terminal on your computer. Once you have all those things we can now start. Let’s first learn how to open a vim file. How to open a vim fileOpen the terminal in your Linux operating system. Once you are in the terminal, in the command line you will type in vim and then the name of your text file name. Then press Enter. Figure 1: what the screen should look like when you are typing in your command line to open your vim fileA blank screen will appear, and at the bottom will have the name of the file and in brackets will say New File. Figure 2: What the screen should look like when you are in the vim fileYou have now learned how to open a vim file! Now let’s talk about how to write, move, edit, save and exit a vim file. To do this you will learn about the three different types of Modes that vim has. The different types of Modes There are three different types of modes to use in vim: Insert modeCommand modeLast-line mode Insert mode Insert mode allows you to type in the file. This is where you will type in your code. Here is how to get into Insert mode and type in it.Open your vim fileOnce you are in your vim file just type in i and press enterIt will show you the same blank screen and the word INSERT at the bottom of the file.Figure 3: what the vim file looks like in Insert mode.You can now type anything you want in this file. Figure 4: Example of typing in a vim file Once you are done typing, to get out of Insert mode, press the esc button on the keyboard. The word Insert at the bottom of your screen will be gone, but what you have typed in Insert mode will still be there.You have now learned how to type in a vim file! Now let’s talk about moving and editing in your vim file. To do this we need to talk about the Command mode. Command modeCommand mode is the default mode that vim will start up on every time you open a vim file. This is where majority of the editing happens in vim. There are many commands for editing and moving around in the vim file, and all is used with the keyboard. Before we start; make sure you are not in Insert mode, if you are in Insert mode the commands that you type in will show in your code. How do you know you’re in Command mode?Unlike Insert mode; to get into Command mode there in no typing on your keyboard to get in or out of it. When you open your vim file or esc from any mode you are in Command mode. Moving in vimNow let’s talk about how to navigate around the file, then we will look on how to edit the file. Here are some basic commands to help you move through the vim file fast and easy. Basics commands for moving in vimhMoves the cursor one character to the leftjMove the cursor down one linekMoves the cursor up one linelMoves the cursor one character to the rightOMoves the cursor to the beginning of the line$Moves the cursor to the end of the linewMoves the cursor forward one wordbMoves the cursor backward one wordGMove cursor the end of the fileggMoves cursor the beginning of the fileFigure 5: a table for commands to move the cursor in Command modePractice moving around in vim with the new commands that are listed above in a vim file you created. You may want to have multiple lines written in your vim file so you can practice all the commands. You just learned how to move through a vim file!Editing in vimNow that you know how to move through a vim file, let’s talk about how to edit a vim file in command mode. Like moving through a vim file, you will be using the keyboard to edit your file as well. Here are some basic editing commands that every beginner should know. Basic commands for editing in vimddDeletes an entire linedwDeletes a worddoDeletes to the beginning of a lined$Will delete to the end of a linedggDeletes to the beginning of the filedGDeletes to the end of the fileuUndoes the last operation/textSearch for texts in a documentcTo cut a lineyTo copy pTo paste VHighlights one line at a timevHighlights one character at a time Figure 6: a table for commands to edit in Command modeThese are the few commands that every beginner should know, if you are curious about more commands here is a cheat sheet that shows more commands. This cheat sheet also will help you remember other basic commands. Cheat SheetFigure 7: a cheat sheet to show where commands are located on keyboardIf you like to see a bigger picture of the cheat sheet go to this link. should practice these commands in a vim file. You should have multiple lines so you can move around and edit your file. You have now master how to move and edit a vim file! Last-line modeNow that you know how to write, move, and edit your vim file, it’s now time to learn how to save your file. This happens in the Last-line mode, here are steps into getting into this mode.Make sure you are in the command modeType on the keyboard the colon button : (press shift and : ) then press enterYou are now in Last-line modeNow that you are in this mode, you can now save and exit your vim file. Like the command mode, you will be using the keyboard to save and exit. To do this here are commands that allows you to do this.How to save and exit:wSave a file:qExit a file without saving it:wqSave and exit the fileFigure 8: a table of commands in Last-line modePractice these new commands with a vim file. Remember if you are editing a vim file and want to exit it, be sure to save the file before exiting, or all your work will be gone. You have now learned how to save and exit a vim file!You are all set!You now understand how vim works and how to use it. You understand the three modes of vim and what each mode does. You’ve learned commands to help you navigate, edit, save and exit a vim file. You also practice in each mode to understand how they work. Even though it is difficult to only rely on the keyboard to use a vim file, it will get easier to use with more practice. Best of luck to all new vim users! ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download