Discussion:
[Notepad-plus-plus] [notepad-plus - Open Discussion] Shift selected text right/left X # of spaces
SourceForge.net
2007-05-16 18:42:13 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4316076
By: bruce_tj

Hello all,

Can anyone tell me of a to shift the text on a line or lines X number of characters
right or left? I often copy text from other applications into NP++. Then I
use the word wrap feature to limit the line length of each line in the selected
text, using a line length I have copied to the clipboard.

At that point I usually save the file and then run a macro I created to open
the same file in another text editor, SPFPC, which is based on the mainframe
ISPF editor. Within the editor I shift the text over 10, 15, or any length
I decide, spaces. I then change the first character in every line into a comment
character.

I haven't found any way to do all this in NP++. Is anyone aware of anyway that
I can perform the same actions without leaving NP++?

Thanks
Bruce



______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=331753
SourceForge.net
2007-05-16 21:13:08 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4316423
By: nobody

You mean
you want
this?

to be

// You mean
// you want
// this?

Try CTRL+R with RexExp checked. Select the "Start of Line" character in the
RegExp dropdown box.

Enter the desired prefix in the Replace field and get going.


______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=331753
SourceForge.net
2007-05-16 21:22:00 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4316429
By: nobody

It turns out you can't simply search for a Line Start and Insert the desired
text at the start of the line. This is because the RegExp has no text selected.
Could this be improved, please?

The other way to use CTRL+R:

Position the cursor at the end of the line.
Hold down the SHIFT button to select text, press Right Arrow key to jump to
the start of the next line.
Now type CTRL+R to replace each End-Of-Line by adding the text to appear at
the front of each next line.
Type CTRL+C rightaway to copy the End-Of-Line character and paste it into the
Replace field.
Move to the Replace field, type CTRL+A to select all text and type CTRL+V to
replace any present text by only the EOL character.
Type any text you want to appear at the start of each line.

Uncheck Regular Expr.
Uncheck Selection.

Get going: Find and Replace.

You may have to insert the desired text manually on the first line of the file.


______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=331753
SourceForge.net
2007-05-17 01:54:01 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4316614
By: bullock

If I understand correctly, you should be able to do this by selecting the lines,
then pressing <Tab> a few times followed by <Ctr-Q> (that is, Edit: Insert
TAB followed by Edit: Block Comment).

What am I missing?

Regards.
Greg


______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=331753
SourceForge.net
2007-05-17 20:34:40 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4318283
By: bullock

Bruce,

In Preferences: MISC, check the box "Replace by space" in the Tab Setting section.
Also, you'll want to set the Tab Size to the least common factor of the various
number of spaces you'll need to insert. (For example, if you're always inserting,
5, 10, 15, or 20 spaces, then 5 would be a good choice). If necessary, set
Tab Size to just 1 -- even then it will still save you time, I should think.
I leave the "Replace by space" box checked all the time, since I'm often sharing
files with others who have different Tab Size settings, so the left margin gets
pretty ragged when the tabs & spaces get mixed. Note that "Replace by space"
affects, I believe, only newly inserted text, not the existing text in the file,
so it should be pretty safe for you.

After that, select the lines, then press <Tab> as many times as needed followed
by <Ctr-Q> (that is, Edit: Insert TAB followed by Edit: Block Comment). If
the language used to display your files doesn't use the kinds of comments you
prefer, then you can use one of the TextFX options, TextFX: TextFX Edit: Fill
Down Insert (or Fill Down Overwrite or Insert (Clipboard) through lines) to
fill the selected block with your preferred comment style.

Regards.
Greg


______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=331753
SourceForge.net
2007-05-17 17:52:32 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4317676
By: bruce_tj

Greg,

I want to insert spaces rather than tabs because ultimately the text will be
copied into another source code editor, SAP's ABAP editor.

I want to change text from:

1---------------------1
2---------------------2
3---------------------3

to:

*
* 1---------------------1
* 2---------------------2
* 3---------------------3

Currently I execute these steps in 15 + seconds using both editors.

1. save file in NP++
2. run macro to open saved file in SPF/SE application
3. shift all line right X spaces (10 spaces in this example). Spacing varies
from 5 to 20 depending on what convention a specific developer was using when
they first documented the original program.
4. change ' ' to '*' in position 1 in all lines, save file and exit back to
NP++

(step 3 takes as much time as all the other steps combined)
(steps 4 is executed by a PFkey in 1 step)

Thanks
Bruce

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=331753
SourceForge.net
2007-05-18 01:26:28 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4318524
By: nobody

Hi,
I'm not sure I've understood the whole idea but maybe this could help:

1. Press Ctrl+H (Replace window)
2. Check "Regular Expression"
3. In "Find" write: '^(.)'
4. In "Replace" write: '* \1'
5. Hit "Replace All"

The only thing is that you would need to enter the amount of spaces you want
between with asterisk ('*') and the reference ('\1'); for instance, to shift
the text 10 spaces (assuming it will result in the asterisk and then 9 spaces):
- Find: '^(.)'
- Replace: '* \1'
Note: Remove single quotes around the Find/Replace texts

Ralph

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=331753
SourceForge.net
2007-05-18 16:50:51 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4319599
By: bruce_tj

Ralph,

Your suggestion does what I want, with one exception. The first character of
every line is removed.
1----------1
becomes
* ----------1
I want
* 1----------1

Where is this syntax for expressions explained?

Thanks
Bruce


______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=331753
SourceForge.net
2007-05-18 17:14:45 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4319631
By: bullock

Bruce,

You may want to consider another suggestion I posted above. Although it was
in response to the more detailed description you gave in replying to my first
message, it somehow ended up listed before your message.

Regards.
Greg

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=331753
SourceForge.net
2007-05-18 18:50:55 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4319725
By: bruce_tj

Greg,

Thanks for the Tab setting suggestion. That helped me get to my desired
solution.

Bruce

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=331753
SourceForge.net
2007-05-19 03:11:14 UTC
Permalink
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=4320108
By: nobody

Hi Bruce,
it seems you already solved this issue, but just as a note, I think the problem
was removing either the back-slash before the one, or both of them. Read below
to know why.

First, I have the latest version of Notepad++ (that being 4.1.1), I tested it
and it seems to work fine.

We are using Regular Expressions here, the POSIX family it seems, you can find
a lot of places with information about these, but since it can be a little (or
a lot) complex I'll try to clarify what it does.
Find: '^(.)'
Replace (with): '* \1'
(remove single-quotes, check "Regular expression" option) it's telling NP++
to look for any character (the dot) "at the beginning of the line" (that's what
the "^" means), and also asking it to "remember" this character (the parenthesis)
--to be used on the replace expression.

Now, on the replace string we're telling NP++ to write '* ' (an asterisk and
a space) followed by the character it found at the beginning of the line (the
one we asked it to "remember" --that's what the '\1' means), hence "inserting"
an asterisk and a space at the beginning of any non-empty line.

The number following the back-slash refers to the "group" (what's inside the
parenthesis), in the order they appeared in the expression (0 typically meaning
"the whole match"), since we only have one group we can only use "1" (the first),
hence the '\1'.

Hope this helps.
Ralph.

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=331753

Continue reading on narkive:
Loading...