-- Leo's gemini proxy

-- Connecting to sotiris.papatheodorou.xyz:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

Viewing TSV files in Vim


Tab-separated-values (TSV) are the simpler alternative to comma-separated-values (CSV). There's no need to quote anything which means you don't need a specialized library to generate or parse TSV, standard Unix tools are enough. I use them extensively for logs which are afterwards further processed using AWK. However there is one big annoyance when viewing those logs: the TSV columns aren't aligned, making it difficult to distinguish which column data belongs to. This is an issue with CSV files too but in the case of TSV it's fairly easy to solve in Vim.


Newer versions of Vim have an option called vartabstop. This allows specifying the tab width for each column separately. A small AWK script is enough to compute the appropriate value of vartabstop given some TSV data on standard input. I wrapped this in a Vim plugin imaginatively named vim-tsv and TSV files are now automatically shown with aligned columns. I also implemented another useful feature I read about on a blog post by Alan Grow, always showing the header line so you can see the column names when you scroll down.


Sotiris 2022/04/25


TSV file format specification

vim-tsv

Alan Grow's blog post


-- Response ended

-- Page fetched on Mon May 20 18:38:25 2024