How can I set vim to only visually align assignments without actually changing the underlying code? Or is there a plugin which can do so?


int c = 8;
int result = 123;


int c      = 8;
int result = 123;

Without underlying code change.

I'm definitely not asking for plugins that perform alignment by altering the text. The indirection between the code itself and how it is visualized must be present.

So, this is much more like :set wrap. That also only alters the visualization, but it doesn't actually add linebreaks to the document.

  • 3
    With a very small number of very hacky exceptions, this isn't possible in current versions of Vim. (And I think it's unlikely it ever will be.) – Rich Jun 12 '20 at 10:52
  • What makes it hard? For example the breakindentopt option can shift by a given number of characters (for line wraps). Is this - what I'm asking - inherently more difficult? – Anne van Rossum Jun 12 '20 at 12:49
  • 3
    what makes it impossible is, that there is a very tight coupling of what you see and what the underlying text is. With the exception of list breakindent` and concealing, that only allow a very limited change of the appearance of the underlying physical structure of the file there is nothing which can change this, yet relate the visual structure of different lines and calculate correctly. Perhaps the vartab feature can be used for that if you use tabs for indenting. Not sure. – Christian Brabandt Jun 12 '20 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.