Emacsist RSS --- If never, make it ever: C-h C-h

Spacemacs: A Vimmer's Emacs Prerequisites

5675

这里 查看更多 Emacs 相关推荐文章最新 Emacs 圈的动态. 欢迎关注微信公众账号: Emacsist

Hick 叽喳:

    我对 Vim 或者说 Emacs 中用 Vim 风格一直有些敬畏, 也不排斥尝试.  这位哥写的文章的不错---不过也是比较常见的因为先熟 Vim 再转 Emacs 才喜欢 evil/spacemacs 风格的.  

In a previous post I explained why Vim and Sublime Text ultimately disappointed me; in this one, I’m going to describe how I finally found at least temporary respite in Emacs and what it took to get me there.

Hick 叽喳:

     作者个人的编辑器之争我也有点评式翻译:  http://emacsist.com/10108  ,  对我之前的认识有一定补充, 虽然我也有一些补充, 综合判断还是比较相信作者的认知的.

I had a rocky start with Emacs. Actually I had about four of them. There was never any question that I was going to use Evil-mode, Emacs’s vi emulation layer. I understand that it arose from the ashes of several previous such efforts to become one of the most complete vi emulations available for any text editor besides ones that derive from vi itself.

Hick 叽喳:

     作者又开始提他四次惨痛的"开始"玩 Emacs 的历程, 嘿嘿

Coming from Sublime Text’s deeply inadequate or flawed vi emulation packages, Evil was a revelation. With very few exceptions, it really is just like using Vim. It’s all that other crap that Emacs does that I had to make sense of somehow and that tripped me up the first several times I made a serious attempt at learning it.

Hick 叽喳:

     sublime 的 Vim 模拟器的不如 Emacs 我觉得是编辑器底层 api 能力的原因.

One of the popular jokes about Emacs is that it stands for “Escape Meta Alt Control Shift”, a jab at the countless arcane key chords that you’re expected to use to invoke its mind-boggling array of features. Almost immediately, I decided that finding a way to avoid those chords in favor of using Vim-style key sequences mostly without modifiers would be a prerequisite for my using Emacs full time.

To make this distinction a bit clearer: The key command to quit Emacs is C-x C-c, which means “control-x followed by control-c”. Take a look at this table of Emacs commands and you’ll get an idea why there’s a whole flavor of RSI named for Emacs and why I wanted to just swap those key bindings out from the get go. What I really wanted was to bulk-convert all of Emacs’s RSI-inducing chords to key sequences like ones using Vim’s leader keys: for example, the aforementioned C-x C-c might become \xc or something.

Hick 叽喳:

    还是有些同意说一些 Emacs 的组合键操作可以简化的, 其实我个人把这个任务交给 smex 和 hydra , 他们挺适合解除传统 Emacs 需要组合 ctrl alt shift 等的麻烦.

My first pass at this had me using god-mode to take a bunch of the modifiers out of Emacs commands. But I had some trouble getting god-mode to play nice with Evil, even when I used the charmingly titled evil-god-state to tie the two together. I suspect that this was actually a perfectly viable way to achieve what I wanted and some misunderstanding on my part prevented me from getting it working; I was too new to Emacs and tried to deviate from its norms too much too fast. If you use evil-mode and god-mode together I’d be interested to hear how it works for you.

Hick 叽喳:

    作者 Emacs 还不是那么熟---可能至少相比 Vim 来说.  在他看来同风格的 evil-mode 和 god-mode 一起工作还是有些费劲.

By this point I’d dipped my toes into Emacs enough to have a handle on Emacs Lisp, the (far superior to Vimscript) language used to do all of Emacs’s extensive customization. I’d tried the “build up an Emacs config from scratch” thing a couple times and ended up frustrated with it due to its being a total crap shoot whether any given plugin would play nice with evil-mode. So when I came across a starter kit whose tagline is “The best editor is neither Emacs nor Vim, it’s Emacs and Vim!”, and which purports to be “first intended to be used by Vim users who want to go to the next level by using Emacs”, I was 100% ready to jump feet-first into an unabashedly Evil-centric starter kit.

Hick 叽喳:

    这个说法挺喜欢, 最好的编辑器既不是 Emacs 也不是 Vim , 是 Emacs 和 Vim ,  Emacs 已经开始施吸心大法于 Vim 了, 嘿嘿

Spacemacs

Here’s the link to that starter kit, which is called Spacemacs. It takes Vim’s leader key idea and kicks it into overdrive with the help of a plugin that provides the same functionality in Evil, setting the leader key to space (whence the starter kit’s name) and using it to replace a whole bunch of Emacs chords with modifier-free key sequences.

Hick 叽喳:

     我也是第一次比较认真的了解 spacemacs, 原来这名字源自使用 space 空格键做命令前导按键啊  :)   足够大气! 大多数键盘布局都是空格键最大, 最大的键最常用, 挺合理的!

This approach is pretty similar to the one I had in mind with evil-god-state, though it doesn’t automatically translate Emacs bindings like I’d hoped. But that turned out not to be as big a problem as I thought: Emacs does so much that I don’t really want to have it all at my fingertips. Manually setting up my bindings helps me compartmentalize, adding a few at a time and assimilating them while I note what continues to be most frictionful so I can try to ameliorate it in my next round of bindings. And Spacemacs sets up a ton of bindings for you, using a sort of “namespaced” hierarchy that allows all those bindings to avoid stepping on each other’s toes while also encouraging mnemonics and working well with a nice feature that aids discoverability.

Hick 叽喳:

    作者的想法其实挺好, 如果能简单的用 space 取代修饰符, 会更好沿袭常规 Emacs 的习惯---不用记那么多了, 就取代最常用的 ctrl 就好. 其他的可以另想办法. 这里的介绍因为不懂可能有误:  spacemacs 绑定了一系列的功能键, 引入了 namespace 类似概念避免不同情况下按键的冲突? 

That’s not the only way that Spacemacs is smartly designed. Its overall architecture is such that it’s (relatively) welcoming for the newbie but has a framework for sensible extensibility when you get further into it. I’ll explain some of the things that were most helpful to me in making Emacs with Spacemacs my full-time editor:

Hick 叽喳:

    下面才是比较有含金量的介绍作者怎么玩转 spacemacs 的了: 

Getting Started with Spacemacs

Memorizing these bindings will enable you to get around in Spacemacs, if occasionally somewhat clumsily. They were my bread and butter before I started to do my own configuration. I’m only mentioning Emacs-specific bindings here; note that most of the basic functionality of Vim also works well in Spacemacs, like invoking Ex mode with : and using it to do things like save and open files, split windows, etc.

Hick 叽喳:

    看到这里打鼓了, 太照顾 Vim 用户了啊,  Vim 里的 : 也来了... 
  • <SPC> f f: Mnemonic “find file”. Triggers the functionido-find-file, which lets you use Ido to navigate your filesystem to find a file to open, starting from the directory of the current buffer. A crash course: <Tab> will autocomplete. Deleting when there’s no text after a slash will go up a directory. ~/ will take you to your home directly from anywhere. // will take you to your filesystem root from anywhere. <Return> will go into the selected directory or open the selected file.

Hick 叽喳:

    基本打开文件的体验, 这讲的也真够初级的, 主要是咱因为体验过 ido-find-file 相关功能.  似乎现在 helm 风格比 ido 还流行,  helm 已经形成一大体系.
  • <SPC> b s: Mnemonic “buffer switch”. Opens a Helm minibuffer with a list of all your open buffers as well as recently visited ones. The biggest thing to know about Helm is that <Tab> doesn’t autocomplete. Instead, Helm filters the list as you type and you just select the best match using <Return>. It does a great deal of more fancy stuff too, but for switching buffers, that will probably suffice.

