From the course: Learning Vim
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Start Vim with a command
- When you invoke Vim with an argument starting with plus sign Vim will interpret this argument as a command to execute. A common case is to start Vim in a specific line. So we do Vim hello.go + 8. And Vim will start at line number 8. This is like opening hello.go and then entering colon 8. Let's quit, colon Q, enter. However, commands are not limited to just line numbers. Say you're reading Sherlock Homes story and you'd like to resume, you remember that you stop when Count Kramm first came to visit Sherlock. What we can do is, let's clear the screen, vim sherlock.txt and then +. And then we're looking for Kramm and it will jump to the first occurrence when Kramm is in the text. You can specify several commands to automate some text processing with Vim. Let's quit this one and clear and have a look at a file called conway.txt. We see we have two empty lines at the beginning. So we can do Vim + 1, 2, which is the range from line 1 to line 2 and d, the action to delete. And then…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Start Vim with a command1m 38s
-
(Locked)
Challenge: Use Vim command4s
-
(Locked)
Solution: Use Vim command26s
-
(Locked)
Diff mode3m 4s
-
(Locked)
Challenge: Diff mode8s
-
Solution: Diff mode18s
-
(Locked)
Zip files1m 19s
-
(Locked)
Challenge: Zip file8s
-
(Locked)
Solution: Zip file22s
-
(Locked)
Open files from name1m 22s
-
(Locked)
Challenge: Open file to line number11s
-
(Locked)
Solution: Open file to line number26s
-
(Locked)
External commands2m 9s
-
(Locked)
Challenge: External command13s
-
(Locked)
Solution: External command31s
-
(Locked)
-