Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to add spaces at the end of a each line in notepad++ upto fixed column

Tags:

notepad++

i have a text document with several lines. Each line ends at different column. I want to add spaces at the end of a each line in notepad++ upto fixed column. How can i do it in notepad++.

like image 685
Anshu Gupta Avatar asked Oct 28 '25 08:10

Anshu Gupta


1 Answers

I have only a very ugly solution with notepad++ without any additional Plugin, but using it once maybe ok. Say you want to expand to a linelength of 80 chars, thus we need to expand each line shorter than 79. We will do several regular expression find/replaces (replace all affected lines in the whole file at once) until all lines have the desired length (i.e. if there is one empty line in the file, to expand it to 80 spaces we have to do 80 Replaces!). Here are the details:

Open the replace Dialog:

  • Find what: (^.{0,79})$
  • Replace with: \1 (there is a space after the 1!)
  • mark Regular expression in the lower left and select Wrap around
  • click Replace All repeatedly until the message in the statusbar of the replace dialog tells yout, that there were no more occurences. (You can hold down Alt-A for a few seconds, so that is not as ugly as it sounds.)

See the screenshot: replace dialog

like image 58
Lars Fischer Avatar answered Oct 31 '25 11:10

Lars Fischer