Search code examples
autocompletesublimetextsublime-text-pluginsublimetext4

How to hide options menu when cursor is inside single or double quotes in sublimetext


I am trying to use the autofilename plugin, but for some reason it replaces me or incorrectly corrects the file path, I think I know that it is because of the options that automatically appear as references when the cursor is inside single or double quotes by example:

enter image description here

As you can see, several options that do not exist such as directory or file names are shown, those names are mostly names that exist in class and id, among other things.

So how can it be avoided that only when the cursor is inside single or double quotes that these options do not appear.

As I mentioned I am trying to use the autofilename plugin but it automatically deletes or corrects me wrong data, I am using sublime text 4113


Solution

  • Probably the easiest way to do this is by assigning a custom key mapping to the filename autocomplete function. First, select Preferences → Key Bindings and add the following, ensuring that they are inside the outer [ ] characters (the file has to be valid JSON):

        { 
            "keys": ["ctrl+super+alt+a"], 
            "command": "afn_show_filenames",
            "context":
            [
                { 
                    "key": "afn_use_keybinding", 
                    "operator": "equal", 
                    "operand": true 
                }
            ]
        },
    

    You can change the key combo to whatever you wish, just make sure it's not overwriting another Sublime or operating system key binding.

    Next, open Preferences → Package Settings → AutoFileName → Settings—User and add the following line:

    "afn_use_keybinding": true,
    

    Now, to open the filename autocomplete, simply press CtrlWinAltA (on Windows and Linux) or CtrlAltA (on OSX/macOS).