Kind of autocomplete?



  • Hi, I started to use notepad++ yesterday and i am looking for an option which does this

    For example when I am writing style for an html code

    <style>

    .first-paragraph{

    color:(I want from notepadd++ to show me every color option that i can write or at least main colors like blue,red,magenta etc.)
    also I want the same thin for every style.
    }
    </style>

    or for example <img src="(when I start to write something, i want notepad check the folder that i am in and show me the full name like I write ea and it show me earth.png)">

    are those possible in notepad++ or do i need a different program for that?

    Thanks in advance. Gokalp



  • @Gökalp-Gürsel

    or do i need a different program for that?

    well it depends on what you expect. Npp can be configured/modified
    to be a good (maybe even better) html editor but there is a need to put in some work first.
    Npp has a builtin concept of auto-completion but this more static than dynamic.
    There are xml files (API files), available under …\plugins\APIs directory, which can be modified to your needs.
    In addition you can load plugins which can be helpful or you write your own extensions
    either as dlls or by using a scripting plugin like python script or lua script.

    It isn’t that complicated, a script, simple example, like this

    import os
    
    file_list = ''
    color_list = "Blue:RED:green:yEllow:dark purple"
    
    color_trigger = ord(':')
    color_indic = 'color:'
    image_trigger = ord('"')
    image_indic = '<img src="'
    
    CAC_IS_RUNNING = globals().get('CAC_IS_RUNNING', False)  
       
    def show_specific_list(trigger):
        cur_pos = editor.getCurrentPos()
        if trigger == color_trigger:
            if editor.getTextRange(cur_pos-len(color_indic), cur_pos) == color_indic:
                editor.autoCShow(0,color_list)
        elif trigger == image_trigger:
            if editor.getTextRange(cur_pos-len(image_indic), cur_pos) == image_indic:
                editor.autoCShow(0,file_list)
    
    def callback_CHARADDED(args):
        if args['ch'] in [color_trigger,image_trigger]:
            show_specific_list(args['ch'])
            
    def callback_BUFFERACTIVATED(args):
        global file_list
        cur_dir, file = os.path.split(notepad.getCurrentFilename())
        file_list = ':'.join(x for x in os.listdir(cur_dir))
    
    
    editor.autoCSetSeparator(ord(':'))
    editor.autoCSetIgnoreCase(True)
    
    
    if CAC_IS_RUNNING:
        editor.clearCallbacks([SCINTILLANOTIFICATION.CHARADDED])
        notepad.clearCallbacks([NOTIFICATION.BUFFERACTIVATED])    
        CAC_IS_RUNNING = False
    else:
        editor.callback(callback_CHARADDED, [SCINTILLANOTIFICATION.CHARADDED])
        notepad.callback(callback_BUFFERACTIVATED, [NOTIFICATION.BUFFERACTIVATED])
        CAC_IS_RUNNING = True
    

    would show a completion list based on the text entered.

    Cheers
    Claudia



  • I will definitely check this, thanks for answering and taking your time to write this.

    Cheers,
    Gokalp


Log in to reply