Hick 叽喳:

    切换 buffer 的方式,  看到这里看是有点像上手了, 这样确实方便啊 
  • <SPC> :: no mnemonic, but think of this as the Emacs equivalent of using : to bring up the Ex command line in Vim. It brings up a Helm buffer that you can use to find an interactive Emacs function to run. There are about thirty million of these and I’m not going to really mention any here, but if you’re reading something about Emacs and you see some hyphen-separated name like emacs-do-thing it’s probably a function you can call using <SPC> :. If you’re already familiar with Emacs (or looking at non-Spacemacs-centric Emacs docs), this is the equivalent of the ubiquitous M-x binding, but better because of Helm’s fuzzy matching.

Hick 叽喳:

    `<SPC> :` 这个在情理之中, 就是常规 Emacs 的 M-x 的替换
  • <SPC> h d f: Mnemonic “help define function”. Man, so I complained about Vim and Sublime Text in my last post here. Sublime Text’s documentation is mediocre at best whereas Vim’s is very good and thorough, but even after working with Vim’s generally excellent documentation, Emacs’s is a revelation. There’s a reason that the blurb on the official Emacs web page describes it as “the extensible, customizable, self-documenting real-time display editor.” Being able to use this binding, in conjunction with Helm for fuzzy matching, to quickly find any function defined anywhere in Emacs including custom ones, and get generally very useful information about how to use it… it’s amazing how much of a difference it makes in learning how to use Emacs productively. Seriously, learn to love this binding. It even reports any custom bindings that are defined to invoke the function that you’re getting help on.

Hick 叽喳:

    这个老实说有点长啊, 倒是 Emacs 原生的 C-h 系列的延续, 这系列都挺实用, 下面说的也是一个系的.
  • <SPC> h d k: Mnemonic “help define key”. Another example of Emacs’s excellent built-in help, this binding prompts for more keys and then tells you what they do. If you accidentally hit some key or something doesn’t do what you expect, this binding will tell you what it did. It’s slightly less useful than the previous binding in my experience, but still very useful.

  • <SPC>: As in, hit the space bar and then just wait. A feature (alluded to above) called guide-key will kick in and list the keys you can use to continue issuing a command, with a short description of what each does. At first most of them will start with “group”; this is the “namespacing” I was referring to earlier. For example, the previous two bindings in this list are in the “help-describe” subgroup of the “helm/help/highlight” top-level group. This hierarchical organization of bindings makes it reasonably plausible that you can discover the binding for a task you want using guide-key alone.

Hick 叽喳:

    发现没体验过就是不知道, 才想起, 真正的空格键没看出来用什么输的... 

Those bindings, along with Spacemacs’s very good documentation of its own, should be enough to get you started on getting used to the brave new world of Emacs: if you’re a Vim user already, you’re probably familiar with the process of starting with a small set of commands and gradually incorporating new ones into your workflow as you learn where your friction areas are. You’ll have to go through that again with Spacemacs, but having a huge chunk of Vim’s functionality already available makes the process a lot smoother. I know, for example, that there’s a Spacemacs binding for saving a buffer, but I don’t yet know what it is because I always just use the Vim-style :w instead.

Hick 叽喳:

    所幸 spacemacs 的文档不错

Hopefully that’s enough for you to get started using Spacemacs! It’s a really nice piece of work and it seems to be deservedly catching on like wildfire, so if you’re familiar with Vim and anything I’ve said here sounds appealing, you should give it a try.

原文出处: valrus
原文地址: http://ian.mccowan.space/2015/04/07/Spacemacs/
原文时间: 2015-04-11 16:10
本文地址: http://emacsist.com/10107
整理时间: 2015-04-11 20:11

本文由 Hick 整理,转载请保留以上信息;
COPYLEFTThe articles on this site come from Internet, thanks to all the original authors.
      If anything about COPYRIGHT, or LEFT, please contact Emacsist at gmail dot com .