Search code examples
haskellvimindentationtabularvim-tabular

Align Haskell import statements in Vim using Tabular plugin?


I'd like to format Haskell import statements into style I usually see in published source code.

From this:

import Data.Map
import qualified Data.Vector as V

To this:

import           Data.Map
import qualified Data.Vector as V

I'd like to not have to install any plugins that specialize in just doing this. Just Tabular. Could someone help me with the regexp needed to make this happen?


Solution

  • Assuming you want to just align the first uppercase character so that they are on top of each other, this appears to work on your test case

    :%Tabularize /\C[A-Z].*/
    

    The \C forces case sensitive comparison.