如何将 vim(通过 tmux)绑定到 Cmd 键 [英] How to bind vim (through tmux) to Cmd key

查看:28
本文介绍了如何将 vim(通过 tmux)绑定到 Cmd 键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常使用 macvim,并使用我的 macs 命令键进行了许多键绑定.我正在尝试切换到 tmux,但这些绑定都不起作用.关于如何修改我的 .tmux.config 或 .vimrc 以恢复这些绑定的任何提示?

I usually use macvim, and have a number of key bindings using my macs command key. I'm trying to switch over to tmux, but none of those bindings are working. Any tips on how to modify my .tmux.config or .vimrc to get those bindings back?

推荐答案

您是否有机会使用 来模拟其他编辑器的快捷键?

Do you, by any chance, use <D-> to emulate another editor's shortcuts?

您可以在 MacVim 中使用命令键进行映射.没有特定于 Vim 的解决方法.

You can use the command key for mappings only in MacVim. There is no Vim-specific workaround.

这是因为该密钥被 Terminal.app(或 iTerm.app)拦截"以供自己使用,甚至未被任何 CLI 程序注册.您可以在 CLI Vim 中依赖的唯一修饰符是 ShiftControl.甚至 Option 也需要一些变通办法才能工作,而且它不可能在没有副作用的情况下实现.

This is because this key is "intercepted" by Terminal.app (or iTerm.app) for its own use and isn't even registered by any CLI program. The only modifiers you can rely on in CLI Vim are Shift and Control. Even Option needs some workarounds to work and it can't be achieved without side effects.

虽然您可以在两个终端仿真器的首选项中重新映射一些键/键组合和/或使用第三方解决方案/黑客来重新映射命令键,但我建议您重新考虑您的方法并考虑使用可以使更多Vim 世界中的意义.

While you can remap some keys/key-combinations in the preferences of both terminal emulators and/or use third party solutions/hacks to remap the command key I'd advise you to rethink your approach and consider using mappings that make more sense in Vim-world.

我的建议是使用 键作为所有自定义映射的基础.默认的 是 \,这很不方便.很多人把它改成更方便的键:

My recommendation is to use the <leader> key as the basis for all your custom mappings. The default <leader> is \ which is quite inconvenient. A lot of people change it to a more convenient key:

let mapleader=","

这是我的 ~/.vimrc 中的一个例子:

Here is an example from my ~/.vimrc:

nnoremap <silent> <leader>k :m-2<CR>==

这篇关于如何将 vim(通过 tmux)绑定到 Cmd 键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