



Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!




The goal of this exercise is to give you practice with the different ways to insert, change, replace, and join text.
Open the insert-practice.txt file
First, start a command line session on your local machine. Next, use vim to open the "insert-practice.txt" file that came in the course downloads. To do that, navigate to the location of the file. Remember this could be different for you depending on where you extracted the contents of the file. This example assumes the course download was saved into your Downloads folder and extracted from there.
cd Downloads cd vimclass vim insert-practice.txt
Using the i command
Remember that the i command places you into insert mode right at your current cursor position. Use i to insert some text at the very beginning of the first line in the file. For example, you might insert "vim". After you have inserted the text, return to normal mode with
Using the I command
Move down to the next line of text by type 2j. Your cursor will be in the middle of this line:
<= What is your favorite color?
Insert text at the very beginning of the line by using the I command. Answer the question posed on the light. Your answer might be "blue," for example. Hit
Using the a command
Position your cursor on the next line of text with 2j. Insert your name between these symbols: ><.
Enter your name here =><=
To do that, first position your cursor under > with f>. (NOTE: The f command is covered in the searching lesson. For now, know that it moves your cursor to the character you specify, but only on the same line.) Next enter insert mode after your cursor position with the a command. Now type your name and finally press
Using the A command
Position your cursor on the next line of text with 2j. Append your name to the end of line by typing A which places you in insert mode at the end of the line. When you are done typing your name press
Enter your name here:
Using the o command
Position your cursor on the next line of text with 2j. Enter insert mode on the line below the current line by typing o. Next, type the name of your favorite movie. When you are done press
One the line below, type the name of your favorite movie.
Using the O command
Position your cursor on the next line of text with 2j. Enter insert mode on the line above the current line by typing O. Next, type "vim" and press
^^^ One the line above, type the name of the editor you are using.
Using the J command
Position your cursor on the next line of text with 3j. Join the following lines:
This line belongs with the one below it.
After your edit, they will appear on the same line:
This line belongs with the one below it.
I am having a brilliant time in this vim class!
First, position your cursor under "g" in the word great. You can do the by performing a forward search with /gr
In the following sentence, change "myself." to "everyone!":
I love myself.
After your edit, the line should look like this:
I love everyone!
First, position your cursor under "e" in the word everyone. You can do the by performing a forward search with /my
Change this entire line of text to anything you want to type:
Type something wonderful here.
First, place your cursor anywhere on the line with 2j. Next, use the command cc which allows you to change the entire line. Type anything you want. For example, "The sky is beautiful!". Finally press
Changing case with the ~ command
Capitalize the first letter of the word "monday" on this line:
monday <= The "m" is supposed to be in uppercase.
To do that place your cursor under the "m" by performing a forward search with /m
Capitalize the entire word "shout" on this line:
Don't shout. It's not nice.
To do that place your cursor under the "s" by performing a forward search with /sh
Switch the case of the entire following line:
mONDAY'S START BETTER WITH coffee.
After your edit it will look like this:
Monday's start better with COFFEE.
To make that change, place your cursor anywhere on the line with 2j. Next type g~~ to switch the case of the entire line.
Using the U command
On the following line, change the word "Shout" to "SHOUT":
Don't Shout. It's just too loud.
To do that place your cursor under the "S" by performing a forward search with /S
Try it again on the next line, but this time use gUW.
Using the u command
One the following line, change the word "Whisper" to "whisper":
Please Whisper.
To do that place your cursor under the "W" by performing a forward search with /W
Repeating commands
One line below the following line, create a new line that contains 80 asterisks (*).