I'm editing a table in extended-markdown, and I'm wondering how to easily edit cells without moving the dividing lines.

Tables are formatted like this:

| HEADING1         | HEADING2       | etc...
| ---------------- | -------------- | etc...
| row 1            | column2        | etc...
| etc...

Suppose I want to change an entry but leave the next | in its place. Ideally, I'd go to the first word in the cell and use c<something>, type the new entry, and, upon leaving insert mode, a sufficient number of spaces would be inserted or deleted after the new text to ensure that the | character is restored to its original location, if possible. (Obviously if too much text is entered, this won't be possible; one solution for this would be to somehow restrict the insert operation to the maximum number of characters to permit retaining the cell-shape, though I don't know if Vim permits this.)

This seems like it should be possible to implement by creating a new text-object or something, though I realize there would be a fair amount of "magic" involved since leaving insert mode would trigger a second edit operation.


1 Answer 1


Have you tried the R operator? This will let you overwrite whatever text you need to without moving the |. If your word is shorter than what you're replacing, you can simply fill the rest with spaces.

See :h R for more info.

  • It's so simple. This is exactly what I was looking for; thanks. Jul 14, 2016 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.