Place cursor in center of displayed text when Goto line number.
-
Notepad++ v8.6.2 (64-bit)
Build time : Jan 14 2024 - 02:16:00
Admin mode : OFF
Local Conf mode : ON
Cloud Config : OFF
OS Name : Windows 10 Pro (64-bit)
OS Version : 22H2
OS Build : 19045.4291
Current ANSI codepage : 1252
Plugins :
AutoSave (1.6.1)
mimeTools (3)
NppConverter (4.5)
NppExport (0.4)
NppSnippets (1.6)(I think the forum did not like my Windows path info and said “You need at least 1 reputation to post links”. So I removed that info from the NPP debug info above.)
When I hit ^G to go to a line in Notepad++, the cursor eithers goes to the top of the window, or bottom of the window, depending on which direction the cursor has to travel. Is there a way to put the cursor about 5 lines from the top of the NPP window when doing a Goto Line?
Thank you.
-
@C-Bacca said in Place cursor in center of displayed text when Goto line number.:
Is there a way to put the cursor about 5 lines from the top of the NPP window when doing a Goto Line?
Not natively.
If you are going to a line near the top of the file, you could do
Ctrl+Home
then Goto Line. Or if you’re going to a line near the bottom,Ctrl+End
before Goto Line. For one in the middle, you could Goto Line then use the mouse scrollwheel orCtrl+Arrow
to quickly scroll that line to the middle. (Settings > Preferences > Editing 1 >☑ Enable scrolling beyond last line
will help if you want to be able to center it with scrollwheel, even if you go to the last line.)If that’s not sufficient, it could be coded up in the PythonScript Plugin or similar scripting plugin, and then assign that script a keyboard shortcut to use – and you could then run that script instead of Goto Line. It’s not that difficult to do a “goto” then try to center it in PythonScript syntax; if you need help to do such a script, let us know (though we aren’t a code-writing service, so you’ll be expected to take an active role).