Question: I need to annotate a text file, so I would like to add a `|` pipe character to the end of each line to put my annotations relatively close to the original text. Each line is *up to* 72 characters in length. How might I move to the 74th character of the line, even if the line itself is shorter (i.e. add spaces if needed)?

My current solution is to simply add 72 spaces to the line, then to move to position 74 and delete the remaining spaces. Is there not a more elegant method in VIM?

My current (inelegant) macro:

```
qq$74a<space><esc>74|i|<esc>lDjq

```

I'm currently using VIM 8.0.133 on CentOS 7.3.

Answer: 
You could also enable `'virtualedit'` option and directly jump to the column you're interested in.

A very similar question as been asked lately on SO: <https://stackoverflow.com/questions/41964261/how-do-i-put-the-character-in-6th-column-and-80th-column-in-vi/41964372#41964372>
Here's one way to do it without having to edit and restore `'virtualedit'`:

```
:execute "normal " . string(73 - strwidth(getline('.'))) . "A " | normal A|

```

This runs two commands:

1. The part *before* the bar `|` calculates the number of spaces required (`73 - strwidth(getline('.'))`) and then uses that as a count to a normal mode command that appends a single space, thus appending the correct number of spaces,.
2. The part *after* the bar simply appends a pipe character `|`.