Second Brain: Crafted, Curated, Connected, Compounded on 10月02日 21:06
Vim编辑器为何仍受欢迎
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

Vim编辑器因其独特的语法和快捷操作方式,即使对新手有一定学习曲线,依然吸引着许多用户。通过几个核心命令(如复制y、删除d、粘贴p、修改c)结合多种移动操作(如数字、{ }),用户能高效编辑文本。Vim的语法类似自然语言,通过动词(如yank、delete)+宾语(如register)+状语(如prefix)的组合,实现丰富的编辑功能。此外,Vim支持多种模式(正常、插入、视觉、命令),让编辑流程更清晰。尽管存在学习门槛,但Vim的效率优势使其在写作、编程等领域持续流行,且可通过插件在其他编辑器中应用其快捷操作。

📚 Vim编辑器通过简单的核心命令(如复制y、删除d、粘贴p、修改c)结合丰富的移动操作(如数字、{ }),实现高效文本编辑,其语法类似自然语言,通过动词+宾语+状语组合实现复杂功能。

🌐 Vim的编辑模式(正常、插入、视觉、命令)分别适用于阅读、输入、选择和执行命令,让编辑流程更清晰,且可通过插件在其他编辑器(如VS Code、Sublime)中应用其快捷操作。

⚡ Vim的快捷操作(如jk上下、hl左右)基于人体工学设计,符合右手的自然键位分布,一旦熟练即可大幅提升编辑速度,且其设计理念符合'快速思考'原则,优于传统光标编辑器。

📖 Vim的编辑技巧不仅适用于编程,在写作领域同样高效,尤其适合处理博客或书籍等长文本,通过精确的段落和行级操作,实现类似外科手术般的编辑精度。

🔄 Vim的学习曲线虽陡,但一旦掌握即可形成肌肉记忆,并通过Vim Golf、Vimtutor等练习工具循序渐进,长期使用后你会发现其效率优势远超传统编辑器,值得投入时间学习。

Why are there many users (and many new ones) still using Vim or Neovim, you might ask?

It’s mainly for vim language/motions. Many believe, me included that you need to know 1000 shortcuts. But when I realized that Vim has a language that works like grammar, things changed. I noticed that I only have to remember a couple of modes (Copying (or yanking) in Vim with y, deleting with d, pasting with p, changing with c) and shortcuts, which I can then combine. This made me want to try it, and I didn’t regret it.

It is surprising to me; I use it even more for writing text than coding, which I think I will use it for. However, the efficiency of editing text with the precision of a surgeon is even more helpful when I edit and rearrange my blogs or books.

# Vim Language

Vim has a terrific language or grammar behind its shortcuts. Instead, remember a thousand shortcuts; you can learn a couple and combine them. These are sometimes called the Vim language or Vim motions for moving around. This has nothing to do with the editor yet; they are universal and available in other editors as well.

For example, VSVim for VSCode, IdeaVim for the JetBrains products, Vintage Mode for Sublime, and so on. But there are also Browser extensions like Vimium or Firenvim, and even Gmail adapted some of its shortcuts for navigation (j, k for moving, g for jumping).

Everyone who types on a computer eight hours a day should learn the Vim language. Yes, it’s hard in the beginning, but that’s everything new and different. getting better every day and having more fun coding or writing should motivate enough. The excuse of being too busy to learn while doing what you always did does not count.


Are you too busy to improve | Image from steenschledermann

Typical hotkey without vim-motions

Typical hotkey with none-vim setup. They are useful, but very limited as I explain in my Vim write-up, making the case why I have chosen vim years bahttps://www.ssp.sh/brain/img_Vim%20Language%20_and%20Motions__1747031168795.webp1747031168795.webp">
Source Boilerplate see Writing is Thinking

# The Grammar

As grammar has verbs, subjects, and objects, so does the Vim language. The grammar has different verbs to begin with. Copying (or yanking) in Vim with y, deleting with d, pasting with p, changing with c.

For example, the easiest shortcut is copying a line with yy. In this case, yank is the verb and the second y is a synonym for y_. The y is doubled up to make it easier to type since a joint operation.

Next, we can add movements. Each verb takes a subject to their movements. There are lots of movements (more in the next chapter); the easiest is with numbers. E.g. to copy three lines, you add three in front, such as 3yy. You can do that with all verbs, e.g., deleting three lines 3dd. Another would be { and } to move to the beginning or end of the paragraph, respectively.

In addition to verbs and subjects, the Vim language also has objects. E.g., we can save text into different clipboards (called a register in Vim) with "ay. Here, we copy it into register a, which would be the object. We can paste it again by doing the same but using the verb paste instead of yank "ap.

If you will, there are even adjectives and adverbs with prefixes. Usually, you use a verb and an object. But instead of going down three lines with 3J, which joins the following three lines. You could add d5}, which means “delete from the current line through the end of the fifth paragraph down from here.”,

For me, the most considerable magic and myth about Vim. All of the vim language is how you navigate end edit text, and it still has nothing to do with the editor. Sure Vim was the one that introduced and perfectionized them, but as listed above, you can get them anywhere else. This goes deep into the Vim language, yet we still need to touch the editor. This is important to know.

