Adding Vertical Lines

  • I want to be able to, with the click of a mouse, turn on and off vertical lines at every 8 columns for 10 columns.

    That’s all I want to do. However, I can’t find any combination of settings, plugins, or manual configuration editing that will let me do it. I am aware of the following tools to create buttons and turn on lines, but I cannot figure out how to assemble them into a single press of a button or a single keystroke:

    • ExtSettings: It lets me create an arbitrary number of vertical lines wherever and whatever color, but it is tedious to delete and re-create them all every time I want the lines on or off. I could edit the config file with a batch file or a script, but that would then require the restart of Notepad++

    • CustomizeToolbar: It lets me create a custom button, but I am limited to only being able to select existing menu options, so I need a 2nd plugin that will create a menu option I can run, or alternatively, something that I can macro in.

    • LuaScript: This is very, very close to doing what I want, I can create arbitrary vertical lines, but I cannot figure out how to run a script of my choice with the press of a button (i.e., integrate in with CustomizeToolbar). My current workflow is I open the script to hide (or show) the lines, run the script, close the script. Annoying if I’m working in a separate folder.

    • Python Script: This lets me run arbitrary scripts via Macros, and has them selectable as menu options (So I can run them with CustomizeToolbar) but it doesn’t yet support MultiEdgeAddLine(). So this won’t work.

    I would love to just macro it in, but Notepad++'s macro documentation is non-existent, I’m reduced to attempting to reverse engineer it by manually editing the shortcuts.xml file in %APPDATA%\Roaming\Notepad++. I feel like the code below should create a grey vertical line at column 12, based on Scintilla’s documentation but without NPP’s documentation I’m clueless. I have also tried it with Action Type = 1,2,3, swapping wParam and lParam, etc., etc.

            <Macro name="AddVerticalLine" Ctrl="no" Alt="no" Shift="no" Key="0">
                <Action type="0" message="2363" wParam="3" lParam="0" sParam="" />
                <Action type="0" message="2694" wParam="12" lParam="0xAAAAAA" sParam="" />

    What I’m asking from the community:

    • A way to assemble any set of plugins to let me press a button, OR
    • Some way for me to directly pass code into Scintilla, OR
    • Some documentation for macros.

    Thank you very much!

  • @Charles-Bogel said in Adding Vertical Lines:

    Notepad++'s macro documentation is non-existent

    What I’m asking from the community:

    A way to assemble any set of plugins to let me press a button, OR
    Some way for me to directly pass code into Scintilla, OR
    Some documentation for macros.

    For about 4-5 years, the Notepad++ documentation was frozen; however, with the new, that has changed, and there is a team actively working on the new documentation. It’s actually back to a fairly reasonable stage, and most major features have a reasonable level of documentation, IMO.

    For macros, the overview, which explains how to record, save, and playback macros (which is the primary intended interface for the macro feature), is at . Beyond that, the newer Configuration Files Details documentation has a section on the details of the shortcuts.xml and the <Macro> section at . Admittedly, there is no link between the main macro page and the appropriate Config Files Details section. (I have added documentation issue#60 to remind me to make that link when I have time in the next couple of days.)

    That section of the document has a lot on the difference between type=0, 1, 2, and 3. It also includes links to the appropriate sections of Notepad++ and Scintilla documentation and code for looking up the correct message numbers.

    Further documents: Extending Functionality WIth Plugins describes how to get started on writing a plugin yourself, and Plugin Communication describes the Notepad++ messaging system.

    If you ever find that the released documentation is missing something, look at the github for the documentation, which will have the most recent versions of the docs (sometimes including updates that haven’t been released to the official website yet). If what you’re looking for is not there, browse the open issues, and if someone else hasn’t already reported it, then open a new issue.

    Back to your problem:
    Looking at your macro, I agree that you are calling the Scintilla messages for SCI_SETEDGEMODE (2363) and SCI_MULTIEDGEADDLINE (2694). My first guess for your problem is that you’re passing lParam="0xAAAAAA", which might not be translated to a number between the XML and when the message gets sent. I tried implementing that macro, but with lParam=“11184810” (which is the decimal equivalent of 0xAAAAAA, but it still didn’t work.

    If PythonScript is missing a message that you want, you could always make a request at the PythonScript github issues. And since you have the full power of Python, you should be able to find the library where you can get direct access to the Win32 API’s SendMessage function in Python; with that, and the scintilla HWNDs – which you can either get from a PythonScript command (I don’t remember for sure if there’s a wrapper for those), or you can enumerate windows to find them – search EnumWindow in the forum for examples of that)

    For passing raw messages to and from Notepad++ and Scintilla, the easiest right now is using the NppExec plugin, which has npp_sendmsg and sci_sendmsg commands, and can handle return value (which the macro feature cannot). Like Macros, or PythonScript, NppExec commands can be bound to keystrokes and can be configured to go into menus that should be accessible from CustomizeToolbar.
    Unfortunately, even using

    sci_sendmsg 2363 3 0
    sci_sendmsg 2694 12 11184810

    I didn’t see any vertical line get added. I also tried the single vertical bar with

    sci_sendmsg 2361 40 0
    sci_sendmsg 2365 65535

    but that did nothing as well.

    Sorry, I cannot immediately solve your problem for you.

    Oh, re-reading, I see you had it almost working in LuaScript. Could you post that code? One of the LuaScript experts might even be able to tell you how to put it into a menu (because it would really surprise me if the menu-config features of NppExec and PythonScript were not re-created when LuaScript was made).

  • From reading the OP’s posting, the problem seems to be in tying a toolbar button to running a LuaScript. I’m no expert, but it seems that any time CustomizeToolbar questions come up, the end result is that that plugin is “lacking”. Doesn’t tying a keycombo to the running of the LuaScript work just as well for this?

  • @Charles-Bogel

    I’m the author of the ExtSettings plugin. You can configure a set of vertical lines using my plugin. Then you need a scripting plugin (e.g. NppExec, LuaScript or PythonScript) to be able to send an event to the Scintilla component of the active view to toggle visibility of this set of lines.

    The following example is for the NppExec plugin:

    To turn on vertical lines: sci_sendmsg 2363 3
    To turn off vertical lines: sci_sendmsg 2363 1

    You can store the above commands to NppExec scripts. The plugin provides the ability to create menu entries for these scripts in the Macro menu. Via Shortcut Mapper you can configure keyboard shortcuts to execute them.

  • PeterJones, thank you so much for the working documentation links about the macros! All the links I had seen before were broken, so I assumed the whole site was dead. Seriously, thank you for all the context, this is great. It’ll take me a bit to dig through but I may be able to get something working from that. I was considering writing my own darn plugin, but I was hoping that is overkill for this use case.

    Working LuaScript code:

    editor.EdgeMode = EDGE_MULTILINE
    for i=1,10 do
    	editor:MultiEdgeAddLine(i*8, 0xBBBBBB)

    And then I just manually change the color to 0xFFFFFF and re-run it to clear the lines. The current reason I can’t use it as a one-button solution is that the menu options presented to me are either run code from the console (so I would need a macro method of putting arbitrary text in the console which I haven’t been able to determine) or run it from the current file (which requires a macro method of loading a specific file which I haven’t been able to get working with any sort of consistency).

    Dinkumoil, thank you for your ExtSettings Plugin! I was really excited when I found it, but then didn’t think about using other scripts to interface with it directly. I think your solution with the added hotkeys will work overall, I am implementing it now.

    This board is fantastic, thank you all for the high quality replies!

  • @Charles-Bogel

    the command sci_sendmsg 2363 1 activates the standard mode of Notepad++, one single line at an arbitrary column (configurable via Preferences dialog). If you want no lines at all change the command to sci_sendmsg 2363 0.

  • For future people reading this thread, here’s a complete tutorial of how to add a set of vertical lines and turn it on/off with a click. I’m sure there’s a cleaner/better way, but at least anyone else trying to work with NASTRAN or other fixed-width files will have something to work with.

    To create the lines, you will need to:

    • Update to Notepad++ 7.8 or greater (you will likely have to update, it’s a relatively new feature)
    • Install some plugins to Notepad
      • Plugins -> Plugins Admin
      • Select Check Boxes next to Customize Toolbar, ExtSettings, and NPPExec
      • Click Install
      • Click Yes to restart Notepad++ and Yes to accept changes to machine.
    • Add vertical lines via ExtSettings
      • Plugins -> ExtSettings -> Extended Settings
      • In the bottom left, select a color
        • Click on the black color box
        • Put in 220 for Red, Green, and Blue (or whatever color you want your lines to be; this makes them a light grey)
        • Click OK
        • If you do not do this step you will not be able to create lines
      • Enter 8 for column
      • Click Add
      • Enter 16 for column
      • Click Add
      • Continue for 24, 32, 40, 48, 56, 64, 72, 80.
      • Click Close to save the ExtSettings
      • You should now have your vertical lines!

    You can stop here if you want, but the lines will be on at all times until you delete them in the same menu as above. Let’s add the ability to turn them on and off:

    • Add the ability to turn on and off lines via NppExec
      • Plugins -> NppExec -> Execute…
      • Copy the following text into the box:
    sci_sendmsg 2363 3
      • Click Save…
      • Enter LinesOn in the prompt
      • Click Save
      • Delete all the contents in the Execute… box
      • Copy the following text into the box (Yes, it’s different, don’t save the same thing):
    sci_sendmsg 2363 1
      • Click Save…
      • Enter LinesOff in the prompt
      • Click Save
      • Close the Execute… box
      • Plugins -> NppExec -> Advanced Options…
      • In the bottom left, under “Menu Item”, enter LinesOn
      • In the “Associated Script” dropdown, select “LinesOn” script
      • Click Add/Modify
      • In the bottom left, under “Menu Item”, enter LinesOff
      • In the “Associated Script” dropdown, select “LinesOff” script
      • Click Add/Modify
      • In the top left, check the box next to “Place to the Macros submenu”
      • Click OK, OK
      • Restart Notepad++
        • This lets the new options you added in get selected as a menu item
    • Create Buttons to turn the lines on and off
      • Plugins -> Customize Toolbar -> Custom Buttons
      • Restart Notepad++
        • This enables the new buttons. See the hammer icon in the far right of the toolbar? That wasn’t there before.
      • Open the file “C:\Users\YOUR_NAME_HERE\AppData\Roaming\Notepad++\plugins\config\CustomizeToolbar.btn”
      • Delete all the contents and replace it with the following 2 lines:
      • Save the file
      • Restart Notepad++ (Last time)
      • Click your new LinesOn and LinesOff buttons! They are the hammer icons on the far right.
      • When you click LinesOff, if you had already chosen a vertical line at some via the normal Notepad++ menu, it will still be visible.

  • @Charles-Bogel said in Adding Vertical Lines:

    For future people reading this thread, here’s a complete tutorial of how to […]

    Absolutely awesome! ++ thanks for taking the time to share this tutorial.


  • Just for completeness, latest pythonscript version does support the
    newest scintilla features.


  • @Charles-Bogel

    You can assign unique icons to your toolbar buttons as well. The icons have to be in a 8 bits per pixel, 256 colors palletized BMP format with a size of 16 x16 pixels.

    You can create such files by opening the icon of your choice in *.ico, *.bmp or *.png format with MS Paint, included in every version of Windows. Save them to a new file and select 256 colors bitmap as output format. Save them to e.g. %AppData%\Notepad++\plugins\config\CustomToolbarIcons.

    In the file %AppData%\Notepad++\plugins\config\CustomizeToolbar.btn change the lines you mentioned above to:


    For future readers on a non-english version of Notepad++: The part Macro,LinesOn and Macro,LinesOff describe the “path” through the main menu to the menu items you would have to click to execute the related function. The names of these items have to be localized, i.e. they have to be noted in the language of your user interface.

  • @PeterJones said in Adding Vertical Lines:

    Unfortunately, even using

    sci_sendmsg 2363 3 0
    sci_sendmsg 2694 12 11184810

    I didn’t see any vertical line get added

    I don’t know what I was doing wrong (or maybe the color wasn’t showing up right on my remote-monitor), but now when I run those, it does work as expected.