You are here: PSPad forum > English discussion forum > Select word left/right if "-" (minus) sign is present

Select word left/right if "-" (minus) sign is present

#1 Select word left/right if "-" (minus) sign is present

Posted by: FrederikS | Date: 02/12/2018 11:22 | IP: IP Logged

Hi there,

I would like to transform a file with data in a single row of space-separated entries into a file with row and columns format. Each block of n entries in the original file belongs to a single block of data and should become a new line in the new format. I could in principle acomplish this task very easy with a macro, using the "strg+right" shortcut. This shortcut jumps to the beginning of the next word. However, it "skips" the minus sign, which is a problem. I.e. if a negative value is present, it jumps AFTER the minus sign, treating it the same as the whitespace before.

Can I change this behaviour somehow?

Many Thanks
Frederik

Options: Reply | Quote | Up ^


#2 Re: Select word left/right if "-" (minus) sign is present

Posted by: pspad | Date: 02/12/2018 12:36 | IP: IP Logged

Is there any rule how to recognize end of line? If yes, you can use regular expression in search/replace and split it to lines by one step

Options: Reply | Quote | Up ^


#3 Re: Select word left/right if "-" (minus) sign is present

Posted by: FrederikS | Date: 02/12/2018 13:29 | IP: IP Logged

Unfortunately not. It is simply a list of space separated values (single line).

I found a way to circumvent the problem by starting from the back and moving to the left. I can then savely move an additional character to the left, which is either space or minus, before hiting "enter" / adding EOL . The trailing/starting spaces are irrelevant. But still, a general solution might be useful.

Also, it would be nice if one could set the automatically repeated macro to proceed the whole file or stop conditionally.

But at any rate, I have a work-around now.

Options: Reply | Quote | Up ^


#4 Re: Select word left/right if "-" (minus) sign is present

Posted by: pspad | Date: 02/12/2018 14:03 | IP: IP Logged

Hello
Does it means there is the same number of spaces for each line? If yes, it can be done with regular expressions

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2018 Jan Fiala
Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák