rstudio/rstudio — pull request #236 by kevinushey (2014-12-01 04:18:22+00:00)
Title: Add a hotkey for vertically aligning consecutive assignments

This PR adds a hotkey `(CMD.CTRL) + SHIFT + A` for automatically vertically aligning consecutive assignments within a selection.

![auto-align](https://cloud.githubusercontent.com/assets/1976582/5240977/0ec4bf10-78c7-11e4-8278-2c956d66f5bb.gif)

This works by doing the following:

1. We identify ranges of consecutive lines containing one of the three assignment operators `<-`, `<<-` and `=` within the current selection,
2. We separate each line in the range into pieces `start`, `delimiter`, `end`,
3. We pad the start pieces with whitespace up to the largest 'start' piece,
4. Then add the delimiter (right-justified for multiple 'types' of delimiters in the same range),
5. Then add the end (potentially right-justified if all bits are numbers).

To avoid erroneously matching assignment operators in a string, e.g. `"this = that"`, we 'mask' strings on the line by replacing anything within quotes with the character `x`. However, we do not do anything special for multi-line strings.