强迫自己掌握 vi 的最佳方法是什么?

发布于 2024-07-04 17:43:53 字数 863 浏览 7 评论 0原文

不久前,我读了viemu的创建者的一篇文章,澄清了许多关于 vi 的误解,并解释了为什么它是一个好主意(以及为什么它在过去 30 多年里非常流行)。 同一个人还拥有一套很棒的图形备忘单,可以一次性教授一些基础知识。时间。

我相信。

事实上,过去两年我一直深信不疑。 但我还没有抽出时间强迫自己学习 vi 作为我的主要编辑器,学习曲线太高了。 当我开始工作时,可接受但即时的生产力(使用我当前的编辑器)到目前为止已经超过了进一步的巨大生产力(使用 vi)。

有人有什么好的建议可以帮助克服学习曲线吗? 它可以是直接的提示、其他教程或文章,等等。

编辑:请注意,我知道 vim/gVim奶油MacVim (等)vi 的变体。 我保留了关于 vi 的问题,以指代整个 vi 家族。 感谢所有精彩的答案。

更新(2009 年 4 月)

自去年 12 月以来,我一直在日常职业生活中使用 Vim(更准确地说,MacVim)。 我不会回去 :-)

祝大家在 Vim 掌握上好运。

A good while ago, I read an article by the creator of viemu, clearing up a lot of the misconceptions about vi, as well as explaining why it's a good idea (and why it's been very popular for the last 30 years+). The same guy also has a great set of graphical cheat sheets that teach the basics a few bits at a time.

I'm convinced.

I've been convinced for the past 2 years in fact. But I still really haven't gotten around to force myself to learn vi as my primary editor, the learning curve is just too high. When I get down to work, acceptable but immediate productivity (using my current editor) has so far won over tremendous productivity farther down the line (using vi).

Does anybody have any good tips to help get past the learning curve? It can be straight out tips, some other tutorial or article, whatever.

Edit: Note that I'm aware of the vim/gVim, Cream and MacVim (etc.) variants of vi. I kept my question about vi to refer to the vi family as a whole. Thanks for all the great answers.

Update (April 2009)

I've been using Vim (more precisely, MacVim) in my day to day professional life since last December. I'm not going back :-)

Good luck to everyone in their Vim mastery.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(30

七色彩虹 2024-07-11 17:43:54

我记得当我第一次开始学习 emacs 时,是在我已经非常熟悉 Vim 之后,我和你处于相同或相似的状态,我知道如何在另一个编辑器中完成很多工作,所以当我开始时使用 emacs 总是慢得令人痛苦。

然而,我认为你要做的只是吸收一点痛苦,并且总是,总是,总是确保你查找文档来做你知道你可以做的事情在以前的编辑器中执行的操作,例如移至行尾或选择文本区域。

如果您有当地的 vi 专家可以提问,或者如果您像我们公司一样,您可以推广结对编程,这也会有所帮助。 这样,当您尝试做一些应该很简单的事情时,您可以简单地询问某人,他们会向您展示如何操作,并且如果您定期使用编辑器几周,则不必询问更多然后几次,然后它就成为第二天性。

如果您没有任何本地资源,网上有大量书籍/教程/参考表应该能够回答您的大部分问题。

最终,学习 Vi 就像学习其他技能一样,没有灵丹妙药,您必须接受这样的事实:在一段时间内,您的工作效率将低于当前的编辑器。 只要不断告诉自己,“其他人已经能够学习 Vi,而我至少和他们一样聪明”(无论如何,这就是我告诉自己的:))

I remember when I first started learning emacs, it was after I was already very comfortable with Vim, and I was in the same or similar boat that you were, where I knew how to get a lot done in another editor, so as I started using emacs, it was always painfully slow.

However, I think what you'll have to do is just absorb a little bit of the pain, and always, always, ALWAYS make sure that you look up the documentation for doing something that you know you can do in your previous editor, such as moving to the end of a line, or selecting a region of text.

It also helps if you have a local vi-expert on hand that you can ask questions, or if you're like our company, you promote pair programming. That way when you're trying to do something that should be easy, you can simply ask someone, they'll show you how, and if you're using the editor regularly for a few weeks, you shouldn't have to ask more then a couple of times before it becomes second nature.

If you don't have any local resources, there are plenty of books/tutorials/reference sheets online that should be able to answer most of your questions.

Ultimately, learning Vi is like learning other skills, there's no silver bullet, and you'll have to accept that, for a while, you're going to be less productive in it then your current editor. Just keep telling yourself, "Other people have been able to learn Vi, and I'm at least as smart as them" (That's what I tell myself anyway :) )

