使用 viper 时,Vim 宏不起作用 Emacs 中的 vimpulse

发布于 2024-07-06 04:20:12 字数 172 浏览 14 评论 0原文

任何其他使 emacs 尽可能像 vim 的调整也将受到赞赏。

附录:我不只使用 vim 的主要原因是我喜欢 emacs 如何让你在两个不同的框架中打开文件[添加:抱歉,这很令人困惑:我的意思是单独的窗口,其中 emacs称为“框架”]。 这就像进行垂直分割,但我不需要有一扇巨大的窗户。

Any other tweaks for making emacs as vim-like as possible would be appreciated as well.

Addendum: The main reason I don't just use vim is that I love how emacs lets you open a file in two different frames [ADDED: sorry, this was confusing: I mean separate windows, which emacs calls "frames"]. It's like making a vertical split but I don't have to have one enormous window.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

缪败 2024-07-13 04:20:13

我不知道如何让 Vim 宏工作,但是既然你要求调整 emacs 尽可能像 vim 一样,这里有一些我每天使用的 vimpulse 的补充:

(define-key viper-vi-global-user-map [(delete)] 'delete-char)
(define-key viper-vi-global-user-map "/" 'isearch-forward-regexp)
(define-key viper-vi-global-user-map "?" 'isearch-backward-regexp)
(define-key viper-vi-global-user-map "\C-wh" 'windmove-left)
(define-key viper-vi-global-user-map "\C-wj" 'windmove-down)
(define-key viper-vi-global-user-map "\C-wk" 'windmove-up)
(define-key viper-vi-global-user-map "\C-wl" 'windmove-right)
(define-key viper-vi-global-user-map "\C-wv" '(lambda () (interactive)
                                                (split-window-horizontally)
                                                (other-window 1)
                                                (switch-to-buffer (other-buffer))))

(define-key viper-visual-mode-map "F" 'viper-find-char-backward)
(define-key viper-visual-mode-map "t" 'viper-goto-char-forward)
(define-key viper-visual-mode-map "T" 'viper-goto-char-backward)
(define-key viper-visual-mode-map "e" '(lambda ()
                                         (interactive)
                                         (viper-end-of-word 1)
                                         (viper-forward-char 1)))

(push '("only" (delete-other-windows)) ex-token-alist)
(push '("close" (delete-window)) ex-token-alist)

当然,学习 Emacs 也非常重要,但是 Emacs依靠定制来使其行为完全符合您的要求。 默认的 Vim 键绑定非常舒适,使用 Viper 仅仅意味着 Viper 会为您进行一些 Emacs 定制。

至于使用 Vim 而不是 Emacs,我喜欢 Vim,但我喜欢 Lisp 系统 Emacs 的交互性。 没有什么比在编辑器中的任何位置键入一行代码并通过一次击键立即对其进行评估、通过一次击键从编辑器(包括实时文档)更改或检查编辑器的状态(包括实时文档)更好的了( CMx) 当它运行时

I don't know how to make Vim macros work, but since you asked for tweaks for making emacs as vim-like as possible, here's a few additions to vimpulse I use everyday:

(define-key viper-vi-global-user-map [(delete)] 'delete-char)
(define-key viper-vi-global-user-map "/" 'isearch-forward-regexp)
(define-key viper-vi-global-user-map "?" 'isearch-backward-regexp)
(define-key viper-vi-global-user-map "\C-wh" 'windmove-left)
(define-key viper-vi-global-user-map "\C-wj" 'windmove-down)
(define-key viper-vi-global-user-map "\C-wk" 'windmove-up)
(define-key viper-vi-global-user-map "\C-wl" 'windmove-right)
(define-key viper-vi-global-user-map "\C-wv" '(lambda () (interactive)
                                                (split-window-horizontally)
                                                (other-window 1)
                                                (switch-to-buffer (other-buffer))))

(define-key viper-visual-mode-map "F" 'viper-find-char-backward)
(define-key viper-visual-mode-map "t" 'viper-goto-char-forward)
(define-key viper-visual-mode-map "T" 'viper-goto-char-backward)
(define-key viper-visual-mode-map "e" '(lambda ()
                                         (interactive)
                                         (viper-end-of-word 1)
                                         (viper-forward-char 1)))

(push '("only" (delete-other-windows)) ex-token-alist)
(push '("close" (delete-window)) ex-token-alist)

Of course, learning Emacs is very important too, but Emacs relies on customization to make it behave exactly like you want it to. And the default Vim key bindings are so comfortable that using Viper simply means that Viper does some Emacs customization for you.

As for using Vim instead of Emacs, I love Vim, but I love the interactiveness of the Lisp system that is Emacs. Nothing feels like typing a line of code anywhere in your editor and instantly evaluating it with a single keystroke, changing or inspecting the state of your editor from your editor (including the live documentation) with a single keystroke (C-M-x) while it is running.

掌心的温暖 2024-07-13 04:20:13

我没有为您提供任何 viper 或 vimpulse 调整,但我建议您尝试跟随模式。

当然我也建议你也开始学习Emacs。 我的意思是,如果您已经了解了这么多,您不妨阅读一下本教程,也许还可以看看 emacswiki。

I don't have any viper or vimpulse tweaks for you, but I do recommend that you try follow-mode.

Of course I'd also recommend that you start learning Emacs too. I mean, if you're in this far you might as well go through the tutorial and maybe have a look at emacswiki.

古镇旧梦 2024-07-13 04:20:13

我使用的VIM版本支持(Windows版本)支持使用“Ctrl+W s”将文件分成2个不同的框架...

The version of VIM I use support (Window version) support splitting a file into 2 different frames using "Ctrl+W s"...

最初的梦 2024-07-13 04:20:13

Vim 可以轻松地让您在两个不同的框架中打开文件:

:split 水平分割

:vsplit 垂直分割

您可以根据需要多次分割屏幕相同文件、不同文件或两者。

CTRL-ww 切换帧。

:resize +n:resize -n 调整当前帧的大小。

Vim easily lets you open a file in two different frames:

:split to split it horizontally

:vsplit to split it vertically

You can split the screen as many times as you want between the same file, different files, or both.

CTRL-w-w switches frames.

:resize +n or :resize -n resizes the current frame.

转身泪倾城 2024-07-13 04:20:13

Emacs+vimpulse 很棒,但我认为它正确的工作流程是自由地结合使用 emacs 命令和 vim 快捷方式。
例如,emacs 的宏快捷键 F3 和 F4 比 vim 的 qq 和 @q 更容易。
另外,emacs 命令是通过 Alt+x 访问的,而不是 : 命令。 尽管 vimpulse 支持一些重要的 vim 命令,但它们的存在只是为了兼容性。

以下是我的 vimpulse 具体定制。

.emacs

   ; I use C-d to quit emacs and vim
   (vimpulse-global-set-key 'vi-state (kbd "C-d") 'save-buffers-kill-terminal)
   ; use ; instead of :
   (vimpulse-global-set-key 'vi-state (kbd ";") 'viper-ex)
   ; use C-e instead of $. This works for all motion command too! (e.g. d C-e is easier to type than d$)
   (vimpulse-global-set-key 'vi-state (kbd "C-e") 'viper-goto-eol)
   (defun t_save() (interactive)(save-buffer)(viper-change-state-to-vi)) 
   (global-set-key (kbd "\C-s") 't_save) ; save using C-s instead of :w<CR> or C-x-s

    (defun command-line-diff (switch)
          (let ((file1 (pop command-line-args-left))
                (file2 (pop command-line-args-left)))
            (ediff file1 file2)))

    ;; Usage: emacs -diff file1 file2 (much better then vimdiff)
    (add-to-list 'command-switch-alist '("-diff" . command-line-diff))

如果您喜欢终端,可以使用 emacs -nw。 在这种情况下,这个剪贴板插件就很有用了。 http://www.lingotrek.com/2010 /12/integrating-emacs-with-x11-clipboard-in.html

.viper

    (setq viper-inhibit-startup-message 't)
    (setq viper-expert-level '3)
    (setq viper-ESC-key "\C-c") ; use C-c instead of ESC. unlike vim, C-c works perfectly with vimpulse.

几乎所有 vim 所做的事情都可以在 emacs+vimpulse 中轻松完成(如果不是相同的方式),但反之则绝对不行!

ps 上面的大部分建议都被最近的 vimpulse 默认支持。

Emacs+vimpulse is awesome, but I think its right workflow is to liberally use emacs commands in combination to vim shortcuts.
For example, emacs's macro shortcut F3 and F4 is easier than vim's qq and @q .
Also emacs commands are accessed through Alt+x, not : commands. Though vimpulse support a few important vim commands, they are there just for compatibility.

Followings are my vimpulse specific customizations.

.emacs

   ; I use C-d to quit emacs and vim
   (vimpulse-global-set-key 'vi-state (kbd "C-d") 'save-buffers-kill-terminal)
   ; use ; instead of :
   (vimpulse-global-set-key 'vi-state (kbd ";") 'viper-ex)
   ; use C-e instead of $. This works for all motion command too! (e.g. d C-e is easier to type than d$)
   (vimpulse-global-set-key 'vi-state (kbd "C-e") 'viper-goto-eol)
   (defun t_save() (interactive)(save-buffer)(viper-change-state-to-vi)) 
   (global-set-key (kbd "\C-s") 't_save) ; save using C-s instead of :w<CR> or C-x-s

    (defun command-line-diff (switch)
          (let ((file1 (pop command-line-args-left))
                (file2 (pop command-line-args-left)))
            (ediff file1 file2)))

    ;; Usage: emacs -diff file1 file2 (much better then vimdiff)
    (add-to-list 'command-switch-alist '("-diff" . command-line-diff))

If you like terminal, you can use emacs -nw. In this case, this clipboard add-on is useful. http://www.lingotrek.com/2010/12/integrating-emacs-with-x11-clipboard-in.html

.viper

    (setq viper-inhibit-startup-message 't)
    (setq viper-expert-level '3)
    (setq viper-ESC-key "\C-c") ; use C-c instead of ESC. unlike vim, C-c works perfectly with vimpulse.

Almost everything vim does can be as easily done (if not the same way) in emacs+vimpulse but definitely not vice versa!

p.s. most of the suggestions above are supported by recent vimpulse BY DEFAULT.

丿*梦醉红颜 2024-07-13 04:20:13

你总是可以在 shell 缓冲区中启动 vim 并调整它的大小以使其填充整个框架?

You could always start vim in a shell buffer and resize it so it filled the whole frame?

_失温 2024-07-13 04:20:13

如果您想要 VIM 功能,那么安装 VIM 更有意义!

If you want VIM functionality, it makes more sense to just install VIM!

泛泛之交 2024-07-13 04:20:13

我不确定我是否回答了你的问题,因为并不完全清楚你在问什么(为什么宏不起作用,或者哪些调整可用于在 emacs 中模拟 vim)
那么,这是你的问题吗?:

  • 一位使用古老 emacs-snapshot(2005 年起)的用户提到
    该模式会导致所有按键打开
    他的键盘将停止工作,除非
    他删除了下面的行
    'viper--来自宏的键映射
    此文件中的 my-get-emulation-keymap

如果是,您可以尝试所述解决方案。

我从 emacs wiki 获得此信息,这是一个已知的错误。

I'm not sure if I answer your question, as it is not entirely clear what you are asking (why the macro's are not working, or which tweaks are available for emulating vim in emacs)
so, is this your problem?:

  • One user who uses an ancient emacs-snapshot (from 2005) mentions
    that this mode causes all the keys on
    his keyboard to stop working unless
    he deletes the line that reads
    'viper--key-maps from the macro
    my-get-emulation-keymap in this file

if it is, you can try the stated solution.

I got this information from the emacs wiki, and it's a known bug.

我不会写诗 2024-07-13 04:20:12

你可以在客户端服务器模式下运行VIM,然后你就可以有两个窗口连接到一个实例,从而消除了对 Emacs 的需要。

You could run VIM in client server mode, then you could have two windows connecting to one instance, hence removing the need for Emacs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文