From the course: Learning Vim

Read command - vi Tutorial

From the course: Learning Vim

Read command

- [Instructor] Say you're writing some Python code, vim hello.py. You decided to license your code under the Apache license. I need to add a header to every file. An easy solution is to write such a header and then read it into a file. To read the file, use :r. Since :r inserts the text under the current line, we first need to insert a new line. So, Shift + o and then escape and then :r and license header.txt and end. And now the delete the new line. So, K to move one line up and DD to remove the line. You can make it simpler if you use a motion command. We can use the minus one line, the previous line, as the location to insert the new line. Let's undo with :e! and enter. This will reload the file from the disk disregarding any changes we made to it. And now, :-1 and then read and then license header.txt and enter. If you start to find imperfects and hit Tab vim will complete the name for you. So, :-1r li and tab and we got the file name.

Contents