半寸时光 2024-07-11 17:43:54

在您使用的所有平台上安装 gVim。

然后运行 ​​vimtutor(命令行中的 :help vimtutorvimtutor)。

观看以下讲座并遵循其中的建议:有效文本编辑的 7 个习惯 2.0

我说您肯定想开始使用它进行所有编辑。 如果你担心生产力下降,那么花一个周末来认真练习(我曾经这样做是为了从 qwerty 切换到德沃夏克,到周一我的生产力已经足够高,并且之后设法坚持下去)。

这是值得的,你不会回头!

Install gVim on all platforms you use.

Then run through the the vimtutor (:help vimtutor or vimtutor at the command line).

Watch the following lecture and follow its advice: 7 Habits For Effective Text Editing 2.0

I say you definitely want to start using it for all your editing. If you fear a loss of productivity then take a weekend to practice it solid (I once did this to switch to dvorak from qwerty and had my productivity high enough by Monday and managed to stick with it after).

It's worth the effort and you won't look back!

忆梦 2024-07-11 17:43:54

就我个人而言,我必须做的是确保我可以在多个应用程序中使用 Vim 键绑定(或者至少足够接近)。 每当我更换编辑器时,都必须完全改变编辑文本的方式,这使得 Vim 编辑风格很难记住。

就我而言,Viemu + vimperator 就达到了目的。

Personally, what I had to do was make sure that I could use the Vim key-bindings (or at least, close enough) in several applications. Having to completely switch how I edited text whenever I changed editors made it too hard to get the Vim editing style committed to muscle memory.

In my case, Viemu + vimperator did the trick.

寒尘 2024-07-11 17:43:54

我的第一条建议是:学会快速打字,而不需要看键盘。

如果您无法触摸打字并且总是在寻找冒号或 hjkl 或 :%s/foo/bar,那就别想了。 打字可能比使用鼠标更快,但如果您不是这种情况,vi 将无法工作。

但是,结合良好的打字技巧,ssh 和 screen 和 vi 将会很自然。

My number one suggestion: learn to type fast, without needing to look at the keyboard.

If you can't touch type and are always hunting-and-pecking for the colon or the hjkl or :%s/foo/bar, forget about it. Typing can be faster than using the mouse, but if that's not the case for you, vi's not going to work.

But combine good typing skills, ssh and screen and vi will be natural.

半岛未凉 2024-07-11 17:43:54

面对这样一个事实:它会立即造成性能损失。 当学习一个新工具时,你需要能够做一些你知道如何使用其他工具做的事情,这样问题就不是你的问题了。 使用新工具一段时间后,它就会消失,您将只关注根本问题。

对于像 vim 这样的东西(正如其他人所说,vim 远远优于 vi),定期重读和浏览文档非常重要。 如果没有它,该界面是完全无法发现的。 每次新阅读时,您都会看到一个功能,并说:“啊哈,这将解决我上周试图解决的这个问题”,并将其归档在您的大脑中。 与您遇到的现实问题相关的解决方案比随机的快捷方式更容易记住。

最后,您可以使用 vim 的一小部分功能,因此不要被所有的附加功能所淹没。 想想Word的所有功能,99%的人都用过吗?

Face the fact that it will create an immediate performance hit. When learning a new tool you need to be able to do something that you know how to do with other tools so the problem isn't your problem. After using the new tool a while it will disappear and you will be only focusing on the underlying problem.

With something like vim (as others have said, vim is vastly superior to vi) it is important to reread and browse the documentation periodically. The interface is completely undiscoverable without it. With each new reading you will see a feature and say, "ah ha, that would have solved this issue I was trying to figure out last week", and will file it away in your brain. Solutions connected to real-world problems that you've had are much easier for you to remember than random shortcuts.

In the end you can use vim with a fairly small subset of it's features, so don't be overwhelmed with all the bells and whistles. Think of all the features in Word, do 99% of the people use them?

薯片软お妹 2024-07-11 17:43:54

ESC gg=G 重新缩进代码和 :retab 将制表符转换为空格或空格转换为制表符是让我着迷于 vim 的原因。 所以实际上你不需要强迫使用它,你只需要学习它什么时候可以帮助你提高你的速度。

通过vimtutor

开始使用 vim 进行简单编辑,例如配置文件或 html。 根据需要学习命令。

在 google 上搜索一个好的 .vimrc,该文件由使用与您类似的工具链的人使用。 打开语法高亮。 找到一个漂亮的配色方案。

