Marking And Highlighting shortcut

  • Is it possible to create my own shortcuts for Marking And or Highlighting any text with any style or just as standard style 1. By pressing the same should Clear it.
    Or Notepad++ can add it as standard of its own because they know what shortcuts are free.

  • @Harpreet-Singh-Bassan

    By pressing the same should Clear it

    If this requirement needs to be fulfilled, then no, not with builtin features.

    Otherwise use shortcut mapper and style configurator.


  • I would like this request to be fulfilled please. I use it for programming Galil servo controllers instead of using their editor. It will be very handy to add these marking and highlighting feature with shortcut.

  • @Harpreet-Singh-Bassan

    to get this solved now, I would recommend to use plugins like python/lua script to do it.
    Maybe someday npp supports it natively.


  • O man. Thanks for some solutions at this time. BBBut both these two languages are the one I never have tried. Are there any example codes on line which I can just change little bit and do it. The latest one i have tried is Java but that too i am not as good. Or do you mind ----- please thro some codes here. Actually this will also the first time I will use any script in Notepad++. So how will I run script in Notepad++ . That will be a great help.

  • @Harpreet-Singh-Bassan

    what languages do you prefer?
    There are other possible solutions like c# …

    For python you need to install the python script plugin.
    I would propose to use the MSI package instead of using the plugin manager.

    First steps are described here .

    An example script would be

    import re                                                                           # needed to find whole words only
    editor.indicSetStyle(13,INDICATORSTYLE.STRAIGHTBOX)                                 # used to color selected text
    editor.indicSetFore(13,(255,0,0))                                                   # the color in RGB color syntax           
    editor.indicSetAlpha(13,155)                                                        # alpha settings
    editor.indicSetOutlineAlpha(13,255)                                                 # outlining
    editor.indicSetUnder(13,True)                                                       # draw under the text
    # -----------------------------------------------------------------------------      
    _g = globals()                                                                      # global variable used to check status
    if not _g.get('CUSTOM_STYLER_IS_RUNNING'):                                          # if variable not defined yet,
        CUSTOM_STYLER_IS_RUNNING = False                                                # set it to False (=NOT RUNNING)
    # -----------------------------------------------------------------------------      
    def clear_indicators():                                                             # used to clear coloring
        text_end_position = editor.getLength()                                          # determine document length
        editor.setIndicatorCurrent(13)                                                  # set defined indicator
        editor.indicatorClearRange(0, text_end_position)                                # and clear it from whole document.
    # -----------------------------------------------------------------------------      
    def colorize(text):                                                                 # used to color the selected chars
        matches = []                                                                    # create empty list of matches
        editor.research('\\b{0}\\b'.format(text), lambda m: matches.append(m.span(0)))  # find selected chars and append it to match list
        for match in matches:                                                           # for each match found
            editor.setIndicatorCurrent(13)                                              # set the defined indicator and
            editor.indicatorFillRange(match[0], match[1] - match[0])                    # color it.
    # -----------------------------------------------------------------------------      
    def main():                                                                         # main function to handle start/stop behavior
        global CUSTOM_STYLER_IS_RUNNING                                                 # assining to global variable
        if CUSTOM_STYLER_IS_RUNNING:                                                    # if script is currently running
            clear_indicators()                                                          # clear all inidcators and
            CUSTOM_STYLER_IS_RUNNING = False                                            # set flag to False
        else:                                                                           # else
            selected_text = editor.getSelText()                                         # get selected text
            if len(selected_text) > 0 and selected_text.isspace() == False:             # if there is at least on char selected
                CUSTOM_STYLER_IS_RUNNING = True                                         # set the flag to true and
                colorize(selected_text)                                                 # color the selection.
    # ----------------------------------------------------------------------------- 
    main()                                                                              # entry point 

    Other python scripts can be found here or in this forum.


  • Thanks Claudia. I use only cnc, plc, hmi, servo system programming the most. Other languages like C and visual basic are history for me. Java being new I still will prefer that. I use Eclipse for it. Any code help will be appreciated as otherwise I always try to work around.

  • Sorry, I’m not aware that there is an java automation plugin available.
    So, maybe you wanna give the python example a try?


Log in to reply