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

Start Vim with a command - vi Tutorial

From the course: Learning Vim

Start my 1-month free trial

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…

Contents