学习宏,因为 Vim 最适合自动化任务和代码片段插入,例如将几个单词格式化为复杂的 XML 标记或将 CSV 转换为 HTML 表。

ESC gg=G to reindent code and :retab to convert tabs to spaces or spaces to tabs was what hooked me to vim. So actually you don't need to be forced to use it, you just have to learn when it can help you increase your speed.

Go through vimtutor.

Start using vim for simple editing, like config files or html. Learn the commands as you need them.

Search google for a good .vimrc used by someone who uses a toolchain that resembles yours. Turn on syntax highlighting. Find a nice color scheme.

Learn macros because Vim is the best for automated tasks and snippet insertion, like formatting a few words into a complex XML tag or converting a CSV to an HTML table.

因为看清所以看轻 2024-07-11 17:43:54

您可能想从奶油开始。 Cream 将自己描述为 vim 的“现代配置”。 基本上,它是 vim 的一个特殊版本,在所有实际用途上,其外观和感觉与任何其他文本编辑器相似。 但是启用“专家模式”,您就拥有了 vim 的所有功能和行为。

因此,您可以开始使用 Cream 作为常规文本编辑器,然后尝试“专家模式”,直到您能够轻松地完全切换到 vim。

You might want to start out with Cream. Cream describes itself as "a modern configuration" of vim. Basically, it is a special version of vim which looks and feels like any other text editor for all practical purposes. But enable the "expert mode" and you have all the power and behavior of vim.

So you can start using Cream as a regular text editor and then experiment with the "expert mode" until you are comfortable enough to fully switch to vim.

小女人ら 2024-07-11 17:43:54

每次开始编辑时,您都可以使用原始的 Happy Hacker 键盘(无箭头键)之一,并将(无线)鼠标放在够不到的地方。

You could get your hands on one of the original Happy Hacker keyboards (no arrow keys) and place your (wireless) mouse out of reach each time you start editing.

漫漫岁月 2024-07-11 17:43:54

写出一大堆命令/快捷方式很容易,但如果不练习就很难记住它们。

一次专注于一个新命令。 当它变得自动时,比如使用一两周后,在你的保留曲目中添加另一个。

你将需要走很长的路才能在短期内完成某些事情——这些显然是新的学习捷径的机会。

根据我的经验,当我尝试不要一次承担太多事情时,事情会变得更容易。

It's easy to write out a big list of commands/shortcuts, but it's difficult to remember them all without practice.

Focus on one new command at a time. When it becomes automatic, say after using it for a week or two, add another to your repertoire.

You'll be taking the long way around to accomplish certain things in the short term - these are obvious opportunities for new shortcuts to learn.

In my experience it was easier when I tried not to take on too much at once.

白芷 2024-07-11 17:43:54

不使用X11

$ sudu rm /usr/local/bin/emacs

将您的登录 shell 更改为 vi

首先,强迫自己使用ed,那么vi会显得很奢侈吗?

bash 中使用 vi 键绑定?

刚开始一直使用 vi

在我看来,学习编辑器与学习语言并没有太大不同。 沉浸式效果最好。

我使用 vi 进行快速编辑,或者当我由于某种原因无法使用 X11 时,但我生活在 emacs 中。 真正强大的编辑器值得花时间去学习。

Don't use X11?

$ sudu rm /usr/local/bin/emacs

Change your login shell to vi?

First, force yourself to use ed, then vi will seem like a luxury?

Use the vi key bindings in bash?

Just start using vi all the time?

It seems to me that learning an editor isn't terribly different from learning a language. Immersion works best.

I use vi for really quick edits or when I can't use X11 for some reason, but I live in emacs. Really powerful editors are worth taking the time to learn.

临风闻羌笛 2024-07-11 17:43:54

我的建议是提出一些简单的程序并使用 VI 从头到尾编写它们。

很可能,您一开始会对学习曲线感到非常沮丧,从而无法强迫自己在工作或任何时间敏感的环境中使用它们。

我之前已经这样做过以熟悉环境/编辑器,并且效果很好。

如果您在想出要写的东西时遇到问题,我建议重做您在学校所做的项目(或您以前做过的任何其他项目)。 这种方法还有一个额外的好处,可以让您看到自己已经成为一名更好的开发人员。 :)

编辑:忘记提及您应该完全从控制台执行此操作,以避免任何使用鼠标的诱惑!

My recommendation is to come up with some simple programs and write them, start to finish, using VI.

Odds are, you will be too frustrated at first by the learning curve to force yourself to use them at work or in any time-sensitive environment.

I've done this before to get familiar with environments/editors, and it works pretty well.

