Skip to content

Suggestion: partially concealing long columns #57

@pvelayudhan

Description

@pvelayudhan

Hello,

Thanks for the great plugin!

I am wondering if there is a simple way to use rainbow_csv in conjunction with a custom CSV conceal rule outlined below.

The following vimscript when placed in after/syntax/csv.vim in isolation creates the effect of truncating CSV columns longer than a specific number of characters (in this case, 20):

highlight ConcealedText ctermfg=gray guifg=gray
syntax match ConcealedText /\([^,]\{20}\)\zs[^,]*/ conceal cchar=*
set conceallevel = 2

Instead of an aligned CSV looking like:

column_1                                        , column_2                           , column_3
asldkfjahsfasd;faskjdf;laskjfa;slfkjasdkljasdhf , aslkjdfhalskjdfaslkjfashldkfjashfd , asdkljfhalskdjfhaslkfjshalfdkjshflsakjfhsd

It will look like:

column_1            * , column_2           * , column_3
asldkfjahsfasd;faskj* , aslkjdfhalskjdfaslk* , asdkljfhalskdjfhasl

And expand to the unconcealed text depending on the user's concealcursor settings.
This type of conceal makes working with CSVs in vim a little closer to typical spreadsheet editor software, where every column doesn't need to be expanded to max width at all times.

I understand the conceal rule I've outlined doesn't handle escaped commas. And I would imagine that implementing this feature would involve somehow duplicating the syntax rules such that instead of there being column0, column1, etc., there would need to be a separate column0_visible, column0_concealed, .... type of structure.

If this goes too far beyond the scope of this plugin, no problem at all. Sorry if the request is a little vague and thanks again for making this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions