editorconfig / editorconfig-vim

EditorConfig plugin for Vim
http://editorconfig.org
Other
3.11k stars 135 forks source link

Add "fillexceeding" option for max line indicator #203

Closed mmrwoods closed 1 year ago

mmrwoods commented 1 year ago

The "exceeding" indicator can be hard to notice as it fills just one column on lines that exceed the max line length. To address this, add a new indicator option "fillexceeding", which fills all the columns that exceed the max length.

I've been using this snippet for years in my vimrc, but making it work with editorconfig is messy as the custom highlighting needs to be applied after editorconfig has changed textwidth (i.e. autocmds are required). It would be nice if editorconfig-vim just supported something similar. I suppose another option would be for editorconfig to allow the calling of a custom function to highlight long lines.

mmrwoods commented 1 year ago

Some screenshots may explain this better...

Before let g:EditorConfig_max_line_indicator = 'exceeding' screenshot_exceeding

After let g:EditorConfig_max_line_indicator = 'fillexceeding' screenshot_fillexceeding

cxw42 commented 1 year ago

Thanks for this PR! I can't see the difference in the two screenshots --- could you please highlight the change in the second image? Much appreciated!

mmrwoods commented 1 year ago

Hi Chris,

On the first screenshot only the first character exceeding the max line length is highlighted, on the second screenshot all characters exceeding the max line length are highlighted.

The difference is noticeable on lines 26, 40 and 47 when comparing both screenshots. Granted, the highlight is subtle, all the more reason for wanting to highlight all the characters exceeding max line length rather than just the first.

I realise I can just set hi ColorColumn to something that screams at me, but I do not want that kind of distraction. Having a max line indicator is a guide, I don't always want to force a hard wrap at max line length, especially when editing other people's code, but by filling all characters exceeding max line length rather than just the first I can more easily see which lines are the worst offenders.

Mark

mmrwoods commented 1 year ago

Hi @cxw42, documentation updated as requested, thanks for your feedback :-)

cxw42 commented 1 year ago

Merged --- thanks again for your contribution!

mmrwoods commented 1 year ago

And thanks for merging, now I can get rid of another hack in my vimrc!