Home Download Buy Blog Forum Support

Split Into Lines

Split Into Lines

Postby brad_ on Sun May 26, 2013 1:48 am

Hello

I just purchased ST2 this evening because I had to do some major refactoring and the multiple selection & join lines & split into lines were just what I needed.

I searched this forum and found a few posts about how the OSX version of ST2 was not splitting a selection into lines. Then they posted that they had figured it out. The problem is that they did not write their solution!

How do you make a line with multiple words, separated by a space (or some other punctuation) move so that each word occupies one line?

When I press Command+Shift+L I see the menu flash, yet nothing happens. Then when I use the menu choice Split Into Lines, still nothing happens.

I saw one response to a post on this subject that you can merely select all of the spaces and press Return to get the same effect. If that is what we need to do, what is the menu choice and keyboard shortcut for?

I am certain I am doing something wrong, and the answer is right in front of my nose. I hope someone can give me some help.
brad_
 
Posts: 6
Joined: Sun May 26, 2013 1:39 am

Re: Split Into Lines

Postby skuroda on Sun May 26, 2013 2:21 am

"cmd+shift+l" splits the selection into lines, though I don't think that is what you want. Your selection would have to cover multiple lines before you hit the key command. Then, it would create a cursor at each line.

Anyways, take a look at my answer here. If you want to maintain the split character(s) you will have to modify the substitution some, but I think that should do what you want.

If you don't want to use a plugin, you can always select the split character, then use cmd+d to select the necessary instances. You could also use the find all under command if you simply want to select all instances. Alternatively, you can use the find and replace functionality.
skuroda
 
Posts: 674
Joined: Fri Oct 05, 2012 8:11 am

Re: Split Into Lines

Postby brad_ on Sun May 26, 2013 4:06 pm

I appreciate the response. I don't mind using a plugin if that is what it takes.

I read on SO that you continued your "tech support" via chat. Is the code that shows on that SO page the final result?

The OP on that SO page wanted to do exactly what I am seeking to do, so I am thankful for the link you provided. :)

The question remains though, what does the menu choice "Split into Lines" do?

You wrote:
"cmd+shift+l" splits the selection into lines, though I don't think that is what you want.


But that is exactly what I want. Perhaps we are referring to two separate things.

You wrote:
Your selection would have to cover multiple lines before you hit the key command. Then, it would create a cursor at each line.


Does "Split Into Lines" refer to the cursor? If this is the case, I guess I assumed too much from watching the video on the ST2 homepage. I assumed since there was a Join Lines command, the Split Into Lines was the opposite of that. I just noticed that those two commands are located on two different menus: SIL is on Selection, and JL on Edit. :oops:

I will make use of your plugin. Thank you for the help.

brad
brad_
 
Posts: 6
Joined: Sun May 26, 2013 1:39 am

Re: Split Into Lines

Postby skuroda on Sun May 26, 2013 6:21 pm

Yes the SO page is the final result. The chat (and well most of the comments) were to help him get a plugin up and running. If you can do that though, the chat really isn't useful :) . So split lines does the following...

It takes a region such as
Image

and turns it into
Image

It creates multiple cursors on the various lines, across your selections. So if you only highlight a single line, and run the split line command, it splits to 1 line, which is still 1 cursor :D It's not really the opposite of join lines. What it does is is quickly switching to multiple cursors after you make a selection.

I hope that makes things a little clearer.
skuroda
 
Posts: 674
Joined: Fri Oct 05, 2012 8:11 am

Re: Split Into Lines

Postby qgates on Mon May 27, 2013 12:34 am

Choices, choices.. Two easy ways that avoid writing plugins:

1. Hilight your space, press Alt+F3 (windows) to select all, hit return.
2. If the whitespace varies, use a regex search, then select all as above and hit return.

If you only want to do a subset of your file, you could use Ctrl+D to select them individually, or you could quickly CnP the desired section over to a new file before using the above method, then paste the fixed text back, or you could regex search within selection.

Pressing return will replace what's hilited with a newline. If you don't want to lose that whitespace char - eg, say its a comma you want to keep - just hit "right" before hitting return. The selections turn into cursors, and you newline at every cursorpoint.

st-space-lb.gif
st-space-lb.gif (222.4 KiB) Viewed 6354 times
qgates
 
Posts: 188
Joined: Mon Nov 05, 2012 4:33 pm

Re: Split Into Lines

Postby neurogenesis on Tue Jul 30, 2013 6:02 am

hah. nice post.

i saw that demo on the front page of the site and immediately wanted to try it as well.

"cmd+shift+l" splits the selection into lines, though I don't think that is what you want. Your selection would have to cover multiple lines before you hit the key command. Then, it would create a cursor at each line.


in retrospect, it possibly might have made more sense to label that menu option (cmd+shift+l) "split cursor" instead of "split lines". i think that more accurately describes what the text editor is doing in that case.

the ability to split a line selection using a quick search/regex would be really helpful for that very purpose. with all the support for python, it'd be interesting if one was able to hit a key-combo which brings up a text box to execute arbitrary code. something like:

Code: Select all
selection.split(', ')


the cursor split and line join options are great though. although it took a few attempts to figure out how to split the lines in the first place (find/replace on just a single line). i half expected the command options to be consistent with other GUI editors (<something>+F for find, <something>+R for replace). instead, those commands seem to be a little jumbled around (possibly for familiarity with legacy text-based editors). additionally, some options in the same UI are alt+cmd+something vs. ctlr+alt+something (select regex expressions vs. replace all for exmaple). some consistency there, or context-sensitive options to reduce the number of key combinations required, might help simplify things.

all minor, and just a matter of not being familiar with the editor's idioms yet i guess. i imagine those can be corrected with keybindings, but typically that won't be reflected in the menu options (unless those are dynamic and not compiled in).
neurogenesis
 
Posts: 1
Joined: Tue Jul 30, 2013 5:34 am


Return to General Discussion

Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests