helix icon indicating copy to clipboard operation
helix copied to clipboard

feat: Commands for aligning text. `:align-text-left`, `:align-text-right` and `:align-text-center`

Open nik-rev opened this issue 9 months ago • 3 comments

This PR adds:

  • :align-text-center to center text (alias :atc)
  • :align-text-left to align text to the left (alias :atl)
  • :align-text-right to align text to the right (alias :atr)

Showcase:

https://github.com/user-attachments/assets/697e76f5-5a4b-4fe2-b19f-4a7a39881d05

All commands also take a parameter that allows you to specify what text width to use. If you don't use this parameter, it follows language config -> editor config text_width setting.

nik-rev avatar Feb 24 '25 00:02 nik-rev

Hi! This PR would be so important for my workflow. I just want to add that I built this branch and it seems to be working perfectly.

ronisbr avatar Jun 02 '25 18:06 ronisbr

Note:

I thought about collapsing all :align-text-* commands into a single :align-text with flags --left, --right and --center

I don't think it's a good idea because all the flags are mutually exclusive And :align-text-left takes 0 arguments while -right and -center take 1 argument

nik-rev avatar Jun 06 '25 11:06 nik-rev

Added tests for each command

nik-rev avatar Jun 11 '25 11:06 nik-rev

Note:

I thought about collapsing all :align-text-* commands into a single :align-text with flags --left, --right and --center

I don't think it's a good idea because all the flags are mutually exclusive And :align-text-left takes 0 arguments while -right and -center take 1 argument

There's however a good benefit of collapsing the commands. I could map a single key to :align-text -- and at the command prompt either type or use tab key to select how I want to be aligned. Maybe such a command could be added in addition to the three separate ones?

yerlaser avatar Aug 12 '25 10:08 yerlaser