首页 > 初级, 学习Emacs > 钗黛双收:若你也同Vim难割舍,却又看Emacs情切切

钗黛双收:若你也同Vim难割舍,却又看Emacs情切切

2011年2月21日 ahei 发表评论 阅读评论

作者: C. Minos Niu

1 钗黛双收:若你也同Vim难割舍,却又看Emacs情切切 (引子)

这篇文章分享我的一些经历,写给和我一样对娇小的Vim难以割舍,又在抱上Emacs这个大家闺秀以后死活不愿意撒手的朋友们。

如果你不知道什么是“编辑器圣战”,那不妨百度Google一下,总之是自从开辟鸿蒙以来,就有两个以伴君左右为己任的贤内助(Vim编辑器和Emacs编辑器)在互掐。由于两位佳人的理念差别之大,加上各自阵营之间的鸿沟之深,使得先贤先哲基本上都会在这两个阵营里面挑一个来站队。

网络普及以后,凡有帖子对Vim和Emacs这两大编辑器作出比较,大都有成为必删贴的潜质。原因很好理解,无论是谁看了红楼梦,很难不对宝钗黛玉这两位产生点好恶,此后但凡有人起了个头要对钗黛二人做点比较,那后面的楼经常能盖歪到变成地域攻击男女对骂。在技术论坛里,这样折腾不被河蟹掉才怪。更有甚者,如果谁在讨论编程的时候问了一句“需要做xx开发,用什么工具比较好?”随后也常常演变成Vim对Emacs的钗黛攻伐,最后一样飞沙走石天昏地暗。这就说明,选择Vim或Emacs已经不仅取决于我们在编辑文本时的好恶,而已经上升到干活的人怎么挑工具,过日子的人怎么选老婆这种哲学高度的问题。

我一向觉得,成事者不可狭于器。所以选工具时候没必要为了工具本身而搞个粉丝团,而是就着菜选刀,比着孩子找媳妇,揽来什么样的活计使什么样的家伙。若以我的经验来概括,Vim的犀利在于键盘操作,练家子爽得是用最少的手指运动完成编辑;Emacs的NB在于自定义功能,高手们都有一套独门不传的脚本,所以Emacser满手都是绝活,靠这些绝活上天入地无所不能。注意,这里要讲的既不是比出高下,也不是评测完了各打五十大板和稀泥。而是说说提炼出两个工具的精华加以“双修”,用足够务实的态度来平息争端。

先说点野史当引子。大学里面从来都不缺废寝忘食折腾电脑的兄弟。他们当中应该有不少动机都和当年的我一样:希望被人误认为是电脑高手。这种伪装有一个巨大的好处——没准能多给女生重装几次Windows。

不过,重装Windows的高手们为了哥们面前神侃时不露怯,基本上还要玩过点一般人玩不转的GNU/Linux。我想,工科男生们的Linux情结,怕有不少是因此而生。然而凡事不易,玩Linux是要自己改配置文件的,这倒是根硬骨头。

骨头硬的重要原因么,编辑器不顺手。在那没有Ubuntu的年代里,谁要是折腾几个晚上装好一台Linux的小白肉鸡,会发现可用的编辑器只有Vim。这玩意和Windows的记事本、Dos的edit相比简直就是个怪胎。这一点想必Emacser也深有感触吧,进到Vim里面若是不懂命令,肯定是在一阵滴滴滴过后连一个字母都敲不到屏幕上。

当装机圣手们的情商智商普遍被挑战了以后,大致是迅速分化为两派——啃骨头派和换骨头派。啃派如我,继续捏着脚适应Vim的小鞋;换派不用说也能猜到,自然是鞋也不要就转身踏入了Emacs阵营——在那边起码知道怎么打字。

按说天朝对于西方的编辑器圣战应该是打酱油的态度,但实际情况是,啃派和换派俨然形成了自己的圣战副本。

2 钗黛双收:若你也同Vim难割舍,却又看Emacs情切切 (Vim篇)

那段时间作为Vim啃派,我和许多队友一样有个自恃甚高的理由来支持Vim:编辑时击键次数最少。但是私下里想想,这个理由多少有些往脸上贴金。