I hope you start seeing the power of such a pattern. With a couple of verbs and objects, you can already know hundreds of combinations without memorizing them. You can see a video on Mastering the Vim Language on the Vim language or read a full plea for the Vim language on a terrific StackOverflow comment.

# Vim Motions

As touched in the Vim language. Vim motions are how you navigate, whether you navigate to the end of the word or back to the start of the document; these are all motions.

These are the first thing you start learning (and hating) when you start learning. It’s extra hard to know initially, but something you want everywhere when you get used to it. Instead of using arrow keys, Vim uses jk to move down and up and hl to move left and right. The main idea is to use the keys that your right hand naturally rests on. You do not need to move any of your hands or even fingers for navigation. Again, this seems like a small thing, but once learned, you know why everyone is telling you that.

Some common ones are:

123456
h,j,k,l - left, down, up, rightw,W - to start of next word or WORDb,B - to start of previous word or WORDe,E - to end of word or WORD$   - to end of line^   - to start of line

You find the most important ones to starhttps://www.ssp.sh/brain/Pasted%20image%2020230101200117.png/Pasted%20image%2020230101200117.png">

Vim Command Cheat Sheet from Cloud Guru

# Modes (normal, insert, visual, command)

Modes are what get you confused at the beginning. When you launch Vim, you are not typing what you click on your keyboard as you are not in the “insert” mode that you know. Instead, the normal mode you are in lets you do the commands explained in the above Vim language and motions.

Vim is the only editor that optimizes editing text instead of wrihttps://www.ssp.shhttps://www.ssp.sh/brain/Pasted%20image%2020230102191556.pngp>
Three modes illustrated (escape mode being the command mode) | Image from Geekforgeeks

That’s another reason Vim makes you so efficient: you have different modes for each phase of your task—normal mode for reading code and navigating quickly. Insert mode when you want to add some code or text. Visual mode is unique, the same as highlighting text with the mouse, but with the above Vim motions. The command mode is the powerhouse, where you can type Linux commands such as formatting a JSON file with :%!jq (whereas jq is a command line tool installed on your machine) and execute them within Vim. As well as Vim commands such as :sort for sorting your file.

I could go on here, but I want to dive into the editor itself now and explore why I learned it initially and how to get started if you’re going to. In case you want to read more, I wrote a full article on Why Vim Is More than Just an Editor and also about My vim-verse: The Backbone of My Workflow.

# Vim motions for none-technical people?

I got asked if vim motions worth for none-technical people, especially with a none-admin account at work? Below is my answer I gave.

First, I would focus on the “vim motions” (the shortcuts) rather than the editor itself. You might even be able to use these shortcuts at work, as there are now Vim extensions for almost everything. Unfortunately, not yet for MS Word or other similar programs.

What you can certainly do is write Markdown locally (which works on any operating system) and find an editor where you can install vim extensions (Obsidian, VS Code, Sublime, Notepad++, etc.). There are many tools that you can launch directly from a file (portable version).

Whether it’s worth it is difficult to say. If you write a lot as an author, and this is your profession, then definitely yes. I actually need it more as an author than for programming. It’s absolutely the best way to write or edit text. You could also use an online tool like HackMD, which also has vim motions that you can activate.

Switching between your personal computer and work computer shouldn’t be an issue, because you’ll never forget normal writing (without vim), and whenever vim motions are available, you’ll just be much faster. The only thing is that it will take you longer to learn the shortcuts and the vim language, and for these to become muscle memory.

Another important question is the keyboard layout. Some time ago, I switched to the US layout because vim motions are best designed for it. But if you don’t program, this doesn’t play such a big role, and you probably will have fewer problems if you stay with the Swiss layout.

I would just try it out. There are many cool exercises like Vim Golf or Vimtutor. It will be challenging at the beginning. And you’ll quickly notice whether it doesn’t suit you at all, or if it might be something for you. After 2-3 weeks, I started to enjoy it, and it became really “fun” to edit something with vim, even if the task itself would otherwise be very boring.

# Good Design Matters

As the vim motions has been here for many years, and integrated in any editor, any tool, it’s passed the Lindy Effect, and we can say, it has very ergonomic design.

Like professional StarCraft players don’t use the mouse for not its speed, but also they can just use their muscle memory, the same vim users use vim motions because of its speed, and Thinking in the thought of speed. Interesting how it connects to Thinking, Fast and Slow (Dhttps://www.ssp.shhttps://www.ssp.sh/brain/img_Vim%20Language%20_and%20Motions__1747032636401.webp
Source by Boilerplate YT Video

More on this very interesting topic also by Boilerplate YT on his video about Writing at the Speed of Thought.

# Further Reads

Article I wrote related to vim motions, and how I use them:


Origin: Why Vim Is More than Just an Editor
References: My Vim Cheatsheet
Created 2023-01-16

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Vim 编辑器 效率 快捷键 编程 写作 编辑技巧
相关文章