How to add a gap between letters and border of N++ window?
-
I switched off the numeration of lines and margin and grey border of N++ window.
Now I get this layout:
The problem is text is too close to window border:
I want to add 1 mm gap like a standard Notepad app in Windows do:
Please explain, how to add 1 mm gap?
I do not want to turn on margin at all:
-
using the Python Script plugin and the following
editor.setMarginLeft(99)
where 99 is the number of pixels for the left margin, the default is 1 pixel.
-
This post is deleted! -
@Nick-Brown said in How to add a gap between letters and border of N++ window?:
using the Python Script plugin and the following
editor.setMarginLeft(99)
where 99 is the number of pixels for the left margin, the default is 1 pixel.
It does not work for me…
I added editor.setMarginLeft(99) in startup.py
and choosed ATSTARTUP option in confog window:
What do I do wrong?
-
You probably don’t have any margin turned on, so setting a width doesn’t do much for you.
Why not turn on the line-number or bookmark margins?
I have trouble understanding why a small number of people are bothered by how close their text is to a window edge.
-
-
@Дмитрий-Трошин
Border Width doesn’t do anything for what seems to be the OP’s complaint. I’ll show you:
Border Width = 2:
Border Width = 30 (max):
See how the
b
inblah
has nothing like the “1 mm gap” the OP desires with EITHER border width setting? -
@Alan-Kilborn said in How to add a gap between letters and border of N++ window?:
You probably don’t have any margin turned on
Curious, how would one do that? I was under the impression that the
blank margin is always active.@Evgeny-Morozov
Npp knows two editor objects namededitor1
andeditor2
.
editor
points to one of those and is the current one used.
Change your code toeditor1.set... editor2.set...
to be sure that both editor objects are affected. In addition I would recommend not to use the standard startup.py file but to create a user startup.py. Simply by using the PythonScript menu and choose
New script
and name itstartup.py
.Can you check if you see an error in the PythonScript console?
Plugins->PythonScript->Show Console -
https://github.com/notepad-plus-plus/notepad-plus-plus/issues/2323 << closed unnecessarily because the extra space may be important for some. You can ask to reopen.
-
Regarding:
“You probably don’t have any margin turned on”
@Ekopalypse said :
Curious, how would one do that? I was under the impression that the
blank margin is always active.What is this “blank margin”??
So without any plugins that might create additional margins, I think N++ has 3 possible margins:
- Line number
- Bookmark
- Fold (for certain Language types, e.g. Python)
If you have them all turned off, like this (see the red dots):
Then you have a “don’t have any margin turned on” situation – or maybe I’m misunderstanding something?
-
https://www.scintilla.org/ScintillaDoc.html#SCI_SETMARGINLEFT
uses the blank margin to insert space between the border and the text.
Hence the solution provided by @Nick-Brown should work and this
margin is not, as far as I know, related to the other “visible” margins. -
Ah, it is somewhat confusing because it isn’t a real “margin” like the others I called out.
So, apparently it was just that the OP had some sort of problem getting the Pythonscript solution to work.
Maybe should try a NppExec solution? -
Yes, took me some time to figure out that this isn’t one of the other
margins while I was testing it some time ago. :-) -
@Ekopalypse said in How to add a gap between letters and border of N++ window?:
@Alan-Kilborn said in How to add a gap between letters and border of N++ window?:
You probably don’t have any margin turned on
Curious, how would one do that? I was under the impression that the
blank margin is always active.@Evgeny-Morozov
Npp knows two editor objects namededitor1
andeditor2
.
editor
points to one of those and is the current one used.
Change your code toeditor1.set... editor2.set...
to be sure that both editor objects are affected. In addition I would recommend not to use the standard startup.py file but to create a user startup.py. Simply by using the PythonScript menu and choose
New script
and name itstartup.py
.Can you check if you see an error in the PythonScript console?
Plugins->PythonScript->Show ConsoleIt does not work too. :((((
I created user scrypt startup.py.
Here is contents:
I restarted Notepad++
Run scrupt using menu:But there is still no space:
Console is empty
I enter commands manually:
But nothing happens
-
Can you post your debug-info, which is available from ? menu?
-
@Ekopalypse said in How to add a gap between letters and border of N++ window?:
Can you post your debug-info, which is available from ? menu?
Can you please explain there to find that debug info?
-
-
@Ekopalypse said in How to add a gap between letters and border of N++ window?:
Surprisingly it works!
Maybe I have not closed one txt file opened in N++ -
Great that it works - still confused that calling the two methods from the console didn’t work.
So the only other thing is that your user startup.py should only contain the two setMarginLeft… lines. The other stuff will get initialized from the standard startup.py.
-
Hello,@Evgeny-Morozov
Please follow this steps,To How to add a gap between letters and border of N++ window?
Step 1:- Open your file in Notepad++
Step 2:- Press Ctrl+H to open the Replace window.
Step 3:- Change the “Search Mode” to Regular expression.
Step 4:- In the “Find what” box, type (\n|^)
Step 5:- In the “Replace with” box, type \1
Step 6:- Then click “Replace All”Note: If you want tabs instead of spaces, a tab character can be typed with Alt+09
I hope this information will be useful to you.
Thank you.