If you are having problems coming up with things to write, I recommend redoing projects you did in school (or anything else that you've done previously). This method has the added bonus of letting you see how much of a better developer you have become. :)

Edit: forgot to mention that you should do this entirely from the console to avoid any temptation to use the mouse!

冷…雨湿花 2024-07-11 17:43:54

你应该从 vim (Vi IMproved) 开始,尤其是它的 GUI - gVim。 GUI 有菜单,在 Windows 上您可以使用复制、剪切和粘贴快捷方式,因此您可以立即替换记事本。 而且由于菜单显示了快捷方式(vim 命令),您可以学到很多东西。

您从一开始就应该做的另一件事是根据您的需要配置 vi。 例如,您可以将 vim 转换为 Python IDE。 通过这样做,您将没有理由使用其他编辑器,因为 vi 将为您提供所需的一切。

You should start with vim (Vi IMproved) and especially its GUI - gVim. The GUI has menus and on Windows you can use the copy, cut and paste shortcuts, so you can replace Notepad immediately. And since the menus display the shortcuts (vim commands) you could learn a lot.

Another thing that you should do from the beginning is to configure vi for your needs. For example, you can transform vim into a Python IDE. By doing this, you'll have no excuse for using another editor, because vi will offer you everything you need.

美男兮 2024-07-11 17:43:54

不要强迫自己。 通往主宰爱情的道路是。

force yourself not. the path to mastery love is.

泼猴你往哪里跑 2024-07-11 17:43:54

有两件事可以极大地提高你的 vi 技能:

  1. 练习、练习、练习
  2. Nethack

Two things that will greatly improve your vi skills:

  1. Practice, practice, practice
  2. Nethack
这样的小城市 2024-07-11 17:43:54

编辑:我已经创建了 在在线间隔重复网站 flashcarddb.com 上设置的抽认卡 ,如果您有兴趣...

  1. 使用间隔重复闪存卡程序,例如mnemosyne,< a href="http://www.supermemo.com/" rel="noreferrer">supermemo,或 anki 将学习和保留新命令融入您的日常生活中。 使用 vim 作为日常编辑器是不够的。 要掌握它,您必须将这些代码存储在头脑中,等待它们成为手头任务的理想解决方案的时候。
  2. 维护带有自定义的 .vimrc
  3. 编写或编辑 vim 插件

EDIT: I've created a flashcard set over at the online spaced repetition site flashcarddb.com, in case you're interested ...

  1. Use a spaced repetition flash card program such as mnemosyne, supermemo, or anki to incorporate learning and retaining new commands into your daily routine. It's not enough to be using vim as your daily editor. To master it, you have to be storing those codes in your head, laying in wait for the time when they're the ideal solution to the task at hand.
  2. Maintain a .vimrc with customizations
  3. Write or edit a vim plugin
阳光下的泡沫是彩色的 2024-07-11 17:43:54

我的建议:从小事做起。 首先记住一小组最有用的命令。 当我启动 vi 时,这些是我的前 10 个:

  • (Esc) 返回命令模式(最重要!)
  • a 在光标后添加文本
  • A 在当前行末尾添加文本
  • x 删除 1 个字符
  • dd 删除 1 行
  • R替换文本(覆盖)
  • u 撤消
  • :q! (Enter) 退出而不保存
  • :w (Enter) 保存
  • ZZ 保存并退出

仅使用这些命令即可完成许多基本编辑。 一旦你适应了,剩下的看起来就不那么困难了。

顺便说一句,我想补充一点,我曾经依赖 vi 作为我的主要文本编辑器,但现在只有在必要时才这样做。 就我而言,当我使用 Emacs 或 Visual Studio 等工具时,工作效率会更高(请注意:“就我而言”)。 尝试多种工具,然后选择最能帮助您提高工作效率的工具。 祝你好运!

My suggestion: start small. Just start by memorizing a small set of most useful commands. When I started vi, these were my top 10:

  • (Esc) to return to command mode (most important!)
  • a to add text after cursor
  • A to add text at end of current line
  • x to delete 1 character
  • dd to delete 1 line
  • R to replace text (overwrite)
  • u to undo
  • :q! (Enter) to quit without saving
  • :w (Enter) to save
  • ZZ to save and quit

A lot of basic editing can be done using only these commands. Once you get comfortable, the rest don't look too difficult.

BTW, I'd like to add that I used to rely on vi for my primary text editor, but now only if I have to. In my case, productivity is better when I use tools like Emacs or Visual Studio (please note: "in my case"). Try more than one tool and choose the one that helps your productivity the most. Good luck!

沧笙踏歌 2024-07-11 17:43:54

您寻求一些好的技巧来帮助克服 vi 文本编辑器的学习曲线。 之前的许多答案建议您不要使用其他编辑器。 我认为这是个好建议。 从图形化编辑器切换到 vi 需要改变思维方式。 它需要根据命令进行思考,而不是视觉变化。

多年来我只使用 vi,并且相信提高工作效率的唯一方法就是记住经常使用的命令。 我这样做的方法是列出最常见的键盘命令的简短列表。 我按功能对这些命令进行分组和颜色编码,即移动光标、编辑、搜索等。我很小心地只包含我不知道的最常用命令。 我们的想法是创建一个快速参考,这也有助于记忆——而不是取代可用的帮助屏幕。 然后我打印了这份清单,并将其贴在显示器后面的墙上,这样我就可以很容易地看到它。 (您提到的图形备忘单可能对某些人来说效果更好,但可能是比记忆工具更好的参考源。)

这是关键。当我熟悉其中一个命令时,我画了一个用铅笔划过它。 如果需要的话我仍然可以看到它,但这对我来说象征着我已经掌握了这个命令。 这给了我信心和动力,因为我可以看到定期的进步。 当我划掉大部分命令后,我将它们删除并添加了一些很少使用的命令。 我继续这个过程,直到我对 vi 的命令感到满意为止。 当我意识到我已经很长时间没有划掉任何命令,甚至没有查看列表时,我知道我已经达到了这一点。

几年前,我需要在 UNIX 平台上工作,其中 vi 是唯一可用的编辑器。 我买了一本关于 vi 的袖珍参考书,但很少使用。 我最终列出了清单并将其张贴在墙上,就像我第一次使用 vi 时所做的那样。 到第一周结束时,我已经感觉很舒服了,尽管我已经五年没有使用 vi 了。

You asked for good tips to help get past the learning curve on the vi text editor. Many of the previous answers suggest you use no other editors. I think that is good advice. Switching to vi from a more graphical editor requires a change in mindset. It requires thinking in terms of commands, rather than visual changes.

I used nothing but vi for many years and believe the only way you can be productive is to memorize the commands you regularly use. The way I did this was to make a short list of the most common keyboard commands. I grouped and color-coded these commands by function, i.e. Moving the Cursor, Editing, Searching, etc. I was careful to only include the most commonly used commands I did not know. The idea is to create a quick reference that is also an aid in memorization – not to replace the available help screens. Then I printed this list and taped it to the wall behind my monitor so I could see it easily. (The graphical cheat sheets you mentioned might work better for some, but are probably a better reference source than a memorization tool.)

Here's the key. As I became comfortable with one of the commands, I drew a line through it with a pencil. I could still see it if I needed it, but it was symbolic to me that I had mastered that command. That gave me confidence and motivation as I could see regular progress. Once I had most of them crossed off, I removed them and added some of the more rarely used commands. I continued this process until I was satisfied with my command of vi. I knew I had reached that point when I realized I had not crossed off any commands or even looked at the list in a long time.

A couple years ago I had need to work on a UNIX platform where vi was the only editor available. I bought a little pocket reference book on vi, but hardly used it. I ended up making lists and posting them on the wall as I did the first time I used vi. By the end of the first week, I was very comfortable even though it had been five years since I had used vi.

老街孤人 2024-07-11 17:43:54

听起来很傻,但是玩roguelike游戏(例如NethackAngband)是一种有趣的方式熟悉使用 h/j/k/l 键进行光标导航。

It sounds silly, but playing roguelike games (such as Nethack or Angband) is a fun way to get comfortable with using the h/j/k/l keys for cursor navigation.

夏了南城 2024-07-11 17:43:54

不久前我写了一篇使用 Vim 进行高效编辑的指南。 您可能会发现它很有帮助。

我会退一步问自己“为什么我想学习这个编辑器?是什么让我认为它会比我当前的文本编辑器更快或更好?” 然后学习那些将使 Vi(m) 对您不可或缺的功能。

例如,Vim 的 CTags 集成对我来说是完全不可或缺的。 我使用非常非常大的代码库,并且通过一次击键跳转到函数或类定义的能力(无论它位于哪个文件中)绝对是一个杀手级功能,没有这个功能我就很难工作。

使用 .vimrc 文件创建可自动执行常见任务的宏。

您的自动驾驶编辑器选择器将选择能够以最快的速度和最少的脑力劳动完成工作的编辑器。 一些准备工作将确保编辑器是 Vim。 :-)

