I am looking for a command I can enter that will make the TAB key input an actual TAB character.
I'm open to anything that is temporary or that will not stomp on TAB mappings that do things other than indenting the cursor (like autocompletion etc). i.e. any or all of these cases would be great to know about:
- It can be permanent and affect all major modes as long as it will not affect anything other than indentation of the cursor. (AFAICT, any permanent changes require an edited config file, but maybe I'm wrong about that.)
- It can be permanent and affect just the current major mode as long as it will not affect anything other than indentation of the cursor. (Again, maybe permanent change options shouldn't be on this list because I do not want to achieve this through config file editing, but maybe there is another way to make permanent changes that I haven't come across yet.)
- It can be temporary and affect all major modes.
- It can be temporary and affect only the current major mode.
- It can be temporary and affect only the current buffer. (I am unclear on whether an option change like this would persist if I then switch the buffer to a different major mode.)
I have found similar questions here but none that quite hit the mark.
- This question is almost the same but missing my caveats, and the only answer says it risks clobbering useful TAB mappings. can TAB behave like M-i?
- This question is different but hits on a great idea, and could even sidestep the useful mapping clobbering issue (if C-q TAB or even M-i could stand-in for TAB for any useful TAB mappings), but it has no answers at all. Translate TAB with C-q TAB
- This question kind of deals with the global risk issue but the only answer looks like a config file edit.
Side note: I am completely baffled by the way the TAB key works in fundamental mode and in text mode. It tries to indent to align with the start of the next word...OK...but it sometimes skips words, and, much worse, successive indentations end up leaving clusters of space characters amongst tab characters (the space characters are completely useless if they come before tab characters, and they make deleting indentation more difficult since there are extraneous characters to delete).
C-q TAB
– lawlist Mar 28 '19 at 05:58(insert "\t")
or(insert 9)
. To evaluate, typeM-:
orM-x eval-expression
– lawlist Mar 28 '19 at 06:06(global-set-key [f5] " ")
There is a literal tab between the double-quotes in the example from the previous sentence. – lawlist Mar 28 '19 at 15:39(global-set-key (kbd "S-<tab>") 'tab-to-tab-stop)
in my config file. This means press shift and tab to insert a real tab – jue Mar 28 '19 at 20:11C-h k
and see what it is bound to. You may need to set up a few different key binding settings for the various major/minor modes that you use on a daily basis ... Some will be easy, and others may take time to track down how they work and learn how to modify them... – lawlist Mar 29 '19 at 05:08