LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 918|回复: 9

emacs怎么实现VI里的ctrl+y和ctrl+e??

[复制链接]
发表于 2004-12-24 11:20:24 | 显示全部楼层 |阅读模式
输入模式的ctrl+y  ctrl+e
觉得VI的这两个功能很实用:p
发表于 2004-12-25 15:59:07 | 显示全部楼层
vi中C-e的功能叫scroll-up,在emacs中的函数就叫scroll-up,用C-h f scroll-up查看它的说明
C-y叫scroll-down
发表于 2004-12-25 19:38:02 | 显示全部楼层
scroll-down is an interactive built-in function in `C source code'.
It is bound to <prior>, M-v.
(scroll-down &optional ARG)

Scroll text of current window down ARG lines.
If ARG is omitted or nil, scroll down by a near full screen.
A near full screen is `next-screen-context-lines' less than a full screen.
Negative ARG means scroll upward.
If ARG is the atom `-', scroll upward by nearly full screen.
When calling from a program, supply as argument a number, nil, or `-'.
这是绑定到了哪个键?
<prior>是什么意思?
 楼主| 发表于 2004-12-25 22:06:21 | 显示全部楼层
Post by Vel
vi中C-e的功能叫scroll-up,在emacs中的函数就叫scroll-up,用C-h f scroll-up查看它的说明
C-y叫scroll-down



兄弟误会了

我说的不是命今模式中的C-y,C-e

而是在按了i,a,o等键后的那个编辑模式。

在那个模式中按住C-y可以把上一行的字一个个地复制下来,C-e则是复制下一行的。

Emacs中有没有类似这个的功能呢?
 楼主| 发表于 2004-12-25 22:08:27 | 显示全部楼层
Post by pupilzeng

这是绑定到了哪个键?


alt+v
发表于 2004-12-25 22:13:11 | 显示全部楼层
还有vim中的这几个命令,很方便的,可不知道怎么在emacs中实现:
dd
Y
发表于 2004-12-26 00:25:06 | 显示全部楼层
以我用emacs的经验,我相信emacs里面是没有现成的这样功能。不过要自己写一个是很简单的事情。
发表于 2004-12-26 01:24:57 | 显示全部楼层
  1. (defun vim-insert-mode-C-y-or-C-e (&optional C-e?)
  2.   "Do that fking stuff for some emacs newbies, which is thought as somewhat 'usable'
  3. in that fking vim ... Only losers will use this fk in emacs, I think."
  4.   (interactive "P")
  5.   (let* ((arg-line (if C-e? 2 0))
  6.          (pos-of-char-to-insert
  7.           (if (>= (- (point) (line-beginning-position))
  8.                  (- (line-end-position arg-line) (line-beginning-position arg-line)))
  9.               nil
  10.             (+ (line-beginning-position arg-line) (- (point) (line-beginning-position))))))
  11.     (if pos-of-char-to-insert
  12.         (insert (char-after pos-of-char-to-insert))
  13.       (beep)
  14.       )))
  15.          
  16. (defun vim-insert-mode-C-e ()
  17.   (interactive)
  18.   (vim-insert-mode-C-y-or-C-e t))

  19. ;; bind these shit, if you really want to.
  20. (global-set-key [?\C-y] 'vim-insert-mode-C-y-or-C-e)
  21. (global-set-key [?\C-e] 'vim-insert-mode-C-e)
复制代码
发表于 2004-12-26 13:04:57 | 显示全部楼层
本来想试试这个代码的
但是冲着这句话,我是绝对不会用你的这个代码的
"Do that fking stuff for some emacs newbies, which is thought as somewhat 'usable'
in that fking vim ... Only losers will use this fk in emacs, I think.
发表于 2004-12-26 14:59:39 | 显示全部楼层
Then hack it by yourself, better this way.

Remember this, emacs is NOT a vim substitute. We have a much better life style with emacs.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表