I wrote a guide to efficient editing with Vim a while back. You may find it helpful.

I'd step back for a minute and ask yourself "why do I want to learn this editor? What makes me think it'll be faster or better than my current text editor?" Then learn those features that will make Vi(m) indispensable to you.

For instance, Vim's CTags integration is completely indispensable for me. I work with a very, very large codebase, and the ability to jump to a function or class definition in one keystroke (regardless of which file it's in) is an absolutely killer feature, one I have trouble working without.

Use your .vimrc file to make macros that automate common tasks.

Your autopilot editor-chooser will pick the editor that will get the job done quickest and with the least amount of mental effort. A little prep-work will ensure that editor is Vim. :-)

池予 2024-07-11 17:43:54

删除所有其他文本编辑器应用程序。

那么你就必须学习它。

delete all other text editor apps.

Then you will have to learn it.

街角迷惘 2024-07-11 17:43:54

强制自己的最简单方法可能就是从计算机中删除所有其他编辑器。 摆脱诱惑:)

The simplest way to force yourself might be just to remove all the other editors from your machine. Get rid of temptation :)

稳稳的幸福 2024-07-11 17:43:54

每次您执行复杂的编辑任务时,请不断想知道是否有更有效的方法来完成它。 大多数时候,当你可以用简单的术语描述它时(例如“交换文本段落”或“删除注释行中 X 字符后面的所有内容”),你只需在 vim 中敲击几下按键即可完成。

