emacs相当于vim重新映射的邪恶,例如:nnoremap dd g0dg $ [英] emacs evil equivalent of vim remapping, e.g. :nnoremap dd g0dg$

查看:175
本文介绍了emacs相当于vim重新映射的邪恶,例如:nnoremap dd g0dg $的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个vi / vim的人,但我使用LaTeX很多,我真的很喜欢AUCTeX Preview,所以我一直在使用emacs与viper直到最近,但我现在正在尝试邪恶。我确实没有emacs的专家。



由于在预览图像被激活时,emacs中的视线模式是非常好的,因为预览图像被激活,线路长度都被弄脏了,但是如果每个段落真的只有一条长线,在视线模式下,预览图像是否被激活都是很好的。



一直让我烦恼的一件事像j和dd这样的viper命令只能在逻辑行上工作,而不是屏幕线。在vim中,可以使用'gj'而不是'j',而且这就是邪恶的作用。但是没有等同于'dd'。



我遇到了这个解决这个vim的一个SO问题的答案,它似乎在做这个诀窍:nnoremap dd g0dg $。确实在恶意中键入右手边(即使使用数字前缀)也可以正常工作。



然而,我不能轻易的看到恶意文件中的一个可能会实现这个重新映射。我看到一个关于邪恶的一般SO问题的详细答案,但是它的所有建议和示例显示如何将键序列映射到单个已定义的邪恶函数。我看不到任何一个现有的邪恶的密钥序列被重新映射到另一个(可能更长的)现有的邪恶密钥序列的例子。



我想我可以替换手边的映射与一系列现有的邪恶功能,但我不知道如何做到这一点。或者我可以使用一个基本的emacs键重新映射,但我担心这会干扰邪恶的不同模式/状态,或者只是不行。



有没有人有任何想法?

解决方案

这是一个基本的功能,可以做我想要的(请注意,它不会做其他的好像Vim / Evil提供的东西;使用 evil-define-command )。如果您尝试将其映射到 gdd ,那么您将会遇到一些关键字,因此您可以将其映射到 gD (或任何你喜欢的):

 (defun evil-delete-visual-line()

(let((progn(begin-of-visual-line)(point)))
(end(progn(end-of-visual-line)(point))))
(evil-delete beg end)))

(define-key evil-normal-state-mapgD'evil-delete-visual-line)


I am a vi/vim person at heart but I use LaTeX a lot and I really like AUCTeX Preview so I have been using emacs with viper until recently, but I am now trying evil instead. I am however certainly no emacs expert.

Visual line mode in emacs is terrific with AUCTeX Preview because when the Preview images are activated, the line lengths are all mucked up, but if each paragraph is really only one long line, in visual line mode it all looks great whether the Preview images are activated or not.

One thing that has always annoyed me is that viper commands like 'j' and 'dd' only work on "logical lines", not screen lines. In vim one would instead use 'gj' instead of 'j', and indeed this is how evil works. However there is no equivalent for 'dd'.

I came across the answer to a SO question addressing this for vim and it seems to do the trick :nnoremap dd g0dg$. Indeed typing the "right-hand side" in evil (even with a numerical prefix) works exactly as it should.

However I cannot easily see in the evil documentation how one might achieve this remapping. I have seen a detailed answer to a general SO question about evil but all its suggestions and examples show how to map a key sequence to a single already-defined evil function. I can't see any examples where an existing evil key sequence is remapped to another (possibly longer) existing evil key sequence.

I guess I could replace the "right-hand side" of the mapping with a sequence of existing evil functions, but I'm not sure how one might do that. Or I could just use a basic emacs key remapping but I fear that this will interfere with evil's different modes/states, or simply just won't work.

Does anyone have any ideas?

解决方案

Here's a basic function that does what I think you want (note that it doesn't do the other nice things like counts that Vim/Evil provide; use evil-define-command for that). You'll clobber some keybindings if you try to map it to gdd, so as a workaround, you could map it to gD (or whatever you like):

(defun evil-delete-visual-line ()
  (interactive)
  (let ((beg (progn (beginning-of-visual-line) (point)))
        (end (progn (end-of-visual-line) (point))))
    (evil-delete beg end)))

(define-key evil-normal-state-map "gD" 'evil-delete-visual-line)

这篇关于emacs相当于vim重新映射的邪恶,例如:nnoremap dd g0dg $的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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