Complete a Whole Line in Vim
This week I picked up an excellent Vim command: CTRL-X CTRL-L
. This command searches backwards through your project and inserts a matching line after the cursor.
So, if there's a line in your project like this:
defimpl Phoenix.Param, for: Tilex.Developer do
And I type defimpl
(which is unique enough to match just a few lines of code in my project), Vim will suggest matching options, letting me choose a match to complete it:
defimpl Phoenix.Param, for: Tilex.Developer do
defimpl Phoenix.Param, for: Tilex.Developer do
This is useful when writing code in a framework like React.js, where the head of many files often includes a group of repetitive import statements.
See 'Insert mode completion' inside insert.txt
in the Vim help for more information.
h/t Dorian Karter
Tweet