有一些非常有用的关键功能,您将永远不再使用。 我最喜欢的是:

  • 块选择 (Ctrl-V)
  • 宏录制 (q)
  • 虚拟编辑 (:set ve=all)
  • 正则表达式
  • 管道连接到外部 Unix 程序
  • 键映射
  • 自动完成(Cp、Cx Cp、Cx Cf)
  • 操作+动作组合(这非常强大)

询问其他程序员他们认为哪些功能最有用,并采用更适合您大脑的功能。 从其他人的 .vimrc 窃取想法(这是我的)

Every time you're doing a complex editing task, keep wondering if there is a more efficient way to do it. Most times, when it's something that you can describe in simple terms (like "swap paragraphs of text" or "delete everything after the X character in commented lines"), it's something you can do in just a couple of keystrokes in vim.

There are some key features that are extremely useful, and you'll end using all the time. The ones I love the most are:

  • Block selection (Ctrl-V)
  • Macro recording (q)
  • Virtual editing (:set ve=all)
  • Regular expressions
  • Piping to external Unix programs
  • Key mappings
  • Autocompletion (C-p, C-x C-p, C-x C-f)
  • The operation+movement combination (this is amazingly powerful)

Ask other programmers what features they find most useful and adopt the ones that fit better your brain. Steal ideas from other people's .vimrcs (here's mine)

场罚期间 2024-07-11 17:43:54

对我来说,VI 是一个很好的紧急编辑器,但如果有其他可用的替代方案,我不想使用它。 我意识到这并不适合所有人,我并不是说它很可怕或什么,我只是个人更喜欢可发现的用户界面。

但如果您在 Linux 中做任何重要的事情,您确实必须了解 VI!

所以只需学习基础知识:
i=插入模式
esc=离开插入模式
:wq=保存并退出
:q!=不保存并退出
x=不在插入模式时,删除该字符。
/=search

这将帮助您解决任何编辑紧急情况。 没有什么是你不能用这几个命令(当然还有导航)做的。 其余的您可以根据需要“添加”。

不过,请保留可用的参考资料或书籍(当您需要使用 VI 时,您可能无法浏览网络),但手册页可能会有些用处。

For me VI is a good emergency editor, but not something I want to use if there is any other alternative available. I realize this is not for everyone though, I'm not saying it's horrid or anything, I just personally prefer a discoverable UI.

But you really have to know VI if you do anything significant in Linux!

So just learn the basics:
i=insert mode
esc=leave insert mode
:wq=save and quit
:q!=don't save and quit
x=when not in insert mode, delete the character.
/=search

That will get you through any editing emergency. There is nothing you can't do with those few commands (and navigation of course). The rest you can "Tack on" as you need them.

Keep a reference or book available though--when you NEED to use VI, you probably won't be able to browse the web--but the man page may be somewhat useful.

苏辞 2024-07-11 17:43:54

写下您在工作中使用当前编辑器时使用的所有快捷键和功能。 然后在周六早上坐下来,使用 Google 和 Stack Overflow 了解如何在 vi 中完成其中的每一项。 如果您使用一张(或多张)纸来完成此操作,可能最好。