其实Vim用多了以后,并不只是臣服于高效,更多的是手指头上瘾。用我们运动神经控制的行话来说,Vimer的大脑已经被触觉感官和运动神经一起绑架了。那些用手指肌肉记住的命令,执行起来基本不怎么过脑子。而且一旦命令执行成功,脑中还会生成大量“多巴胺”以示奖励。

看过《生活大爆炸》的应该都有印象,Leslie夜晚敲Leonard的门,只不过是为了缓解自己多巴胺分泌过剩……所以Vimer生存在这样一种状态下:只要不用hjkl这种奇怪的击键来移动光标,就会流着眼泪打着呵欠思念不已;反过来一旦用上了hjkl,那就等于在重复《生活大爆炸》里面那种神经感受。你说像在嗑药也行。

Vim瘾上身之后必然产生一个愿望,那就是以嗑药的方式,额,以Vim的方式来操作所有的软件。很不幸,持有这种愿望的啃派们几乎都会发现,就算骨头啃下来了,它也是打狗不能的。

首先,想替小家碧玉Vim扩展出十八般武艺,这个基本上真的很难。难的根本原因是Vim给用户预留的扩展能力先天不足。Vim的设计者压根没考虑把它做成一个放之四海而皆准的巨无霸,所以Vim打从娘胎里出来时在胃口上就不太给力。

既然此路不通,那只好另求变法。为了让啃骨头时攒下的功夫不至于荒废,能不能对其他软件的键盘操作方式动动刀,让它们起码和Vim敲起来差不多?这也很难。虽然软件的操作方式通常可以自定义,但自定义的途径大多是修改键位绑定。这种途径有个与生俱来的短板,它并不能区分出Vim里的“命令模式”和“编辑模式”。不巧的是,这种模式区分恰恰是Vim操作方式的核心。说到底,要想在其他软件里面模拟Vim,基本上等同于重新开发一遍。所以这么多年我只见到Firefox的Vimperator插件做到了在宿主软件(Firefox)中对Vim几乎完全模拟(当然有若干Chrome和Visual Studio的插件也可以部分模拟Vim,但个人意见它们的“类Vim”程度都还差得远)。而且现如今浏览器混战成这个样子,哪个插件都恨不得全机种通吃,但Vimperator却丝毫没有往其他浏览器上移植的意思。这也从某种意义上证明模拟Vim不是件容易的事。

折腾这一大圈,发现一个无奈而不争的事实:Vim由于太过婉约,终归没有可能升任管家。意思就是不可能让所有软件用起来都像是在操作Vim一样。所以我只好把Vim养在硬盘里没事绣绣花打打字,而让管家这个肥缺虚位以待。转机出现在某一天,那天后知后觉的看到了一个老掉牙的故事,福特汽车的创始人亨利福特说,在汽车发明以前如果你问消费者想要什么,他们会说想要跑得更快的马。苹果的乔大爷也总是拿这个故事来说事,意思就是我苹果这才叫真正抓住了问题的核心——(出门人)要的未必是马,而是快;(iPhone粉丝)要的未必是多任务,而是上网的时候还能听个小曲。

这个产品设计的例子启发在哪?在我看来,当一个愿望被挖出来以后,不见得需要照本宣科才能满足这个愿望。如果换个解法还能满足,那说明你hit the button了。换句话说,当引子出来后,故事往下怎么续是文无定法的。

回到眼前这个事上,啃骨头派的愿望是用Vim的操作方式来一统江湖,不过果真非得“用Vim的方式”吗?恐怕重点还是“一桶浆糊”吧。玩电脑的都是懒人,懒人有个癖好叫“Don’t repeat yourself”,如果谁弄出一套比较高效的键盘操作方式,能让我学一次以后就不用再学了,那就暂时去tnnd的门派。

用个比方来做总结,Vim实在是精致独特得有点像个林妹妹。但谁要是希望家里也有个林妹妹,光把自家丫头照着绣像打扮打扮是不行的,必须从零开始养成一个。而且就算真能养出来个“天上掉下来”一般的可人儿,管家婆的位置仍然没她的份。

