Equivalence of Emacs and Vim commands

Equivalence of VIM and Emacs commands

Descriptions for VIM commands are quite straightforward, there is not many choice, you have just to type the command. This is not as simple in Emacs, because there is so much possibilities. Here is presented the Emacs commands and their standard key bindings when there are some. But many (like myself) alter the default keybindings to type faster and according to what they do with Emacs.

This heading includes contributions from David Richfield. Thanks David !

Conventions

  • NA
    Not Applicable, the equivalence doesn't exist.
  • -
    I personnaly don't know if there is an equivalence.

Commands

Help

ActionEmacs commandVIM command
Generalapropos:help
:help <word> then hit CTRL-D to see matching help entries for word
About commandsapropos-command : f1 a:help <command>
Describe functiondescribe-function : f1 fNA
Describe variabledescribe-variable : f1 v:help options
Describe key brieflydescribe-key-briefly : f1 cNA
Tutorialhelp-with-tutorial : C-h tNA

Open/Close/Save

ActionEmacs commandVIM command
Open a filefind-file : C-x C-f:e file-name
Reload a file from diskrevert-buffer:e
Close a buffer, a framekill-buffer : C-x k:q
Close all filesC-x C-c:qall
List all buffers, frameC-x C-b:files
Change to next frameswitch-to-buffer : C-x bC-w C-w
Change to next bufferswitch-to-buffer : C-x b:e#<n>
Save a buffer, a framesave-current-buffer : C-x C-s:w
Save all buffers, framesave-some-buffer : C-x s:wall

In Emacs, it is better to load all the files in different buffers, but in the same instance of Emacs, if only to load the file faster. Thus, open as many files as you want and then switch from one buffer to another.

Navigation / Search

ActionEmacs commandVIM command
Go to the beginning of a bufferbeginning-of-buffer : M-<1G or gg
Go to the end of a bufferend-of-buffer : M->G
Search forwardC-s/<string>
Repeat last search forwardC-s C-sn or /
Search backwardC-r?<string>
Repeat last search backwardC-r C-rN or ?
Find the next brace, bracket, etc.Click on the brace, bracket, etc.%

Edition

ActionEmacs commandVIM command
Transpose lettersC-txp
Transpose wordsM-tGo to start of first word, then dwwP. Except at the end of the line, then go to the space in between the words, and type 2dwbhP
downcase wordM-lWith cursor at beginning of word: veu
Downcase regionC-x C-lMark region, press u.
Upcase wordM-uWith cursor at beginning of word: veU
Upcase regionC-x C-uMark region, press U.
Syntax highlightingM-x toggle-global-lazy-font-lock-mode:syntax enable and then :set syntax=>syntax name<
Region indentationM-x indent-according-to-mode== (current line)
<n>== (n, the number of lines)
=G (till end of file)
Inserting commentsindent-for-comment : M-;-

Cut & Paste

ActionEmacs commandVIM command
Copy a region, a selectioncopy-region-as-kill<n>yy to "yank" or copy n lines, or mark region in visual mode, then press y
Set markC-Spacem{a-zA-Z}
CopyM-wSee above
Mark the bufferC-x hggVG

String substitution

To come, work in progress.

:%s/stringToReplace/newString/gc
:%s#stringToReplace#newString#gc
:%s#/home/guest/tmp/comp#/usr/local/#gc

Undo / Redo

ActionEmacs commandVIM command
UndoC-_u
RedoSpace C-_C-r
Repeat a commandM-x z.
Repeat a complex commandrepeat-complex-command : C-x M-:.

More about the undo/redo in Emacs : All the actions are piled up, even the "undo" action. Thus to perform a "redo", one has to undo an "undo". One way to do that is after an "undo" to write a character, like "space", and then perform an "undo".

Check this out too about macros.

Spelling check

ActionEmacs commandVIM command
Check spelling of a region/fileispell-region / ispell-buffer

:w! (hit ENTER):!ispell % (hit ENTER):e! % (hit ENTER)

Or a bit more complex and powerful, use some macros :
map <F5> :w!<CR>:!ispell -d francais %<CR>:e! %<CR>
map <F6> :w!<CR>:!ispell -d american %<CR>:e! %<CR>

Check spelling of a wordispell-wordNA

Emacs specificities

Insertion

ActionEmacs command
Insert special charactersC-q

Examples :

  • To insert a TAB character
    C-q TAB
  • To insert a newline in the minibuffer, for substitutions, etc.
    C-q C-j

LISP evaluation

ActionEmacs command
Evaluate a LISP expression and print the resulteval-expression : M-:

For a function evaluation expression is of the form (function)

Examples :

  • Addition
    (+ 1 2)
    will return 3
  • Division
    (/ 225 60)
    will return 3
  • Division
    (/ 225.0 60)
    will return 3.75
  • Variable assigment
    (setq shell-file-name "bash")
    will return "bash"

For a variable evaluation expression is of the form variable

Examples :

  • Checking a variable value
    M-: shell-file-name
    might return "/bin/bash" or "bash"

Emacs modes

ActionEmacs command
Get name of current buffer major mode, eg xml-modeM-: major-mode
Get pretty name of current buffer major modeM-: mode-name
Full description of current major modeM-x describe-mode
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值