VIM-如何使“撤消"使我回到以前的模式? [英] VIM - How to I make Undo put me back in what ever mode I was on previously?

查看:113
本文介绍了VIM-如何使“撤消"使我回到以前的模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常去各地的编辑在正常模式下的东西才意识到我变的目的不是,正因为如此,我撤消,然后按K/L/J/H继续,但同时我已经在插入模式,所以我有走出它首先

我想插入我的.vimrc一个规则,让我回到我刚才上的任何改变,我之前做过的模式.

IE:移+ S(删除线并开始编辑) - >撤消:早在正常模式下 奖金:CIW - > asdahsdasdh - >撤销:早在正常模式

PS:我实际上使用撤消使用命令+ Z,默认MacOSX的撤消组合

解决方案

OS X被捕获 Cmd的 ž键盘事件和处理撤消在应用程序级别,因此任何为映射将被忽略.但是,您可以覆盖此做你想做的.

首先,添加一个映射到你的.vimrc:

<预类= 朗 - 无prettyprint-越权">

重新启动的MacVim以确保的.vimrc已经重新加载.

要得到这个工作,你还需要告诉的MacVim不使用<大骨节病> Cmd的 <大骨节病> Z ^ 的撤消"菜单项.

(这些说明基于优胜美地/El Capitan,但与旧版本相似.)

  1. 转到系统预置的应用程序.
  2. 点击键盘图标.
  3. 点击快捷键部分.
  4. 在左侧列中,点击应用程序的快捷方式.
  5. 点击 +" 按钮来添加新的规则.
  6. 从应用程序下拉菜单中选择的MacVim.
  7. 在菜单标题"框中键入撤消"(正是这样,别无其他).
  8. 点击进入键盘快捷键框,选择一些快捷键,你永远不会真正使用.
  9. 单击 添加",然后关闭系统偏好设置.

(我选择了 Shift Ctrl Opt Cmd x .)

现在要回的MacVim,如果你拉下编辑菜单中的撤消"应该有您选择的组合键,你的<大骨节病> Cmd的 <大骨节病> Z ^ 快捷方式应该工作你描述过的.

I often go around editing things in normal mode only to realise my change was not intended, as such, I undo and then press K/L/J/H to continue but meanwhile I am already in insert mode, so I have to get out of it first.

I would like to insert a rule on my .vimrc to put me back on the mode I was on just before any changes that I did.

IE: shift+s (delete line and start editing) -> undo : Back in normal mode Bonus: ciw -> asdahsdasdh -> undo: Back in normal mode

PS: I am actually using Undo with Command+Z, the default MacOSX undo combination.

解决方案

OS X is capturing the Cmdz keyboard event and handling undo at the application level, so any mapping for <D-z> will be ignored. However, you can override this to do what you want.

First, add a mapping to your .vimrc:

if has("gui_running")
    inoremap <D-z> <Esc>:undo<CR>
endif

Restart MacVim to ensure the .vimrc has been reloaded.

To get this to work you also need to tell MacVim to not use Cmdz for the "Undo" menu item.

(These directions are based on Yosemite/El Capitan but are similar for older versions.)

  1. Go to the System Preferences app.
  2. Click the Keyboard icon.
  3. Click the Shortcuts section.
  4. Click on App Shortcuts in the left column.
  5. Click the "+" button to add a new rule.
  6. Choose MacVim from the Application pulldown.
  7. Type "Undo" (exactly that and nothing else) in the Menu Title box.
  8. Click into the Keyboard Shortcut box, and choose some shortcut you'll never actually use.
  9. Click "Add", then close System Preferences.

(I chose ShiftCtrlOptCmdx.)

Now going back to MacVim, if you pull down the Edit menu, "Undo" should have the key combination you chose, and your Cmdz shortcut should work as you described.

这篇关于VIM-如何使“撤消"使我回到以前的模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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