emacs中怎么实现括号匹配

Vim、Emacs配置和使用
回复
cmdblock
帖子: 307
注册时间: 2008-12-01 7:52
来自: 蜀山

emacs中怎么实现括号匹配

#1

帖子 cmdblock » 2009-01-19 0:25

我想在编程时,实现括号匹配,比如:我打入 ( 这个符号自动匹配 )
看了下abbrevation,好像不能实现括号匹配
头像
lerosua
论坛版主
帖子: 8455
注册时间: 2007-11-29 9:41
联系:

Re: emacs中怎么实现括号匹配

#2

帖子 lerosua » 2009-01-19 13:20

cmdblock
帖子: 307
注册时间: 2008-12-01 7:52
来自: 蜀山

Re: emacs中怎么实现括号匹配

#3

帖子 cmdblock » 2009-01-19 13:24

兄的我说的不是对齐,而是匹配
emacs0921
帖子: 57
注册时间: 2008-09-13 23:53

Re: emacs中怎么实现括号匹配

#4

帖子 emacs0921 » 2009-01-19 20:58

自己写个函数吧。这个函数的作用是在当前位置插入一个括号,再在另一个你希望的位置上插入另一个括号,最后把光标落在你希望的位置上。把这个函数绑定到左括号上就行了。
forcotton
帖子: 57
注册时间: 2006-10-06 21:10

Re: emacs中怎么实现括号匹配

#5

帖子 forcotton » 2009-01-19 22:30

(show-paren-mode 't) 高亮显示匹配括号
如果要自动插入匹配的括号:
;; enable skeleton-pair insert globally
(setq skeleton-pair t)
(global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "[") 'skeleton-pair-insert-maybe)
(global-set-key (kbd "{") 'skeleton-pair-insert-maybe)

不知道楼主要的是什么功能...
cvgmt
帖子: 322
注册时间: 2007-02-26 2:29
来自: 广东

Re: emacs中怎么实现括号匹配

#6

帖子 cvgmt » 2009-01-22 9:39

loseblue
帖子: 14
注册时间: 2008-04-29 14:55

Re: emacs中怎么实现括号匹配

#7

帖子 loseblue » 2009-01-28 15:15

代码: 全选

;;   C  mode
(add-hook 'c-mode-hook 'hs-minor-mode)
(defun my-c-mode-auto-pair ()
  (interactive)
  (make-local-variable 'skeleton-pair-alist)
  (setq skeleton-pair-alist  '(
    (?` ?` _ "''")
    (?\( ?  _ " )")
    (?\[ ?  _ " ]")
    (?{ \n > _ \n ?} >)))
  (setq skeleton-pair t)
  (local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
  (local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
  (local-set-key (kbd "`") 'skeleton-pair-insert-maybe)
  (local-set-key (kbd "[") 'skeleton-pair-insert-maybe))
(add-hook 'c-mode-hook 'my-c-mode-auto-pair)
我在网上找的,一直在用,输入({这类的,他会自动在后面添加)}光标还在前面。不知到是这个吗?
cmdblock
帖子: 307
注册时间: 2008-12-01 7:52
来自: 蜀山

Re: emacs中怎么实现括号匹配

#8

帖子 cmdblock » 2009-02-03 5:29

谢谢楼上各位,搞定了
回复