现在禁用/删除工作中的其他编辑器,这样您查找并重新安装它们的时间就会比查看比较表并在 vi 中执行要花费的时间 - 即您别无选择。

最后,在博客上发布从旧编辑器到新编辑器的交叉快捷方式列表。

祝你好运!

Write down all the short-cuts and features that you use in your current editor while you're using it at work. Then sit down on Saturday morning and using Google and stack overflow find out how to do each one of those in vi. Probably best if you use a sheet (or sheets) of paper for this.

Now disable/delete the other editors at work so that it'll take you longer to find and re-install them than look at your comparison sheet and do it in vi - i.e. you have no choice.

Lastly, publish your list of crossover shortcuts from your old editor to your new one on your blog.

Good luck!

回忆那么伤 2024-07-11 17:43:54

gVIM 有一个非常好的教程(开始菜单组中的链接)。

我发现解决这个问题有助于克服最初的学习障碍; 然后将我的 Visual Studio 切换到 ViEMU 帮助我磨练了我的 VI 技能。

另外,http://vimcasts.org/ 上的截屏视频也很棒!

gVIM has a really good tutorial (link in the Start menu group).

I found working through that helped to get over the initial learning hump; and then switching my Visual Studio to ViEMU helped me hone my VI skills.

Also, the screencasts at http://vimcasts.org/ are great!

百思不得你姐 2024-07-11 17:43:54

我使用 vi 的主要原因是 ssh(或 Windows 上的 Putty):当您远程登录到 Unix 服务器时,vi > 始终可用。 当光标键和退格键/删除键均未映射时,它可以与 VT100 一起使用。

另外,拥有一本像 VI Editor Pocket Reference 这样的书也有很大帮助。

The main reason for me to use vi is ssh (or Putty on Windows): When you're logged into a Unix server remotely, then vi is always available. And it works with VT100 when neither the cursor keys nor backspace/delete are mapped.

Also having a book like VI Editor Pocket Reference helps greatly.

旧情别恋 2024-07-11 17:43:53

首先,你可能想选择 Vim; 它拥有极其优越的功能集以及 ​​vi 所拥有的一切。

也就是说,学习需要纪律。 如果您有工作并且无法承受生产力下降(不会被解雇),我建议您参加一个周末项目,其唯一目的是学习编辑器。 工作时保持文档开放,并保持足够的纪律,不要畏缩。 当你学得更多、变得更有效率并开始依赖肌肉记忆时,坚持下去就不会那么困难了。

我已经使用 Vim 太久了,以至于我什至没有想过要按什么键来搜索、导航或保存。 我的手从来没有离开过键盘。 使用 Vim 是我在编程生涯中做出的最佳选择之一。

First of all, you may want to pick up Vim; it has a vastly superior feature set along with everything vi has.

That said, it takes discipline to learn. If you have a job and can't afford the productivity hit (without getting fired), I'd suggest taking on a weekend project for the sole purpose of learning the editor. Keep its documentation open as you work, and be disciplined enough not to chicken out. As you learn more, become efficient and start relying on muscle memory, it won't be as hard to stick with it.

I've been using Vim for so long that I don't even think about what keys to press to search or navigate or save. And my hands never leave the keyboard. To use Vim is one of the best choices I've made in my programming career.

爱殇璃 2024-07-11 17:43:53

我要做的第一件事就是在你的箭头键和 ins/home/end/pgup/down 键上放一张纸或一本书。 Vi 中不需要这些。

