Append text to lines in Vim

Vim Icon Every time someone shows me something they like about some other editor it is always fun to show how the same thing can be done in vim. A popular thing in modern editors now seems to be multiple cursors and folks get excited about appending some text to a bunch of lines all at the same time.

Suppose you have a bunch of lines that you want to turn into an unordered list in HTML. Here is a quick and easy way to add something to the end of a line in vim.

  1. Select the lines you want to work with
  2. norm (type the following commands)
  3. A</li> (the string you want to append to the lines)

If you visually select the lines you want to work with, the full command might look something like this.

:'<,'>norm A

And that will take your from code that looks like this:

  • line one
  • line two
  • line three

To code that looks like this:

  • line one
  • line two
  • line three

Leave a Reply

Your email address will not be published. Required fields are marked *