Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for an easy way to align text

Tags:

notepad++

I have a common problem that I'm looking for a solution to. I have lines of similar text I'd like to somehow automatically insert text to align them vertically such that:

x="foo" data="123" y=x
x="b  4" data="12 " y=x
x="baaar4" data="123aaa5" y=x
x="baaaa,4" data="123dddd5" y=x

becomes this

x="foo"     data="123"      y=x
x="b  4"    data="123 "     y=x
x="baaar4"  data="123aaa5"  y=x
x="baaaa,4" data="123dddd5" y=x

This is a text issue. The input comes from notepad. The output is going to notepad. This is not a formatting issue.

like image 862
jhon smith optional Avatar asked Jan 10 '12 18:01

jhon smith optional


People also ask

What is the shortcut for Align text?

The shortcut key to centre align the selected text is Ctrl + E. Q.

What are the four ways to align a text?

There are four main alignments: left, right, center, and justified. Left-aligned text is text that is aligned with a left edge.


3 Answers

Notepad++ has a plugin that does this for you. It's called "Code alignment". It allows you to align text vertically based on characters of your choosing. You can install it via the Plugin Manager for notepad.

Below is a simple usage scenario. You start off with the following code, then you align by "equals" which is a built-in shortcut/command for the plugin.

Initial Code Sample, without alignment

After that, you end up with the following below:

Code after equals alignment

You can also take it a step further and use the "align by..." command which allows you to specify any arbitrary alignment string. In the example below, I chose the "#" character in order to align my comments next to one another. This could just as easily have been a longer string, and not one of length 1.

End result below:

Final result after arbitrary code alignment string

like image 177
Zoran Pavlovic Avatar answered Oct 19 '22 11:10

Zoran Pavlovic


If you want to align by specific characters use Notepad++ extension TextFX.

Look at: TextFX > TextFX Edit > Line up multiple lines by (,)

There are also: Line up multiple lines by (=), and Line up multiple lines by (Clipboard Character)

Here is a link for helpful tips for programming.

http://techbrij.com/518/10-notepad-tips-tricks-fast-development

like image 29
iSpardz Avatar answered Oct 19 '22 11:10

iSpardz


Notepad++ TextFX is not longer supported and maintained. The Code alignment plugin only aligns the first occurence of the column aligning character.

I solved the problem using a free online service: https://onlinetexttools.com/convert-text-to-nice-columns

like image 5
Emiliano A. Carlevaro Avatar answered Oct 19 '22 12:10

Emiliano A. Carlevaro