micans
micans

Reputation: 1116

How to create a strictly columnar display in Vim for a tab-separated file

In vim, I'd like to display tab-separated files such that the tab stop is strictly respected, meaning that each individual column is strictly aligned. This requires any content that does not fit into the width of a tab to be truncated. For example, with a tab-stop of 8 I would like this:

the quick fox<TAB>brown<TAB>4 legs
dog<TAB>lazy<TAB>floppy ears

to be displayed as (first line (ruler) is for illustration purposes only)

#23456781234567812345678 <- ruler
the qui|brown  |4 legs |
dog    |lazy   |floppy |

I've looked around for tab-separated and keywords like truncate and fold, but to no avail.

Upvotes: 2

Views: 781

Answers (1)

Araxia
Araxia

Reputation: 1155

I believe you're looking for conceal (added in 7.3; :help conceal).

:syntax match Entity "[^\t]\{8}\zs[^\t]*[\t\n]" conceal cchar=|
:set conceallevel=1

Adjust the 8 to taste, or wrap the syntax command with exec to insert &ts (or &sts).

Upvotes: 2

Related Questions