How to align text to the right with notepad++?

flyingbird013 picture flyingbird013 · Oct 30, 2017 · Viewed 12.5k times · Source

I have text like this:

1;a;3;;
2;abc;4;;
3;abcde;5;;

I want to align texts to the right with notepad++, so become like this:

    1;a;3;;
  2;abc;4;;
3;abcde;5;;

How to do this?

Answer

help-info.de picture help-info.de · Oct 31, 2017

I think you'll need two main steps here. In Notepad++, select Plugins -> Plugin Manager and check if the TextFX Characters plugin is installed.

Solution for use case 1

  1. Search for the longest line,
  2. set cursor to the end of the longest line,
  3. press and hold Alt,
  4. click left mouse button and move mouse to upper left corner,
  5. go to Menu TextFX > TextFX Edit > Pad rectangular selection with space,
  6. repeat steps for lower left corner (select empty last line too),
  7. save the file looking like upper left corner shown in the screenshot below.

enter image description here

Solution for use case 1 (continue)

  • Ctrl+H
  • Find what: ^(.+?)(\h+)
  • Replace with: \2\1
  • check Wrap around
  • check Regular expression
  • Replace all

Solution for use case 2

Copy the character used as a delimiter ";" to the clipboard and select all rows.

Select TextFX -> TextFX Edit -> Line up multiple lines by (Clipboard Character):

enter image description here

Special use case 3

BTW - you may want to use Ctrl+Alt+R for viewing and writing right align and switch back by using Ctrl+Alt+L for left align.