4coder » Forums » Rebind tab key
Stromberg
3 posts
#17336 Rebind tab key
2 weeks ago Edited by Stromberg on Feb. 4, 2019, 11:34 a.m. Reason: Initial post

I want to rebind the tab key in code mode, cause I often use languages that are not bracket based.
I tried this and it does not work for me.

1
2
3
4
5
begin_map(context, mapid_file);
{
    bind(context, '\t', MDFR_NONE, write_character);
}
end_map(context);


my other keybindings do work.
mrmixer
Simon Anciaux
536 posts
#17338 Rebind tab key
2 weeks ago

mapid_file is for text file, not code. Try with default_code_map instead.
Stromberg
3 posts
#17339 Rebind tab key
2 weeks ago

Thanks, that works great :D
I'm wondering though I have this

1
2
3
4
5
6
7
begin_map(context, mapid_file);
{
    bind(context, key_del, MDFR_SHIFT, delete_line);
    bind(context, 'a', MDFR_CTRL, select_all);
    bind(context, ' ', MDFR_CTRL, word_complete);
}
end_map(context);


and those work fine in the code mode, how do I "know" which one I should use?
mrmixer
Simon Anciaux
536 posts
#17340 Rebind tab key
2 weeks ago

mapid_default_code_map is used by files with the extensions specified in the config.4coder file. The treat_as_code value that defaults to .cpp.c.hpp.h.cc.cs.java.rs.glsl.m .

File with other extensions will use mapid_file.

mapid_default_code_map inherits mapid_file's bindings. Meaning that any binding that is present in mapid_file will be present in mapid_default_code_map unless you overwrite it in mapid_default_code_map. It was probably why remapping tab didn't work since it's bound to autocomplete in mapid_default_code_map by default.
Stromberg
3 posts
#17341 Rebind tab key
2 weeks ago

I see, thanks a lot for clearing it up :)