接下来,每当你被告知要按 escape 时,我都会习惯按 ctrl+[ 。 它速度更快,您无需将手从键盘上移开。

然后我会观看我的截屏视频:

http://www.youtube.com/watch?v=FcpQ7koECgk

http://www.youtube.com/watch?v=c6WCm6z5msk

http://www.youtube.com/watch?v=BPDoI7gflxM

http://www.youtube.com/watch?v=J1_CfIb-3X4

然后,练习一下练习练习。

编辑
避免使用箭头键的原因是它们会减慢你的速度。 Vim 最大的好处之一就是它的速度。 箭头键还会阻止您真正拥抱模态性质,而掌握了模态性质后,它的功能将非常强大。

The first thing I'd do is lay a piece of paper or a book over your arrow keys and your ins/home/end/pgup/down keys. Those aren't needed in Vi.

Next I'd get used to hitting ctrl+[ whenever you're told to hit escape. It's much faster and you won't need to take your hands off the keyboard.

Then I'd watch my screencasts:

http://www.youtube.com/watch?v=FcpQ7koECgk

http://www.youtube.com/watch?v=c6WCm6z5msk

http://www.youtube.com/watch?v=BPDoI7gflxM

http://www.youtube.com/watch?v=J1_CfIb-3X4

Then, just practice practice practice.

edit
The reason for avoiding the arrow keys is that they slow you down. One of the largest benefits of Vim is the speed it allows you. The arrow keys also prevent you from really embracing the modal nature, which is very powerful when mastered.

泪意 2024-07-11 17:43:53

第0步:学习盲打。 说真的 - 如果你的手指不知道按键在哪里,那么 vim 将是一个痛苦。 即使您拒绝 vim,盲打也会改进您的编程(询问Steve Yegge )通过让头脑无摩擦地监控链接。 有很多可以帮助您提高打字水平的软件

第 1 步:使用 vimtutor 开始。 它在 gvim 中(在
我认为是帮助菜单)或者你可以在命令中输入“vimtutor”
线。 这将花费您 30-45 分钟的时间,然后您的手指将
了解 vi/vim 的基础知识,您应该能够编辑文件而无需
想要把键盘扔出窗外。

第 2 步:到处使用 vim。 请参阅这个
问题

有关在命令中使用 vim 和 vi 键绑定的提示和链接
行,从您的网络浏览器,用于撰写电子邮件,在您的 IDE 中......您
需要使用 vim 将按键绑定嵌入到你的肌肉记忆中。

第 3 步:了解有关 vim 的更多信息。 你只会刮伤
使用 vimtutor 进行表面处理。 您可以观看此视频
视频

阅读这篇文章(均关于
“有效文本编辑的七个习惯”。 你可以
阅读
关于
提示

技巧

StackOverflow
您可以浏览vimtips。 学习一个
我的建议很少——外面有太多东西
坚持小块将是获取知识的最佳方式
戳。

第 4 步: 利润:)

Step 0: learn to touch type. Seriously - if your fingers don't know where the keys are then vim is going to be a pain. And even if you reject vim, touch typing will improve your programming (ask Steve Yegge ) by making the mind to monitor link friction free. There is a lot of software that can help you improve your typing.

Step 1: use vimtutor to get you started. It is in gvim (under
the help menu I think) or you can just type 'vimtutor' at the command
line. It will take 30-45 minutes of your time and then your fingers will
know the basics of vi/vim and you should be able to edit files without
wanting to hurl your keyboard out of the window.

Step 2: use vim everywhere. See this
question

for tips and links for using vim and vi key bindings at the command
line, from your web browser, for composing emails, in your IDE ... You
need to use vim to embed the key bindings in your muscle memory.

Step 3: learn more about vim. You will only have scratched the
surface with vimtutor. You can watch this
video
or
read this article (both about
the "Seven habits of effective text editing". You can
read
about
tips
and
tricks
on
StackOverflow.
You can browse vimtips. Learn a
litle often would be my advice - there is so much out there that
sticking to bite-size chunks will be the best way to make the knowledge
stick.

Step 4: Profit :)

魂归处 2024-07-11 17:43:53

这些年来我一直断断续续地使用 vim(偶尔做一些系统管理工作)。 我最近才开始花更多的时间在其中进行编程工作。 我也建议从 gvim 开始。 它与大多数操作系统环境集成良好,并且(甚至更好),您可以在需要时重新使用鼠标:)。

要开始使用 vim,请运行 vimtutor(与 gVim 捆绑在一起)一次或两次(需要一个小时左右)。 我无法夸大它对我有多大帮助! 特别是第一部分,关于在文档中移动的不同方式,以及如何使用动作命令记录编辑动作等。之后,事情会变得更加清晰。

然后,开始用它进行快速、细微的编辑(记事本替代品),直到您能够轻松地快速进行有用的编辑。 然后尝试在其中完成日常工作。 您很快就会发现自己渴望其他编辑器中的“重复上一个操作”命令!

I've been a on-again, off-again user of vim throughout the years (doing the occasional sys admin job). I just recently started spending more time doing my programming work in it. I'd suggest starting with gvim too. It integrates well with most OS environments, and (even better), you can fall back to the mouse when you need to :).

To get going with vim, run through the vimtutor (bundled with gVim) once or twice (takes an hour or so). I can't overstate how helpful it was for me! Especially the first parts about the different ways to move through a document, and how edit actions are recorded with motion commands, etc, etc. After that, things will be MUCH clearer.

Then, start doing quick, minor edits with it (notepad-replacement stuff) 'till you are comfortable enough to do useful editing at a rapid clip. Then try doing your day-to-day work in it. You'll find yourself pining for the "repeat last action" command in other editors in no time!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文