1

I configured mutt to use vim as an editor to write emails (with set editor=vim in .muttrc), and I have noticed that when I am in tmux (with an empty .tmux.conf), the vim keybinding CTRL-K in insert mode, which is handy to insert digraphs, does not work.

Outside of Tmux && mutt, everything works fine: typing CTRL-K causes the character ? to temporarily appear under the cursor, and the next two characters I type are correctly interpreted as a digraph.

Does anyone know where the error might be coming from?

Thank you.

  • 1
    Maybe tmux consumes the keypress C-k, so Vim doesn't receive it. I'm not sure these shell commands will work for you, because I use an old version, but you could try tmux list-keys. This should list the keybindings installed in a tmux session. They can be divided into several tables. I suspect the one you should look for is called root, because these keybindings don't need a prefix. To see them, try tmux list-keys -T root. Look for the word C-k. If you find it, and you want to remove it, try to add this to your .tmux.conf: unbind-key -T root C-k, then restart tmux. – user852573 Oct 13 '17 at 15:24
  • 1
    Ah yes, I misunderstood your question, sorry. You're right, the issue must come from something else, but unfortunately I have no other idea. – user852573 Oct 13 '17 at 16:08
  • 1
    I forgot: execute :verb ino <c-k> in a buffer where C-k doesn't insert digraphs. If a filetype plugin is involved, it would install buffer-local mappings, for example only in a file whose type is mail. The command will find a global mapping from any buffer, but it will only find a buffer-local one in the right type of buffer. – user852573 Oct 13 '17 at 18:05
  • 1
    In the meantime, you could restore the functionality using another key sequence. For example, in a filetype plugin sourced when you load a mail buffer (example: ~/.vim/after/ftplugin/mail.vim), you could write ino <buffer> <c-g><c-g> <c-k>. With this mapping, you would insert a digraph by pressing C-g C-g. Also, you could try to check whether Vim receives C-k, by inserting one literally. If you press C-v C-k, you should see the caret notation ^K inside your buffer. If you don't see anything, it means something is consuming C-k before Vim. – user852573 Oct 14 '17 at 10:17
  • 2
    Hello! Thank you very much for your comment. I tried C-v C-k and nothing appears. It turns out that, in fact, the key was received by tmux and not sent to vim, because of mappings I defined in my tmux.conf (which is strange, considering that I was opening with tmux -f empty.conf and it didn't work). The problematic line in my .tmux.conf was this one: is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim)(diff)?$"'. Adding |mutt in the regular expression fixed it. Thanks again for your time and for your help! – Rastapopoulos Oct 14 '17 at 10:36
2

The origin of the problem was that tmux was consuming the C-k keypress. I had blindly followed the instructions that came along with the vim-tmux-navigator plugin at the time I installed it, which recommended using the following line in .tmux.conf to identify whether or not vim was running:

is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'

This way of detecting vim was not robust, and in my case it didn't detect that I was in vim when writing an email with mutt.

As it turns out, the command proposed in the README of the plugin was changed in this commit to one that makes the detection of vim more robust.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.