LinuxGem
此处为老的 LinuxGem,新版 LinuxGem 请移步 www.linuxgem.org

在 Vim 中实现括号自动补全

galeki posted @ 2007年10月03日 14:36 in 文档编辑与排版 with tags 自动补全 vim , 6749 阅读

流行的 IDE 的编辑器,诸如 Eclipse,都提供了括号自动补全的功能,相当的方便。可惜 Vim 默认情况下并没有提供这样的功能,那就只有自己来写了。

将下面的代码加入到 ~/.vimrc 中,重启 Vim,即可:

:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap < <><ESC>i
:inoremap > <c-r>=ClosePair('>')<CR>

function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
这样,写代码的时候不再担心会丢掉右边的括号了,尤其是函数嵌套的时候

转自: http://blog.linuxgem.org/liulang/show/262.html

&#27969;&#28010; 说:
2007年10月04日 16:55 hia,hia,hia~~~
momoc 说:
2007年10月13日 07:56 good ,i loooooooooooooove you
hzht 说:
2007年12月15日 19:04 这功能太帅了
Border 说:
2008年3月30日 06:44 cooool。。。
UMAIR 说:
2021年2月23日 15:04

Glad that I came herehttps://www.signnow.com/ask/what-is-the-difference-between-a-signature-stamp-and-an-electronic-signatureand invested my time at right place. Here I was able to get my hands on one of the best service I have ever used. Highly recommended.

daniyalabbas212@gami 说:
2021年5月04日 08:46

Karnataka board will release the 2nd PUC result 2021 one month after the conclusion of examinations. Students can check their Karnataka 2nd PUC result 2021 on the board's official results website - karresults.nic.in or from the board's official website - pue.kar.nic.in by providing their "Registration Number".karresults.nic.in PUC Result 2021Students can also make use of the direct link given on this page to download their PUC results 2021.

hkseo 说:
2023年8月30日 22:00

I exactly got what you mean, thanks for posting. And, I am too much happy to find this website on the world of Google. Properti Jual Beli Tanah Listing

hkseo 说:
2023年8月30日 23:57

You make so many great points here that I read your article a couple of times. Your views are in accordance with my own for the most part. This is great content for your readers. Pannello LED

hkseo 说:
2023年9月02日 21:32

i am always looking for some free stuffs over the internet. there are also some companies which gives free samples. Teatime Results

hkseo 说:
2023年11月22日 14:50

It is truly a well-researched content and excellent wording. I got so engaged in this material that I couldn’t wait reading. I am impressed with your work and skill. Thanks. Altamiraweb

hkseo 说:
2023年11月26日 17:21

I admire what you have done here. I like the part where you say you are doing this to give back but I would assume by all the comments that this is working for you as well. SEO優化

naeemkhatri 说:
2023年12月06日 15:30

Great content material and great layout. Your website deserves all of the positive feedback it’s been getting. okeplay777

seo 说:
2023年12月08日 17:29 Remarkable article, it is particularly useful! I quietly began in this, and I'm becoming more acquainted with it better! Delights, keep doing more and extra impressive! Avaliador premiado
seo 说:
2023年12月10日 20:50

I just found this blog and have high hopes for it to continue. Keep up the great work, its hard to find good ones. I have added to my favorites. Thank You. jonitogel

seo 说:
2023年12月11日 15:18

I felt very happy while reading this site. This was really very informative site for me. I really liked it. This was really a cordial post. Thanks a lot!. jpslot

seo 说:
2023年12月11日 15:30

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often. jutawanbet

seo 说:
2023年12月11日 15:34

Super-Duper site! I am Loving it!! Will come back again, Im taking your feed also, Thanks. latoto

seo 说:
2023年12月11日 20:12

Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work! linetogel

seo 说:
2023年12月12日 15:39

thanks for this usefull article, waiting for this article like this again. mariatogel

seo 说:
2023年12月12日 15:57

I have read your blog it is very helpful for me. I want to say thanks to you. I have bookmark your site for future updates. nanastoto

hkseo 说:
2023年12月13日 21:39

Your article has piqued a lot of positive interest. I can see why since you have done such a good job of making it interesting. Coffee shop canggu

seo 说:
2023年12月14日 16:52

This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses. <a href="https://www.youtube.com/watch?v=lDrtHzEgAYw">Jogo do Tigre</a>

seo 说:
2023年12月14日 16:52 This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses. Jogo do Tigre
sophia 说:
2023年12月14日 18:28 Hi there! Nice stuff, do keep me posted when you post again something like this! Canggu instagram cafe
sophia 说:
2023年12月14日 18:28 Hi there! Nice stuff, do keep me posted when you post again something like this! Canggu instagram cafe
seo 说:
2023年12月15日 21:15

