Micro: Any way to disable autocompletion?

Created on 24 Mar 2020  路  13Comments  路  Source: zyedidia/micro

Description of the problem or steps to reproduce.

I'm trying to disable autocompletion, but it does not seem to be configurable. Or is it?

Specifications

Commit hash: 943ea15.
OS: Arch Linux.
Terminal: xterm.

Most helpful comment

By default the tab key is bound to

"Tab": "Autocomplete|IndentSelection|InsertTab"

You can rebind it and remove the autocomplete part of the binding to achieve what you want.

All 13 comments

Or is it?

vsauce music plays

Try pressing Ctrl E in the editor and type set then keep on pressing tab; maybe you will find it there even if it's undocumented.

@dullbananas, I already did. :sweat_smile: But there doesn't seem to be anything related to autocompletion.

This is unfortunate.

Also why did you want to disable it in the first place

Because I'm trying to insert tabs. :slightly_smiling_face:

By default the tab key is bound to

"Tab": "Autocomplete|IndentSelection|InsertTab"

You can rebind it and remove the autocomplete part of the binding to achieve what you want.

Thanks, @zyedidia! Can this feature be customized so that it works properly depending on the context?

The autocomplete action should try to work properly based on the context. It will insert a tab if the character before the cursor is a whitespace character.

What further behavior are you looking for? Technically you can customize it more with Lua and the onAutocomplete and preAutocomplete callbacks. If you return false from onAutocomplete it will do the tab actions (even if the autocomplete has already been done), and if you return false from preAutocomplete it will cancel the autocomplete action.

I got into trouble when trying to insert a tab into a comment block. That's the _"further customization"_ I'd like to add to it. :grin:

Thanks for your help, pal!

...Well, after a while using it, it turns out that something unexpected happens: If I disable autocompletion in the way suggested by @zyedidia, it also gets disabled for commands. :sweat_smile: I run commands more often than inserting tabs into comments!

Changing the Tab key behaviour works, but I think it should either be disabled by default or changed to another keybinding (e.g. ctrl+tab like in many other IDEs) because with the standard config, it is often impossible to insert tab keys after non-whitespace characters.

Think of a TSV file (tab delimited CSV), or maybe this example:

abc def
a[TAB KEYPRESS]xyz

should result in

abc def
a   xyz

but it now becomes

abc def
abcxyz

due to autocompletion. The only way to insert - afaik - is to manually copy and paste the tab character.

Yeah, these things happen. However, I think that @zyedidia will improve more on this; because this is a newly added feature (autocompletion).

Hmm yes I see your points. For the next large update (2.1.0) I am hoping to provide an improvement to the keybinding system which would allow you to specify keybindings based on the buffer, so you could enable the tab binding for the infobar and disable it for general buffers. At the moment this is only possible if you add the following code to your init.lua:

local buffer = import("micro/buffer")

function preAutocomplete(bp)
    if bp.Buf.Type == buffer.BTInfo then
        return true
    end
    return false
end

The above code will only allow the autocomplete action to be executed if the buffer is an info buffer (infobar).

@phil294 I can see how this is cumbersome. One method for inserting tab characters is to insert a space, insert the tab, and then delete the space. Not the best but it doesn't require copy-paste. Also, you are free to rebind the Autocomplete and InsertTab actions to whatever keys you like. Just take a look at the current binding for Tab.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Calinou picture Calinou  路  3Comments

nabeelomer picture nabeelomer  路  4Comments

johnmbaughman picture johnmbaughman  路  3Comments

Bigguy34 picture Bigguy34  路  3Comments

utkarsh2102 picture utkarsh2102  路  3Comments