vim linux column formatting -- handling string literals

79 Views Asked by At

Doing some programming in VIM I'd like to automatically line some stuff up in columns. Doing :!column -t works for the most part but it doesn't know the concept of a string literal so those are getting modified as well. Is there any short way of getting it to treat the string literal as a single cell of the column?

* edit *

For example, if I currently have the rows

stringType short "Short string" plusSome
otherStringType longStringName "Intentionally do a longer string" plusSomeMore

I'd like it to be formatted as

stringType      short          "Short string"                     plusSome
otherStringType longStringName "Intentionally do a longer string" plusSomeMore

instead of

stringType      short          "Short         string" plusSome
otherStringType longStringName "Intentionally do      a        longer string" plusSomeMore
1

There are 1 best solutions below

3
On

Take a look at the tabular plugin, it does what you want and a lot more. See this screencast for a quick intro.