Add space at left of text?
Anderwriter last edited by
NP++ is great. Unlike most text editors I’ve used, it starts the text right up against the left border (window edge). Is there a way to add a bit of space there? Maybe it’s just me, but that would make my text easier to read.
If this can’t currently be done, will you consider adding it as an option, like how you can specify NP++'s border and cursor widths?
And BTW, is it normal for the edit box to scroll off the bottom of the page here, so you can see only a few lines of the text you’re entering? Maybe most of you compose your posts in NP++ and paste them in here (that’s what I’m doing, so I can see it!). But still. It hides the Preview text as well, so I can’t see the point of that either.
Mikhail V last edited by
Unlike most text editors I’ve used, it starts the text right up against the left border (window edge).
Not really, I believe most Npp users at least have line numbers on,
so it is not right from the left border ;-) See “Settings -> Preferences -> Editing”.
As for other text editors - I think it is very different. MS Notepad for example does not have any margins and no options at all.
Is there a way to add a bit of space there? Maybe it’s just me, but that would make my text easier to read.
It is not just you – solid margin makes it much easier to read, but many editors
completely ignore this UX aspect (luckily, Npp is not such a software).
So how can it be adjusted? Well, it is not that obvious actually and this question comes
up regularly (I think maybe we need a FAQ section for such things).
There are settings for this (and many more settings) - though they cannot be accessed via GUI settings.
The question is, (and its a general question) how to access internal command/settings.
There are few ways, like defining macros, or using specific plugins.
For this task, I personally use the Pythonscript plugin.
After installing the plugin, restart Npp, and there will be a menu setting you must check:
open menu “Plugins-> Python Script -> Configuration”.
At the bottom there is “Initialisation” box, choose “ATSTARTUP” there.
And there is a script called “startup.py” - this script will be auto-executed each time Npp restarts.
To edit this script, go to "Plugins-> Python Script -> Scripts -> " and Ctrl-click the “startup.py” item.
Now simply add these 3 lines at the bottom of the file and save the file.
editor.setMarginWidthN (0, 76) # line numbers margin
editor.setMarginWidthN (1, 16) # bookmark margin
editor.setMarginWidthN (3, 46) # left margin
NOTE: to make these settings work, you must first disable margins in the GUI settings: goto “Settings -> Preferences -> Editing”.
Un-check “display line number” and “display bookmark”
(otherwise there will be conflicts)
Now run the script (by clicking it “Plugins-> Python Script -> Scripts -> startup.py”)
You should see margins changed.
In the above commands, second number in brackets is the pixel-width for each type of
margin. Experiment with these widths to get the comfortable look.
The color can be changed in “Settings -> Style configurator”.
Choose “global styles” on the left, then “Line number margin” in second column,
and click “Background color” to change the color.
And BTW, is it normal for the edit box to scroll off the bottom of the page here, so you can see only a few lines of the text you’re entering? Maybe most of you compose your posts in NP++ and paste them in here
Not sure what was the problem, but I think it is always good idea to edit posts
in some editor first and then paste it, not only here but in any web-forms.
dail last edited by dail
A better way would be the call to setMarginLeft() which does not mess with any of the actual margins and will not interfere with Notepad++'s settings at all.
guy038 last edited by guy038
@anderwriter, @mikhail-v, @dail and All,
Just tried, Dail and it’s working nice !, But you just forgot your own excellent Lua plugin ;-))
So, once the Lua plugin installed, just use these commands to change left and/or right margins :
editor.MarginLeft = WidthInPixels
editor.MarginRight = WidthInPixels
And to know the current value of margins, simply type :
and hit the
Enterkey or click on the
Remark : The default Scintilla value, for the two margins, is
1pixel wide, but value
0is allowed, too !