3 钗黛双收:若你也同Vim难割舍,却又看Emacs情切切 (Emacs篇,结局)

一旦破除了心理障碍,在Vim之外寻求“管家婆”的人选也就不算作倒戈了。电影《社交网络 The Social Network》里面有这样一个镜头,在扎克伯格同学悲愤不已,要把女生头像和畜生猪狗一起打分时,他来了句“有必要重启Emacs,修改代码”。这个杜撰的场景告诉我们,IT巨星再怎么胸怀壮志,始于足下的不过是手指另一端连着的编辑器。当geek们叫嚣要在世界上留下一个痕迹(make a dent in the universe)的时候,手里常常拎着一把折凳,折凳背面写着——Emacs。

我用Emacs的最初经历和很多Emacser可能稍有不同,但想必都是从跌跌撞撞的青涩回忆开始,最后让Emacs成了一个“全能伴侣”而浑不自知。博士期间,我主要用的工具是Matlab和Visual Studio,这两个工具自带的编辑器与Vim相比都是小白,属于要严重影响心情和智商的那一种。但是,无论是Matlab还是Visual Studio,它们自带的小白编辑器都只有Emacs模式,没有Vim模式(原因如前所述,模拟Vim很难)。这好歹是聊胜于无,而且既然Emacs用户能从中受益,我凭什么不试试。不得不说,如果目的是用统一的键盘操作方式来使用各种软件,Emacs的领地实在是太广了。除了Matlab和Visual Studio这种内部伪装出一部分Emacs的快捷键以外,非常值得一提的是还有一个日本人写的软件Xkeymacs。这玩意干脆把Windows的快捷键全部接管了,直接让所有Windows软件用起来都跟Emacs一个感觉。所以如果你像我一样不得不在Word里面写文稿的话(Neuroscience领域很多教授不是工程背景,只用Word),就知道Xkeymacs让你舒服在哪里了。难怪一个老外在评价的时候说Xkeymacs这个李鬼软件好到让人“心中不安(disturbingly good)”。

搞笑的是,我是直到在Xkeymacs这种替身杂牌军中用熟了Emacs快捷键之后,才开始慢慢尝试Emacs本尊。开始时先把Emacs配成了Matlab IDE,用它搞定了整个博士课题的数据处理,后来又陆续使用了cedet,etag,yasnippet这些扩展,再加上秒杀笔记、日程、Wiki、表格、博文的org-mode……算是把我这个入门级的Hacker武装到了神经末梢。虽然我不像其他Emacser一般可以骄傲的说自己“活在Emacs里”,但若说最近重要的工作成果都是在Emacs上创作出来,这话却是一点也不假。到了这个时候,Emacs已经完全升任管家婆,堪比宝钗再世。如果谁也有似曾相识的回忆,想必可以深刻体会到这样一个比较狗血的剧情,若宝玉能和Emacs一样的宝钗姐姐继续好下去,那完全有希望弄出个明朝版的百度,东山再起。

可是作为Vim的死忠,对于手掌几乎不挪窝的向往,那是消失不掉的。

坊间对于Emacs有一条经典评语,说Emacs是“伪装成编辑器的操作系统”。言下之意就是Emacs什么都能做(包括经典的煮咖啡)。既然Emacs都神通成瑞士军铲了,何不另辟蹊径,用军铲削出一个Vim呢?西方到底是计算机技术的始作俑者,对Emacs这种恐龙级工具而言,能被摆弄的四十年来都被摆弄一遍了。所以只要放狗一搜,就会发现Emacs居然自带Vim模拟,名叫viper-mode。而且为了让viper-mode更像Vim,还有第三方开发了一套叫做vimpulse的增强包。也就是说,只要下载一个vimpulse.el脚本,丢到Emacs的启动路径中,它就可以几乎完美的模拟Vim!

写到这里,折腾的两条主线已在此收敛,引发“圣战”的两大神器也已经被和谐进了同一个窗口。再往下就该写些技术笔记和心得回顾,不在这篇的目的之内,因此应该歇笔了。如果要问我到底是在用Emacs还是在用Vim,或问哪一方赢得了我的选择?我也不知道。每当想写点程序、调段脚本、码点wiki、记记笔记的时候,我用的都是Emacs提供的外加自己用eLisp扩展出的功能;但是当码出来的东西让人不爽,需要浏览、修改和整理的时候,手指弹出的又都是Vim的命令。

回到最开始说的,若是你用电脑要做的事和我差不多,而且也觉得用键盘工作是很爽的一件事,那就应该试试Emacs+Vim双修。道理很简单,假如你是包工头,而Emacs和Vim是两位身手不凡的应聘者,那么当然应该是两个都收了而后“择其善者而从之”,这才是对自家生意负责。不过对选编辑器如选媳妇的人来说,两大神器双修在手,尽在此一句:

惘于环肥燕瘦,颦怅蹙茫

哪比举钗盈黛,牵黄擎苍?

分享家:Addthis中国
GD Star Rating
loading...
钗黛双收:若你也同Vim难割舍,却又看Emacs情切切, 9.2 out of 10 based on 240 ratings 该日志未加标签。
分类: 初级, 学习Emacs
  1. 2016年4月7日05:42 | #1

    Wow, this piece of writing 钗黛双收:若你也同Vim难割舍,却又看Emacs情切切 | Emacs中文网 is pleasant, my younger sister is analyzing such things, thus I am going to tell her.

    [回复]

  2. 2016年4月7日05:42 | #2

    I am in fact thankful to the owner of this website 钗黛双收:若你也同Vim难割舍,却又看Emacs情切切 | Emacs中文网 who has shared this wonderful piece of writing at here.

    [回复]

  3. 2016年4月7日05:51 | #3

    – Cal became the latest Pac-12 team to blow out Oregon State, beating the Beavers 54-24. It was the seventh consecutive loss for OSU, which is winless in the Pac-12. michael kors outlet Atlantic City currently has eight casinos. r michael kors outlet online
    Fine Minerals International ShowWhen: 10 a. michael kors outlet He wrestled for Iowa State, which had won five of the last 10 NCAA championships, and was to college wrestling what Alabama is to college football.
    Tears for Fears does not perform in the U.S. very often, but judging by the crowd reaction and how much fun the band looked like they had on stage, they will certainly be back. michael kors bags Or for a more relaxing tour, hop on a horse-drawn carriage, or visit the nearby sealarium where you are guaranteed a good view. w coach outlet store online
    “The Republican base doesn’t want a liberal justice, and they’re completely fine with the court having a vacancy for as long as is required to get a justice they believe is right,” Fagen said michael kors outlet SPECIAL ADMONITION FOR YAHOO SERVICES RELATING TO FINANCIAL MATTERS If you intend to create or join any service, receive or request any news, messages, alerts or other information from the Yahoo Services concerning companies, stock quotes, investments or securities, please read the above Sections 19 and 20 again.
    s No Red Wing made the top 10. michael kors outlet online “It’s imperative now more than ever that we bring Arkansas’ failed experiment with Obamacare’s Medicaid expansion to an end,” said David Ray, state director for the national group. http://www.louisvuitton-outlet.us.org
    “Not in this specific way,” Hopkirk said louis vuitton bags Allonzo Trier led Arizona offensively with 18 points while Parker Jackson-Cartwright had 16 and Ryan Anderson added 11 points and 12 rebounds. http://www.coachhandbagsdeal.us.com
    34.1 — Percent shooting for the Pistons, a season-low over the first 14 games. Detroit finished 31 of 91 and 6-of-28 from the 3-point line. michael kors handbags Julius Caesar, 7:30 p. a michael kors handbags
    I was there. louis vuitton outlet online “The pitch to Peralta was probably off the plate a little bit,” Shields said.
    Marty Richman. coach outlet They tossed out a clunker against the Los Angeles Lakers, losing 11295 on Sunday while shooting a seasonworst 13 percent from threepoint range.
    Like Amazon, it could tout the games as a selling point to get more cellular customers to switch over. http://www.raybansunglasses.name He is extremely playful and likes to spend his days playing with paper balls, fuzzy mice or a feather taped to a piece of string.
    Holy Cross is the 20th team since 1985 to make the NCAA Tournament with a losing record, per STATS LLC. ray ban outlet Junior offensive tackle Dalton Wagner said he was looking forward to his visit to Arkansas over the weekend, and he did not leave disappointed.
    l They make me feel welcome,” adds 18-year-old Will Byrd http://www.coachhandbags.me Low or negative inflation is considered a sign of economic weakness and raises fears that low inflation expectations will become ingrained in wage and price agreements.
    We need to ask them to do what they are good at and that is not planning or problem solving. coach outlet The number of days needed for the minor roadwork has been a point of debate. v ray ban sunglasses
    Follow us on ?to learn more. michael kors outlet online They also hostbeginning-to-advanced comedy workshops, private coaching and teenimprov classes at the theater and at Jester’z Performing Artstraining center in Mesa.
    x “I woke up this morning and said dang, this is senior week, like this is crazy,” Adams said. “I’ve just enjoyed my time here, meeting new friends and enjoying this experience. I’m just very thankful for it.” http://www.raybanoutlet.name Four schools in two school districts participated in the program during its first year in Arkansas in the 20142015 school year, and the 70 schools in the program in the current school year are in 22 school districts, said Kimberly Friedman, a spokesman for the state Department of Education. c
    Contact:Julie HolsingerLife Happens703-888-4446jholsinger(at)lifehappens(dot)org cheap louis vuitton bags Getting ready to ask city voters for a sales tax increase, Tucson’s mayor made “investing in Tucson” the theme of his fifth State of the City speech. cheap michael kors bags
    – Northern Iowa is coached by Mark Farley, 128-60 in 14 seasons as coach. Farley’s teams are 47-8 in November. cheap jordan shoes Metro on 03/03/2016 t coach online store
    Consumer analysis is structured by age bracket and household income, further broken out by gender. cheap air jordans Doubles Parikh/Grygutys, SAL, d.
    The engine has an active fuel management system that switches to a four-cylinder drive mode to save gas when it doesn’t need power. louis vuitton outlet online Arkansas America — is the biggest pageant I’ve ever won. i ray ban sunglasses
    You half expect the soloist to match energeticwits with the music, but Boyd played it fairly low key. michael kors handbags Ripley loves attention and loves petting he’d let you rub his head, neck, and ears all day long.

    [回复]

  4. 2016年4月7日11:30 | #4

    D A G Real Estate Development Inc. to Donna Anne Granatelli, 85 North Main St., $220,000. michael kors outlet Each made a case for being the best candidate to defeat GOP frontrunner Donald Trump in a November matchup. w http://www.coachstoresonline.com
    The Ducks whittled it to 67-64 after two free throws by Jacinta Vandenberg with 2:16 to play but free throws allowed the Wildcats to wrap it up http://www.coachoutlet.cc The now-frail Feit, who uses a walker, was arrested Feb.
    “We’ve made strides, so I’m happy with this team.” http://www.louisvuittonhandbagsbuy.co.uk The Zoppé Family Circus, a family tradition since 1842, invites you into a 500 seat tent for a show to remember this holiday season. w coach outlet
    I then contacted Alitalia and purchased comfort seats for both me and my wife at a cost of $95 each. oakley sunglasses While not intentional, none of them were built with fine art in mind.
    g The lakes and ponds got so high, the dams couldn’t take it anymore, Shirer said. Speaking of the rains, he said, “They’ve wrecked the dams; they’ve ruined all of the bridges. This one lake has already gone from topping over this bridge to where it’s emptying out.” michael kors outlet online Boyer said the difference between Saturday’s victory and Wednesday’s was defense. o.storeonlinecc.com
    Williams made the threat while an acquaintance beat the bodyguard with a baseball bat and choked him, apparently because the bodyguard didn’t engage in criminal activity the comedian wanted him to, according to a statement from Hall County sheriff’s Deputy Nicole Bailes coach outlet store online To an extent, that dual focus parallels the movie industry itself. http://www.michaelkorshandbagsup.us.com
    The transfer meant he had to sit out almost his entire first year at UMass as well. During those days when he could practice but couldn’t play, Vatrano worked to improve his defensive game and his quickness, always with a pro career in mind. coach outlet online Actual results may differ materially from Allergan s current expectations depending upon a number of factors affecting Allergan s business. r louis vuitton handbags
    Key questions answered in the report include http://www.coachoutletstores.net.co “We hadn’t played a lot of them until lately.
    With Klauer Park, there would be two official dog parks in Hollister, though residents tend to bring their dogs to other parks, too. coach outlet online AFC’s 10kilowatt unit underwent “engineering tweaks” that allows the cell to generate 11.
    “Society is going to tell you how important it is to hate your body,” Ncube said. http://www.coachoutletstoreonline.me The Los Angeles Times’ game story discussed how critical the foul imbalance was to the Bruins.
    Sonoita Vineyards, 290 Elgin-Canelo Road, Elgin. oakley glasses Roberts is described as standing 6 feet 1 inch tall and weighing 190 pounds.
    z Even the cooks and waitstaff stayed on michael kors outlet With plenty of money to spend, Raiders GM Reggie McKenzie is looking to help Oakland end a 13-year run of not making the playoffs.
    The Pullin’ for a Cure Benefit Truck Pull is coming at 11 a. michael kors outlet This community is going to be populated primarily by retired people, not commuters. c cheap jordan shoes
    Chris Johnson, ARI, vs. michael kors outlet Much of the talk last week—discussions were much briefer Tuesday night—revolved around concerns about the section in the proposed contract on staffing.
    z Whole books have been written on this subject, so don’t ask Truth Squad to settle this in a paragraph. Of more interest to Truth Squad is Sanders’s statement connecting trade policy to Flint’s economic spiral in particular. michael kors outlet Anyone who moved into those areas would be required to move back downtown insteadand they couldn’t own a car either since in Downtown Utopia everyone would be required to walk or bike to any place they might go. i
    Nearly 7 million Americans have failed to make a payment on their student loan debts in the past year. michael kors bags Remove stems; finely chop enough stems to measure 1/3 cup. michael kors outlet
    The , a coalition of environmental conservationists, serves as a liaison at the Capitol for Michigan residents on issues of energy and sustainability. michael kors outlet The official said that another 12 Islamic State fighters had been killed in the strike, which hit the town of Shadadi. v coach outlet store online
    “I’m not interested in re-litigating something that happened when I was 19. michael kors handbags We got lucky.
    Continuing on Oregon’s Most Endangered Places List from previous years are: michael kors outlet online If you disagree with these religious groups on a particular moral issue, they complain, they threaten you with a loss of money or votes or both. f michael kors bags
    That did not happen on Thursday night coach outlet online On Saturday, Groth and John Peers are scheduled to play doubles against Bob and Mike Bryan, although that lineup can be changed on the morning of the match, along with reverse singles on Sunday.

    [回复]

  5. 2017年6月15日08:03 | #5

    motilium to buy
    buy motilium boots
    motilium domperidone 10mg
    buy motilium

    [回复]

  6. 2017年6月20日04:02 | #6

    I have been exploring for a little bit for any high quality articles or blog posts on this sort of house .
    Exploring in Yahoo I finally stumbled upon this site.
    Reading this info So i am glad to exhibit that I
    have an incredibly excellent uncanny feeling I came upon just what I needed.
    I so much indubitably will make certain to do not put
    out of your mind this site and give it a
    glance regularly.

    [回复]

评论分页
1 ... 8 9 10 41806
  1. 2011年2月21日11:46 | #1
  2. 2012年2月3日20:28 | #2
  3. 2012年2月3日21:46 | #3
  4. 2012年9月11日21:16 | #4
  5. 2013年12月2日14:44 | #5
  6. 2013年12月2日15:39 | #6
  7. 2013年12月10日15:54 | #7
:wink: :-| :-x :twisted: :) 8-O :( :roll: :-P :oops: :-o :mrgreen: :lol: :idea: :-D :evil: :cry: 8) :arrow: :-? :?: :!: