Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • "Vim uses tmap mappings for both :terminal insert and normal modes." No, it doesn't, only terminal insert mode. See [:help mapmode-t]: "The terminal mappings are used in a terminal window, when typing keys for the job running in the terminal." Commented May 16, 2020 at 22:38
  • @filbranden I wasn't clear about that in the description. Terminal mode has actually 3 states: [1] terminal normal mode - it allows using regular mappings, [2] terminal insert mode with bash in insert mode (can be configured in .inputrc), [3] terminal insert mode with bash in normal mode (can be configured in .inputrc). I don't know how to distinguish two last modes so my terminal mapping work only in the last mode. Commented May 17, 2020 at 9:19
  • Ah I can't tell that at all from reading your question (well, only in that you mention .inputrc that doesn't matter at all for Vim.) Please edit your question to make it clear you're talking about "vi-mode" in bash. But to answer your question, Vim doesn't really have a direct way to know whether bash inside a :terminal is in Insert or Normal mode, so a :tmap in Vim will always execute the action when you press that key from that terminal window. Commented May 17, 2020 at 12:22
  • Does it work using <C-v><Tab> to insert an actual Tab character in that terminal window? If not, maybe configure a mapping for it with tnoremap <C-v><Tab> <Tab>? That way you still have a way to enter a literal tab... Commented May 17, 2020 at 12:23
  • I could do tnoremap <S-Tab> <Tab> with tmap <TAB> <C-w>w and use Shift with Tab whenever I want to use autocompletion in the terminal but that doesn't solve the problem. I've got many other keybindings that I would like to use when my bash is in insert vi-mode. I've noticed that in emacs that feature is available by default. Commented May 17, 2020 at 14:09