Comparison between vim and emacs Script Programming

Source: Internet
Author: User

1. Define Variables

Vim:

Run a = 123

Emacs:

(Setq a' 123)

2. define functions

Vim:

Function Fun () // if the scope limit is not used, the first letter must be capitalized.

Endfunction

Command Line call: command! -Nargs = 1 Gdb :! Command "<args>"

Emacs:

(Defun fun ()

"Message"

(Interactive)

.....

)

3. Execute Functions

Vim:

Call function ()

Emacs:

(Fun)

4. conditional statements

Vim:

If c

Elseif B

Else e

Endif

While

Endwhile

Emacs:

(If

'Thenfun

'Elsefun)

(While (equal a B)

Body...

(Counter ))

(Cond

(First ...)

(Second ...))

5. Automatic Execution

Vim:

Autocmd BuffRead *. cpp: call fun

Emacs:

(Add-hook 'C ++-mode-hook' (lambda ()

(Interactive)

.....))

6. Reference other files

Vim:

Source name. vim

. Name. vim

Emacs:

(Require 'name); you must add (provied 'name) at the end of the file)

(Load "name. el ")

7. Bind a shortcut key

Vim:

Nmap <silent> <F8>: call fun () <CR>

Imap <F9>: call fun () <CR>

Vmap <F10>: call fun () <CR>

Emacs:

(Global-set-key [f8] 'fun)

(Define-key c ++-mode-map (kdb "C-\") 'fun)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.