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

ToggleWord -- 在 Vim 中迅速切换关键字

galeki posted @ 2008年7月26日 00:26 in 文档编辑与排版 with tags vim , 4686 阅读

true 和 false 这两个关键字对程序员来说再熟悉不过了,如果你经常写程序,肯定碰到过这种情况,例如:

你要调用一个函数,其中有一些参数都是布尔值:

somefun ( a, b, true, false );

你想尝试下不同的布尔值,对函数的运行结果有什么影响,只好不停的把参数从 true 到 false 改来改去,虽然在 Vim 中有 cw 之类的快捷键,但是还是很麻烦。

ToggleWord 这个 Vim 扩展就是帮你摆脱这种烦恼的,他可以让你在关键字之间方便的切换,比如:

true => flase

yes => no

up => down

left => right

if => elseif => endif

monday => tuesday => ...  => sunday

january => february => december

.....

只需在命令模式下,将光标移动到单词上,然后输入 :ToggleWord

当然输入这么长一串命令太麻烦了,你可以在 .vimrc 中定义一个快捷键,比如 t :

nmap t :ToggleWord<CR>

这样只要按一下 t,就可以自由切换了~

除此之外,你还可以增加想要的关键字,比如在 Python 中,条件判断为 if ... elif ... else,那么在 .vimrc 中增加:

let g:toggle_words_dict = {'python': [['if', 'elif', 'else']]}

就搞定了~

ToggleWord 的下载地址:http://www.vim.org/scripts/script.php?script_id=1676

Gentle 说:
2008年7月26日 03:49 真不错,确实很方便。
princelai 说:
2008年7月26日 07:07 留名,以后也许用的到
wzhy 说:
2008年7月28日 16:59 不错! 您介绍的有关vim的文章都很有用~谢谢~
wocher 说:
2022年5月25日 19:33

Updates are delivered in our Discord server dedicated for customers and we offer support for everyone in case tutorials are not enough. We also try to provide updates in a timely manner. logitech

Click here 说:
2022年8月28日 14:13

For my part, the particular was presented an employment which is non secular enlargement. alongnovember.com

DDD 说:
2022年8月29日 18:50

How is it that simply anybody can write a website and acquire as widespread as this? Its not like youve said something incredibly spectacular –more like youve painted a reasonably picture over a difficulty that you simply recognize nothing concerning I don’t want to sound mean, here. but do you really suppose that you can escape with adding some pretty pictures and not really say anything?baddiebossbeauty.net

sghsesf 说:
2022年8月29日 22:57

I just like the helpful info you provide for your articles. I will bookmark your blog and check again here frequently. I¡¯m somewhat sure I¡¯ll learn lots of new stuff right right here! Good luck for the following! <a href="http://annoying4vein.com/">annoying4vein.com</a>

sghsesf 说:
2022年8月29日 22:58

I just like the helpful info you provide for your articles. I will bookmark your blog and check again here frequently. I¡¯m somewhat sure I¡¯ll learn lots of new stuff right right here! Good luck for the following! annoying4vein.com

sghsesf 说:
2022年8月29日 23:14

I like what you guys are up also. Such clever work and reporting! Carry on the excellent works guys I have incorporated you guys to my blogroll. I think it will improve the value of my website rentacar kosovo annoying4vein.com

jacvk22 说:
2022年8月30日 00:35

Awesome article! I want people to know just how good this information is in your article. It’s interesting, compelling content. Your views are much like my own concerning this subject. billharrell.com

DDD 说:
2022年9月01日 22:28

i always syndicate feeds on my subcribers and of course feedburner is definitely a great help,. charleshinspections.com

sghsesf 说:
2022年9月05日 21:16

I always visit your blog everyday to read new topics.”`;”; colorfulcapsulewardrobe.com

HASNA 说:
2022年9月06日 17:49

After examine a number of of the blog posts on your web site now, and I really like your manner of blogging. I bookmarked it to my bookmark web site record and can be checking again soon. Pls try my website online as well and let me know what you think. katstransport.com

sghsesf 说:
2022年9月06日 18:16

Hello There. I found your blog using msn. This is a very well written article. I will be sure to bookmark it and return to read more of your useful info. Thanks for the post. I’ll certainly comeback. javaairdesign.com

DDD 说:
2022年9月07日 15:14

Wonderful work! This is the type of information that should be shared around the internet. Shame on Google for not positioning this post higher! Come on over and visit my web site . Thanks =) ldepropertyconferences.com

rehman 说:
2022年9月07日 22:53

I am really inspired with your writing talent well with the layout to your weblog. Is this a paid topic or did you modify it your self? Anyway stay up the excellent high quality writing, it’s rare to peer a great blog like this one nowadays. picocreativo.com

HASNA 说:
2022年9月18日 21:53

To begin with, you’ll find that that you’re enclosed from free of cost content material; the fact is, this site is all the uk’s greatest cost-free articles and reviews company as well as by ” shopping “, you’ll certainly realize why this really is true. schwarzes-zelt.com

HASNA 说:
2022年9月21日 18:52

The Aaronson Law Firm is situated in Longwood, Florida, and they've been doing business since 2005, assisting customers with escaping their timeshare responsibilities. Resort Release

MAHMISHAL 说:
2022年9月29日 14:24

Rapidly this kind of fantastic web site will surely irrefutably often be well-known amongst many creating any website people, due to the fact thorough articles along with testimonies. wildroserenfaire.com

rehman 说:
2022年9月29日 19:55

This really is additionally an excellent publish that we truly loved reading through. It's not daily which i possess the likelihood to determine some thing. wol-gaming.com

asass 说:
2022年9月29日 20:04 Nice blog and absolutely outstanding. You can do something much better but i still say this perfect.Keep trying for the best. workable2swim.com
MAHMISHAL 说:
2022年10月12日 13:54

Wow that was odd. I just wrote an incredibly long comment but after I clicked submit my comment didn’t show up. Duch Œwiêty Grrrr… well I’m not writing all that over again. Anyways, just wanted to say fantastic blog! <a href="https://data-encoder.io/how-to-bypass-360-total-security-video-2/">bypass 360 Total Security</a>

MAHMISHAL 说:
2022年10月12日 13:54

Wow that was odd. I just wrote an incredibly long comment but after I clicked submit my comment didn’t show up. Duch Œwiêty Grrrr… well I’m not writing all that over again. Anyways, just wanted to say fantastic blog! bypass 360 Total Security

DDD 说:
2022年10月13日 17:32

Generally I try and get my mix of Vitamin E from pills. While I’d really like to through a fantastic meal plan it can be rather hard to at times. Vintage cars


登录 *


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