我设置了所有376个Vim选项,但我仍然是个傻瓜。
I set all 376 Vim options and I'm still a fool

原始链接: https://evanhahn.com/i-set-all-376-vim-options-and-im-still-a-fool/

## Vim精通的无尽追求 受到2012年与一位精通Vim用户谦逊相遇的启发,作者踏上了为期13年的Vim精通之旅。尽管取得了显著进步,并达到了一种编码感觉更接近思维速度的程度,但仍然存在挥之不去的笨拙——意外的命令和低效的按键仍然困扰着他们的工作流程。 为了实现真正的流畅性,作者承担起了配置Vim所有376个选项的雄心壮志。深入研究包括广泛的研究、查阅文档、在线论坛,甚至Vim的源代码。这个过程揭示了关于Vim内部运作的惊人细节——从文件写入的复杂性、条件选项设置到像双字母输入法这样的晦涩功能。 虽然这项练习极大地提高了理解和技能,并突出了Vim和Neovim之间的差异,但作者最终意识到完美的精通可能无法实现。尽管拥有近2900行的配置文件,偶尔的错误仍然存在。然而,这种认识却令人感到安慰——它时刻提醒着人们,学习是一个持续的过程。

一篇名为“我设置了 Vim 的所有 376 个选项,但我仍然是个笨蛋”的博文引发了 Hacker News 的讨论,揭示了一种普遍情绪:即使经过大量自定义,Vim 仍然可能显得笨拙且容易误操作。 用户分享了诸如无意中将整个缓冲区转换为小写(由涉及 'guG' 的序列触发)以及由于肌肉记忆而非理解而意外执行非预期操作的经历。一些人承认使用了几十年预制的 `.vimrc` 文件,但并未完全理解它们,但发现它们完全可用。 对话涉及对“Vim 流利度”的追求——即无错误、优化的按键操作——一位评论员认为这是一个不切实际的目标。最终,该帖子突出了用户与 Vim 之间复杂的关系,在它的强大功能与可能令人沮丧的错误之间取得平衡。一位用户甚至分享了他的 `.vimrc` 文件供他人尝试。
相关文章

原文

I set all of Vim’s configuration options. I still feel far from mastery.

First impressions of Vim: wow

I first saw someone use Vim during an internship in 2012.

I had been coding for many years and I fancied myself pretty good at shortcuts, but I was quickly humbled. I watched in awe as experienced users zipped around the code. A single keystroke could move the cursor halfway across the file to exactly the right spot. Code was ripped apart and reshaped like putty.

Wow,” I thought to myself, and probably said out loud.

13 years later, still clumsy

I vowed to master this editor but I was slow. When I wasn’t accidentally opening some unknown menu, I was taking an uneconomical path through the code. I pressed j twenty times instead of running 20j, or manually deleted code inside parenthesis instead of running di(. Sometimes I’d open another text editor to give my mind a break from all the key bindings!

Fast-forward to 2025. After tons of practice, I felt much more capable. Code did feel more like putty. I was working closer to the speed of thought. I could get code where I wanted much more quickly. 13 years of practice paid off!

But Vim still felt clumsy. I was still accidentally opening menus I didn’t recognize. I would do silly things like converting the whole file to lowercase, or trigger some scary error message. “Surely I shouldn’t be making these mistakes,” I thought. What could be done to finally master this editor?

My goal: set every Vim option

That desire for expertise led me on a quest to set all of Vim’s options. I would make an informed decision about all 376 of Vim’s settings and drop them in my .vimrc. In other words, I wanted to 100% Vim.

Surely, setting every Vim option would make me the fluent expert I wanted to be…right?

I pored over every single Vim option and made a decision. What did the option do, and what did I want it to be set to? My goal was to be thorough; leave no stone unturned. I only set the option after I understood it.

Eventually, after countless hours, I had done it. I had set every single Vim option.

I learned a lot…

This exercise taught me plenty about day-to-day usage and the editor’s inner workings. I spent a lot of time with the documentation, Vim’s source code, and online forums.

Here’s a grab bag of things I learned:

  • How to use external commands. I didn’t realize I could send text from a Vim buffer to an external command, and vice-versa. Now I can write regular programs that operate on stdin. For example, I now frequently use a program to remove “smart quotes”, which I call without leaving the editor. See :help filter and :help write_c for details.

  • Vim’s docs are mixed. I frequently ran the :help command for something, read the docs, and came away clueless. Thanks to the great people of the internet for so many great explanations! One of the flags stumped me so much that I had to ask my own question on Vi Stack Exchange because nobody had really documented it before.

  • How Vim writes files. When you run :w, it’s just saving the file—how hard could it be? Turns out, it’s complicated! If you’re overwriting a file, Vim (by default) creates a backup of the old version, then overwrites it with the new version. This can help avoid data loss in some situations. But there’s a lot of complexity here: in the fate of that backup file after a successful write, in how the backup switcharoo happens, and where the backup is saved. This is probably irrelevant for most people, but I had to understand the details in order to set every option.

  • The command-line window—which I’d always open by accident—is super useful. The cedit option taught me about the command-line window. I frequently opened this by running q: instead of :q, and didn’t know what I had done. Now I know: a useful way to search and edit the history of previous commands and searches. For example, if I run some long command and make a typo, I can open the command-line window and fix the error using regular Vim keybindings.

  • Digraphs are an obscure feature for typing obscure characters. For example, you can enter “½” in Insert mode with CTRL-K 1 2. There’s a big list in :digraphs. I don’t use this much, except for typing fractions, but I use this more than I thought I would.

  • How to set options conditionally. I knew about regular if conditionals with things like if has('nvim'). But I didn’t know that you could set a Vim option only if it’s supported with code like if exists('+option').

  • Vim and Neovim have more differences than I thought. Among the many changes, I was pleased to learn that pasting is smoother in Neovim, that Q repeats the last recorded macro, it makes running arbitrary code safer, and has a much nicer default color scheme.

  • Vim used to have a different name. Today, “Vim” stands for “Vi IMproved”, an old Unix editor from the 1970s. But it was originally called Vi IMitation!

This is just a sample of my many discoveries. For more, see my heavily-annotated init.vim.

…but I’m still not fluent

As of this writing, my configuration file is nearly 2900 lines long.

This exercise was fun. It also taught me a lot about the editor I use every day. I definitely feel more skilled!

Yet the feeling of awkwardness remains. Even after ~14 years, I still accidentally open the command-line window all the time. I mess up filtering commands, or get lost in the jumplist. I still sometimes press k ten times instead of running 10k.

I discovered one thing about myself. The feeling of true Vim fluency—one where every keystroke is exact, I never make mistakes, and I’m exploiting every obscure feature—is a fantasy, at least for me. That’s a comforting constant in this topsy-turvy life: I’ll always have more to learn about Vim.

Click here to see the finished product.

联系我们 contact @ memedata.com