This is a truly good site post. Not too many people would actually, the way you just did. I am really impressed that there is so much information about this subject that have been uncovered and you’ve done your best, with so much class. If wanted to know more about green smoke reviews, than by all means come in and check our stuff. FORTUNE TIGER

hkseo 说:
2023年12月18日 22:18

I went over this website and I believe you have a lot of wonderful information, saved to my bookmarks festtagssaison

MOIZ 说:
2023年12月20日 20:49

Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon! GTA 6 trailer breakdown

hkseo 说:
2023年12月24日 18:14

I wish more authors of this type of content would take the time you did to research and write so well. I am very impressed with your vision and insight. Hamraaz login

hkseo 说:
2023年12月25日 21:27

Hey There. I found your blog using msn. This is a very well written article. I’ll be sure to bookmark it and come back to read more of your useful info. Thanks for the post. I’ll definitely return. snokido

sophia 说:
2023年12月31日 02:51

Thanks for the nice blog. It was very useful for me. I'm happy I found this blog. Thank you for sharing with us,I too always learn something new from your post. Hi 88

hkseo 说:
2024年1月01日 18:29 It’s appropriate time to make some plans for the future and it is time to be happy. I have read this post and if I could I wish to suggest you few interesting things or advice. Perhaps you could write next articles referring to this article. I desire to read even more things about it! Spotiflyer
victor 说:
2024年1月04日 14:47 Youre so cool! I dont suppose Ive read anything similar to this prior to. So nice to find somebody with original thoughts on this subject. realy appreciate beginning this up. this excellent website are some things that is required on-line, an individual after a little originality. helpful job for bringing new things towards web! master slot gacor
seo 说:
2024年1月05日 19:27

Thanks so much for this information. I have to let you know I concur on several of the points you make here and others may require some further review, but I can see your viewpoint. Jogo do Tigre

sophia 说:
2024年1月19日 12:37

No doubt this is an excellent post I got a lot of knowledge after reading good luck. Theme of blog is excellent there is almost everything to read, Brilliant post. ufa 2023 ทางเข้า

sophia 说:
2024年1月19日 17:12

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. ufabet เว็บตรง ทางเข้า

sophia 说:
2024年1月20日 19:20

Nice blog and absolutely outstanding. You can do something much better but i still say this perfect.Keep trying for the best. Great whip N20

hkseo 说:
2024年1月21日 03:52

There is so much in this article that I would never have thought of on my own. Your content gives readers things to think about in an interesting way. Thank you for your clear information. www.riseeducationfund.org

sophia 说:
2024年1月21日 13:06

I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much. ketone sensor

hkseo 说:
2024年1月21日 20:39

I admire what you have done here. I like the part where you say you are doing this to give back but I would assume by all the comments that this is working for you as well. POS Inventory Software

hkseo 说:
2024年1月22日 18:06

Some truly wonderful work on behalf of the owner of this internet site , perfectly great articles . Fast gas 640g cylinder

hkseo 说:
2024年1月25日 18:33

I admire what you have done here. I like the part where you say you are doing this to give back but I would assume by all the comments that this is working for you as well. Android Developer

hkseo 说:
2024年1月31日 01:17

Thanks for your post. I’ve been thinking about writing a very comparable post over the last couple of weeks, I’ll probably keep it short and sweet and link to this instead if thats cool. Thanks. sakti88

sophia 说:
2024年1月31日 20:45

Hi there! Nice stuff, do keep me posted when you post again something like this! dana89.shop

sophia 说:
2024年2月02日 02:10

I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much. https://www.egymoe.com/pages/1xbet-free-bet-promo-code.html

seo 说:
2024年2月05日 16:40

Good post but I was wondering if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit further. Appreciate it! tubidy music download

seo 说:
2024年2月07日 16:36

Good post but I was wondering if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit further. Appreciate it! fc augsburg vereinsprofil

seo 说:
2024年2月08日 16:06

Thank you a bunch for sharing this with all of us you actually realize what you are talking about! Bookmarked. Please also seek advice from my site =). We could have a hyperlink change contract between us! chartlog

seo 说:
2024年2月10日 14:51 Cool stuff you have got and you keep update all of us. royalqq login
seo 说:
2024年2月11日 19:00

Thank you a bunch for sharing this with all of us you actually realize what you are talking about! Bookmarked. Please also seek advice from my site =). We could have a hyperlink change contract between us! real madrid vereinsprofil

mubashir 说:
2024年2月15日 00:50

Cool you inscribe, the info is really salubrious further fascinating, I'll give you a connect to my scene. profile-backlinks


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter