Need the ability to have fixed-width line number column
-
@Alan-Kilborn said in Need the ability to have fixed-width line number column:
even @dinkumoil 's ExtSettings plugin
My original thought … but looking at the question more could it be @thompsop is blurring the lines between data and presentation? If you have text that are to be in columns, then wouldn’t a Excel spreadsheet or comma separated values (CSV) file format be best? Then to present the data in a nice readable format, you use a script to “present” it?
Notepad++ does fine with CSV files (as they’re just plain text) and with the CSV Query plugin.
Cheers.
-
@Michael-Vincent said in Need the ability to have fixed-width line number column:
blurring the lines between data and presentation?
Sometimes it is tough to know when to nudge a poster to a different solution than the one they have. Sometimes gauging their technical expertise (from the nature of their question and their writing) helps. The OP in this case seemed to know where they were heading and had a very specific question, which I tried to help on.
-
@Alan-Kilborn said in Need the ability to have fixed-width line number column:
The OP in this case seemed to know where they were heading and had a very specific question, which I tried to help on
Agree - and I like your suggestion - as I said it was the first thing I thought of (Scintilla multiedge) implemented well in ExtSettings.
Sometimes I read a bit into things and think this could be an XY problem - like “how do I make Notepad++ behave like a column-based spreadsheet application”?
:-)
Cheers.
-
@Michael-Vincent said in Need the ability to have fixed-width line number column:
Scintilla multiedge) implemented well in ExtSettings.
I was actually thinking that maybe ExtSettings could change the width of the line number margin, but it doesn’t appear that it can do that. But, your hint about “multiedge” might be a better solution for the OP anyway; multiple edges in the same color would be in the same columns in each view, so even if they didn’t exactly line up, the (mental) color sync-up potential could aid.
-
@Alan-Kilborn said in Need the ability to have fixed-width line number column:
change the width of the line number margin
(face palm). I may have been thinking about this all wrong. If all we’re trying to do is make the Notepad++ line number margin a different width that’s easy (he says until he actually tries it).
Using NppExec:
SCI_SENDMSG SCI_GETMARGINWIDTHN 0 ================ READY ================ ECHO $(MSG_RESULT) 32
So the width of the Notepad++ line number margin is 32. Let’s just change it:
SCI_SENDMSG SCI_SETMARGINWIDTHN 0 100 ================ READY ================ SCI_SENDMSG SCI_GETMARGINWIDTHN 0 ================ READY ================ ECHO $(MSG_RESULT) 32
Wait, what? I set it to 100 and it visibly didn’t change and querying it, it’s still 32. Let’s try margin 1, the bookmark margin:
SCI_SENDMSG SCI_GETMARGINWIDTHN 1 ================ READY ================ ECHO $(MSG_RESULT) 16 ================ READY ================ SCI_SENDMSG SCI_SETMARGINWIDTHN 1 100 ================ READY ================ SCI_SENDMSG SCI_GETMARGINWIDTHN 1 ================ READY ================ ECHO $(MSG_RESULT) 100
Yep, that worked and i can visibly see the margin is huge. I there some magic hocus pocus that is preventing resizing of the Notepad++ line number margin (margin 0)?
Cheers.
-
@Michael-Vincent said in Need the ability to have fixed-width line number column:
Hmmm, worked for me! :
-
@Michael-Vincent
NOTE: when I page way down to line 100,000, and query, the margin 0 returns a result of 56:ECHO $(CURRENT_LINE) 129600 ================ READY ================ SCI_SENDMSG SCI_GETMARGINWIDTHN 0 ================ READY ================ echo $(MSG_RESULT) 56
So it is “dynamically” resizing as needed as we can see from OP and as I think we’ve all probably noticed. It would be nice to be able to “force” it to a fixed size wide enough to accommodate all line numbers in a given file (if we know the length).
Cheers.
-
@Alan-Kilborn said in Need the ability to have fixed-width line number column:
Hmmm, worked for me! :
Outstanding! It may be a plugin I have that is causing issue? I have quite a few and some that muck with margins (like Changed Lines).
Cheers.
-
@Michael-Vincent said in Need the ability to have fixed-width line number column:
may be a plugin I have that is causing issue
Weird - I just tried on portable N++ 7.8.3 64-bit with only NppExec (no other plugins) and it didn’t work for me - same results as I posted above. I also tried with N++ 7.7.1 32-bit with lots of plugins and same behavior. I didn’t bother getting 7.8.3 32-bit for apples to apples - this isn’t much of an issue for me, but interesting that yours works and mine doesn’t.
As I said:
DEBUG INFO
Notepad++ v7.8.3 (64-bit)
Build time : Jan 12 2020 - 19:09:49
Path : C:\usr\bin\npp64\notepad++.exe
Admin mode : OFF
Local Conf mode : ON
OS Name : Windows 10 Enterprise (64-bit)
OS Version : 1809
OS Build : 17763.1098
Plugins : AutoSave.dll BetterMultiSelection.dll ChangedLines.dll CodeAlignmentNpp.dll ColumnTools.dll ComparePlugin.dll CsvQuery.dll DoxyIt.dll DSpellCheck.dll Explorer.dll GitSCM.dll HexEditor.dll JSMinNPP.dll MarkdownViewerPlusPlus.dll NppConsole.dll nppConverter.dll NppExec.dll NppExport.dll NppFTP.dll NppMenuSearch.dll Perl Indent.dll PluginManager.dll PreviewHTML.dll Python Indent.dll QuickText.dll SpeechPlugin.dll SurroundSelection.dll TagLEET.dll TagsView.dll XMLTools.dll ZoomDisabler.dll(lot’s of plugins …)
but I did try a “clean” version with same non-working results:
Notepad++ v7.8.3 (64-bit)
Build time : Jan 12 2020 - 19:09:49
Path : C:\Users\vinsworldcom\tmp\npp64\notepad++.exe
Admin mode : OFF
Local Conf mode : ON
OS Name : Windows 10 Enterprise (64-bit)
OS Version : 1809
OS Build : 17763.1098
Plugins : NppExec.dllCheers.
-
…and I’m sitting here now annoyed by a wide margin and thinking I should change it back. :-)
Since you showed me yours I’ll show you mine:
Notepad++ v7.8.5 (32-bit)
Path : …\notepad++.exe
Admin mode : OFF
Local Conf mode : ON
OS Name : Windows 10 Enterprise (64-bit)
OS Version : 1809
OS Build : 17763.1039
Plugins : BetterMultiSelection.dll ColumnTools.dll Explorer.dll linefilter2.dll LocationNavigate.dll MarkdownViewerPlusPlus.dll mimeTools.dll NppConverter.dll NppEditorConfig.dll NppExec.dll NppExport.dll NppMenuSearch.dll NppToolBucket.dll PythonScript.dll XMLTools.dll -
@Alan-Kilborn
Hmm, very similar except for the 32 vs 64 bit and you’re latest 7.8.5. Many similar plugins and I see you have LocationNaviagte which mucks with margins as does my Changed Lines (based on LocationNav).I’m probably not going to pursue why this doesn’t work me, but thanks for your help.
Incidentally, the default is 32 at “line 1” so presumably you’d be able to:
SCI_SENDMSG SCI_SETMARGINWIDTHN 0 32
and all should be well. Although it’d be interesting to see if that would force yours to 32 and when you scroll to larger line numbers, would the margin auto-expand as it should?
Cheers.
-
Hi, @thompsop, @alan-kilborn, @michael-vincent and All,
May be I’m missing something obvious, but why not simply disable the line number margin, by UN-ticking the option
Settings > Preferences > Editing > Display line number
?Best Regards,
guy038
P.S. :
@michael-vincent, in your Wikipedia link to the
XY problem
, I particularly like this example :Gene Woolsey described a famous example of solving the wrong problem. Management was concerned about complaints that people had to wait too long for elevators, and so spent a lot of time and money researching how to schedule elevators to reduce the wait times.
Woolsey pointed out that they were trying to solve the wrong problem. The real problem was that “people were complaining”. The installation of large mirrors in the lobby gave people something to do, and the complaints were drastically reduced !!! -
@guy038 said in Need the ability to have fixed-width line number column:
Wikipedia link to the XY problem
I got that link from Perl Monks where I used to spend a lot of time and that sort of thing came up with many questions it was documented in a node.
Cheers.
-
Hmmm, well here I go with a big facepalm of my own. You know how sometimes you do something a long time ago, and forget about it?
Well, apparently I run with line numbers disabled in the Preferences, and then I do this in my Pythonscript startup:
for e in (editor1, editor2): e.setMarginWidthN(0, e.textWidth(STYLESCOMMON.LINENUMBER, "_999999"))
This gives me a wider margin for the line numbers, right out of the box.
By turning off Notepad++'s control of the line numbers, I don’t see the behavior that you do, specifically, that Notepad++ is constantly resetting it.
This also allows me to deduce that if Notepad++'s control of line numbers is disabled, Notepad++ sets the margin for the numbers to have zero width ONCE and then leaves it alone.
Big sorry for the confusion on this. Sheepish grin.
Additional reference: https://community.notepad-plus-plus.org/topic/17907/adding-leading-zeros-or-additional-leading-space-for-line-numbers
-
@guy038 said in Need the ability to have fixed-width line number column:
May be I’m missing something obvious, but why not simply disable the line number margin
Well, because it is too valuable to disable. :-)
I joined a new group at work, and was stunned to find that nobody has line-numbers turned on in the Visual Studio we use.
When I asked why, I was met with “meh” and “that’s the Visual Studio default” (meaning line numbers off).
Of course I couldn’t take it that way for very long, so I turned line numbers on in my Visual Studio.So many people just use the default settings in the programs they use. Sad.
-
@Alan-Kilborn said in Need the ability to have fixed-width line number column:
Well, apparently I run with line numbers disabled in the Preferences, and then I do this in my Pythonscript startup:
THAT’S AWESOME! And for us Python impared:
“PerlScript”:
for $e (editor1, editor2) { $e->setMarginWidthN(0, editor->textWidth($SC_STYLE{STYLE_LINENUMBER}, "_999999")); }
Cheers.
-
@Michael-Vincent said in Need the ability to have fixed-width line number column:
(Scintilla multiedge)
You mentioned “multiedge” briefly above; I agree that this could definitely help the OP. And, it appears a native multiedge capability is coming soon to Notepad++ !
See https://github.com/notepad-plus-plus/notepad-plus-plus/pull/8107 and :