TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

To Master Vim, Use It Like Language

250 pointsby danielmiesslerover 9 years ago

21 comments

stevebmarkover 9 years ago
This article is well written, but it has nothing to do with mastering Vim. It goes no further than running &quot;vimtutor&quot; at the command line. It has all the same tips and shortcuts as any other vanilla Vim tutorial. This is a common problem among Vim articles and tutorials. Authors title them as if it will give you Vim mastery, but instead it only offers the basics.<p>Mastering Vim means going beyond vanilla movements and learning all of Vim&#x27;s nasty warts to replace good GUI features. It means learning the wonky, dead Vimscript language. It means knowing how to use the arcane arglist. It means knowing how to go into insert-normal mode, and when to use the expression register. It means knowing everything about very magic search, and why default search is poorly designed. These are all randomly chosen examples, because mastering Vim involves mentally juggling a very large playbook of oddball features to complete editing tasks.<p>The main resources to help you master Vim are the book &quot;Practical Vim&quot; by Drew Neil, and if you&#x27;re ever in the unfortunate position of needing to write or edit a Vim plugin, &quot;Learn Vimscript the Hard Way&quot; is invaluable <a href="http:&#x2F;&#x2F;learnvimscriptthehardway.stevelosh.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;learnvimscriptthehardway.stevelosh.com&#x2F;</a>
评论 #10317549 未加载
评论 #10316938 未加载
评论 #10316830 未加载
评论 #10316964 未加载
DarkTreeover 9 years ago
My issue with getting better at vim is that I&#x27;ve gotten to the point where I&#x27;m comfortable moving around text, copying&#x2F;pasting, and everything I would normally do with a mouse. I know vim is so much more than that, but it&#x27;s one of those things where &quot;you don&#x27;t know what you don&#x27;t know&quot; and because of that, I don&#x27;t have the incentive to continue learning. Hopefully this post will inspire me to incrementally advance my vim usage.
评论 #10317572 未加载
评论 #10316483 未加载
评论 #10316718 未加载
评论 #10316983 未加载
评论 #10316656 未加载
评论 #10316642 未加载
评论 #10317037 未加载
blymphonyover 9 years ago
I consider myself at least an intermediate user of Vim, and I&#x27;m glad that you mentioned the &quot;f&quot; motion (along with its cousins &quot;t&quot; and &quot;;&quot;). I don&#x27;t think these keys get enough exposure among beginner Vim users (they aren&#x27;t mentioned in vimtutor), but they allow you to quickly and efficiently move across files and do things like &quot;ct(&quot; (change text up to first left parentheses), which is super useful for changing function names.<p>Shameless plug: I wrote a plugin (<a href="https:&#x2F;&#x2F;github.com&#x2F;unblevable&#x2F;quick-scope" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;unblevable&#x2F;quick-scope</a>) that facilitates the use of &quot;f&quot; and family that even beginners can take advantage of.
评论 #10316216 未加载
评论 #10317109 未加载
评论 #10316343 未加载
PhasmaFelisover 9 years ago
The thing that always frustrated me about Vim (and command-line apps in general) is that it punishes you for being a GUI power user. The more mastery you have of conventional GUI keyboard shortcuts to highlight, jump words, copy&#x2F;paste, etc., the more often you will reflexively hit them and do the wrong thing while trying to use Vim. You have to unlearn a lot of perfectly good skills before you can really master Vim, and that&#x27;s frustrating.<p>Of course it&#x27;s not Vim&#x27;s fault that the standards established by vi were not taken up by the early GUI systems, but I wish there was a better way to deal with this problem than a figurative grizzled old console cowboy going &quot;suck it up, n00b, it builds character.&quot; I&#x27;m aware that people have made command sets that make Vim and the *nix console in general more GUI-standards-friendly, but these are never presented to actual CLI newbies, so by the time you&#x27;re aware of them you&#x27;ve done half the work already...
评论 #10317168 未加载
barbsover 9 years ago
&gt; inoremap jk &lt;ESC&gt;<p>Using two keystrokes instead of ESC to leave insert mode is definitely a personal preference and not necessarily more efficient or comfortable.
评论 #10316167 未加载
评论 #10316232 未加载
评论 #10316255 未加载
评论 #10316118 未加载
评论 #10316706 未加载
评论 #10316787 未加载
评论 #10316659 未加载
lognover 9 years ago
From the article: &quot;Arguably the most brilliant thing about vim is that as you use it you begin to think in it.&quot;<p>Bill Joy, regarding vi: &quot;It&#x27;s like one of those pinatas--things that have candy inside but has layer after layer of paper mache on top. It doesn&#x27;t really have a unified concept. I think if I were going to go back--I wouldn&#x27;t go back, but start over again.&quot;<p>Hunter S. Thompson, on an unrelated topic: &quot;That was the fatal flaw [...] the desperate assumption that somebody--or at least some force--is tending the Light at the end of the tunnel.&quot;<p>I think vim is a useful tool. It&#x27;s available on most systems and is powerful. But trying to grok it and appreciate its UI isn&#x27;t really something I want to do.
voidpointerover 9 years ago
While a tweaked configuration can be a great productivity boost, it has a major drawback. My main reason for using vim is its ubiquitousness. Whenever I need to ssh into a box to check something out, I can trust that it&#x27;s there. However, I cannot trust that its configuration has been tweaked like I expect. Hence, I stay away from getting used to non-standard key mappings.
评论 #10317484 未加载
评论 #10320775 未加载
uxcnover 9 years ago
This is a really good introduction to vim. It is better to think of it as a grammar to manipulate text.<p>A few additional things that have saved me keystrokes...<p>replace mode (<i>R</i>)<p>insert normal mode (<i>&lt;c-o&gt;</i>)<p>paste from a register in insert mode (<i>&lt;c-r&gt;reg</i>)<p>expression register (<i>=</i>)<p>clipboard and active selection registers (<i>+</i>, <i></i>* respectively)<p>command ranges (e.g. <i>10,+5s&#x2F;foo&#x2F;bar&#x2F;g</i>)<p>miscellaneous commands (<i>:global</i>, <i>:argdo</i>, <i>:normal</i>, etc...)
andhessover 9 years ago
I have my interns setup Vim on their first day, and it&#x27;s usually their editor of choice by the end of the summer. Apparently it gives them mad credit among their peers at school too.
PeterWhittakerover 9 years ago
Great tutorial. About 20 years ago, I was a Level 4 user (by the article&#x27;s definition), but that knowledge faded with disuse. When I switched back to a Linux&#x2F;UNIX machine about a decade ago, I started using vim again (well, I started using <i>vi</i> again, but it was vim), and remembered a lot of Level 1 and 2 stuff, and could recall being able to do more, but never had the motivation to crawl through the man page to force myself to recall how I did more.<p>This article is so logically laid out I think anyone could get to at least Level 3 with the article and a few hours diligent practice. Level 4 would then beckon....<p>When I became a serious sed - and then ed - user, I became a much better (faster, more productive) vi&#x2F;vim user when I didn&#x27;t need to be in visual mode all the time.
zappo2938over 9 years ago
Vim Adventures is so much fun. <a href="http:&#x2F;&#x2F;vim-adventures.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;vim-adventures.com&#x2F;</a>
mellingover 9 years ago
Which plugins do people find valuable? EasyMotion was recently recommended to me:<p><a href="http:&#x2F;&#x2F;code.tutsplus.com&#x2F;tutorials&#x2F;vim-essential-plugin-easymotion--net-19223" rel="nofollow">http:&#x2F;&#x2F;code.tutsplus.com&#x2F;tutorials&#x2F;vim-essential-plugin-easy...</a>
评论 #10316508 未加载
bootloadover 9 years ago
from config: <i>&quot;I remap it to Ctrl at an operating system level. This way my left pinky can simply slide to the left by one key to execute Ctrl-whatever.&quot;</i><p>Been a while since I used emacs, ctrl-<i>everything</i> is an emacs idiom [0] and a pinky killer. I guess the best bit is it&#x27;s configurable. Really like this tute Daniel, found a nice add for my .vimrc already.<p>[0] <a href="http:&#x2F;&#x2F;mally.stanford.edu&#x2F;~sr&#x2F;computing&#x2F;emacs.html" rel="nofollow">http:&#x2F;&#x2F;mally.stanford.edu&#x2F;~sr&#x2F;computing&#x2F;emacs.html</a>
enigmatic7over 9 years ago
I agree that knowing basics of Vim is of great help and adds value to a programmer&#x27;s skill set.<p>I don&#x27;t agree that it should be the only thing one uses for all development&#x2F;writing tasks.<p>Yes, vim is ubiquitous. However, no one uses vim without high levels of customization. So i think there is a bigger dependency issue here.<p>Also, I&#x27;ve seen millennials struggling to cope with vim - it&#x27;s like handing a cassette to a person who&#x27;s grown up with an iPod.<p>As long as the work gets done, an editor does not matter.
ridiculous_fishover 9 years ago
Learning vim is easy, I&#x27;ve done it a thousand times! (As Mark Twain might say)<p>This time around I&#x27;ve been keeping a list of the stuff I miss from my usual workflow. Here&#x27;s two of the most maddening:<p>1. Searching for literal text. Is there a way to avoid having to manually escape special characters?<p>2. Maintaining cursor position when scrolling. Maybe I want to go look at another part of the file and come back. How can I scroll without it moving my cursor?<p>As far as I can tell, I&#x27;m SOL on both counts.
评论 #10317226 未加载
评论 #10316903 未加载
评论 #10316974 未加载
评论 #10316923 未加载
rajathagasthyaover 9 years ago
Thanks for this tutorial. I&#x27;m at Level 1 having switched from an IDE (PyCharm) and I find this helpful. Any reason why you use Pathogen vs Vundle for managing plugins? Does it even matter?
评论 #10316333 未加载
评论 #10316315 未加载
mellingover 9 years ago
Is there a way to navigate words taking camel case into consideration? helloWorld should be treated as two words when I want to delete or move, at least sometimes when I want to edit.
评论 #10318468 未加载
评论 #10316843 未加载
allendoerferover 9 years ago
Does work less well if you do not think in English.
评论 #10316238 未加载
bhagyasover 9 years ago
This has been one of my favourite articles on Vim for beginners. I&#x27;d recommend this to any beginner or a user of any other text editor.<p>Great post.
hackatrollover 9 years ago
What is a better editor VIM or emacs? Why?
Animatsover 9 years ago
Vim is a regular expression system hooked to a 1970s user interface. If you need to apply regular expressions to text files, vim is useful. I used vi to write code for years, but that was decades ago. There&#x27;s been some progress since the 1970s.
评论 #10316431 未加载
评论 #10316295 未加载
评论 #10316160 未加载
评论 #10316296 未加载