Vim macros don't work when using viper + vimpu

2019-06-25 04:14发布

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.

9条回答
太酷不给撩
2楼-- · 2019-06-25 04:53

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.

查看更多
做自己的国王
3楼-- · 2019-06-25 04:57

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.

查看更多
戒情不戒烟
4楼-- · 2019-06-25 05:00

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

查看更多
姐就是有狂的资本
5楼-- · 2019-06-25 05:07

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

查看更多
Emotional °昔
6楼-- · 2019-06-25 05:08

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

查看更多
来,给爷笑一个
7楼-- · 2019-06-25 05:12

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.

查看更多
登录 后发表回答