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.

Ten Years of Vim

153 pointsby mrealmost 7 years ago

24 comments

linsomniacalmost 7 years ago
One thing google can do that blows most peoples mind when I show them: Did you know vim supports time travel undo?<p>Sometimes you do some things then undo and redo trying to get back to a certain point in time. In vim you can step forward and back through all this by doing &quot;g-&quot; or &quot;g+&quot; to travel backwards or forwards in time. Or you can say &quot;:earlier 50s&quot; to go back to where you were 50 seconds ago.<p>Most editors treat undo as a linear thing, you undo and you redo. But once you undo and then do some things, it starts looking more like a tree than a line. It&#x27;s not frequent, but sometimes I just need to say &quot;I know what I had was what I wanted 5 minutes ago.&quot;
评论 #17115598 未加载
评论 #17115465 未加载
评论 #17115271 未加载
评论 #17116870 未加载
评论 #17115492 未加载
peraalmost 7 years ago
OP should consider using buffers: you can <i>:ls</i> to display the list of buffers (which I have mapped to <i>gl</i>) and then <i>:bn</i> (where <i>n</i> is a buffer number) to go to some specific buffer. Also, in the same fashion of <i>gt</i> and <i>gT</i> for tabs, I mapped <i>gb</i> to go to the next buffer, <i>gB</i> to the previous one, and <i>g space</i> to go to the last one. IIRC all these key bindings are unused by default. In my opinion tabs are more useful&#x2F;interesting when you work with multiple windows layouts.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;pera&#x2F;vim&#x2F;blob&#x2F;master&#x2F;.vimrc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pera&#x2F;vim&#x2F;blob&#x2F;master&#x2F;.vimrc</a>
评论 #17116654 未加载
评论 #17118709 未加载
bArrayalmost 7 years ago
I use (Vim IMproved - not vi) vim all the time. I find it interesting to see what features other people tend to use in vim, there seems to be some minor differences in their workflows, but it&#x27;s not clear who &quot;wins&quot; the productivity battle.<p>I only use a <i>very</i> small number of it&#x27;s features:<p>* `:tabe` Create a new tab<p>* `:e .` Start browsing files in that tab<p>* `:w` Write the file<p>* `:q` Quit the file (`:q!`, seriously, please do quit the file)<p>* CTRIL+SHIFT+UP&#x2F;DOWN To switch tab (doesn&#x27;t reliably work on every machine)<p>* `&#x2F;WORD` To search for something<p>* `:NUM` To go to a specific line<p>* `i` To insert<p>* SHIFT+V to select lines<p>* `d` To delete lines<p>* `x` To extract lines<p>* `y` To &quot;yank&quot; (copy) lines<p>* `p` To paste lines<p>&gt;Here are a few things I wish I could do better:<p>I don&#x27;t have a great memory, so memorizing more than what I use every day is a little too much. One thing that I&#x27;m working on remembering is the ability to replace strings (although I don&#x27;t really like regex).<p>&gt;Would I learn Vim again?<p>I&#x27;m yet to experience anything compelling enough to stray me away. The advanced features are there if I ever need them, but for the most part I am free to have a lightweight editor.
评论 #17116371 未加载
评论 #17117212 未加载
评论 #17115801 未加载
评论 #17115954 未加载
评论 #17116904 未加载
darthlucioalmost 7 years ago
I know you said that you like maintaining a super minimal .vimrc, but fwiw there&#x27;s a couple of plugins that really helped me with the workflow issues you mentioned struggling with:<p>&gt; Jumping around in longer texts: I know the basics, like searching (&#x2F;), jumping to a matching bracket (%) or jumping to specific lines (for line 10, type 10G), but I still could use symbols more often for navigation.<p>vim-sneak is real nice for this, and has turned into one of my most-used movement commands <a href="https:&#x2F;&#x2F;github.com&#x2F;justinmk&#x2F;vim-sneak" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;justinmk&#x2F;vim-sneak</a><p>&gt; Using visual mode for moving text around: Sometimes it can be quite complicated to type the right combination of letters to cut (delete) the text I want to move around. That&#x27;s where visual mode (v) shines. It highlights the selected text. I should use it more often.<p>vim-move was a game changer for me <a href="https:&#x2F;&#x2F;github.com&#x2F;matze&#x2F;vim-move" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;matze&#x2F;vim-move</a><p>&gt; Tabs: I know how tabs work, but all the typing feels clunky. That&#x27;s why I never extensively used them. Instead, I mostly use multiple terminal tabs or an IDE with Vim bindings for bigger projects.<p>This is worth a read: <a href="https:&#x2F;&#x2F;joshldavis.com&#x2F;2014&#x2F;04&#x2F;05&#x2F;vim-tab-madness-buffers-vs-tabs&#x2F;" rel="nofollow">https:&#x2F;&#x2F;joshldavis.com&#x2F;2014&#x2F;04&#x2F;05&#x2F;vim-tab-madness-buffers-vs...</a>. Buffers + vim fzf is a really nice workflow <a href="https:&#x2F;&#x2F;github.com&#x2F;junegunn&#x2F;fzf.vim" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;junegunn&#x2F;fzf.vim</a>
评论 #17115677 未加载
评论 #17117044 未加载
评论 #17121229 未加载
JepZalmost 7 years ago
After using vim for a few years now, I noticed how I changed from thinking about text as characters to thinking about text as lines, which lets me create much cleaner code (independently from pretty printers).<p>When I selected code via mouse in the past, I selected it from character to character. In vim I tend to think line-wise so I can yank, paste, delete code per line which makes sense in many scenarios.
评论 #17115307 未加载
评论 #17115341 未加载
rjkennedy98almost 7 years ago
Surprised to see that he&#x27;s gone back to an empty vimrc after years with high customization. To me customization is such a great part of vim that I can&#x27;t imagine being without it. For instance, I have shortcuts to find and replace on visual selection. I also have at least 5 plugins in my vimrc that are absolutely necessary for my workflow. Pure vim is nice if you need to occasionally edit files, but if you use it as your prime editor its not enough without customization.
评论 #17115941 未加载
评论 #17115416 未加载
markrianalmost 7 years ago
One built-in feature (not enabled by default) that I absolutely love is persistent undo. <i>Love</i> it.<p>Basically, undo trees can be persisted across vim sessions. Have a read via &quot;:help undo-persistence&quot;.
评论 #17115577 未加载
Theodoresalmost 7 years ago
One current problem I have with Vim is those linux distributions where someone - maybe the VPS vendor&#x2F;hosting company - put in some mystery .vimrc file somewhere that makes the editor apparently more friendly for new users. So you copy and paste a line to your mysql config file, to restart the database service and find that nothing has changed. So then you edit the file again and discover that the mystery .vimrc file has added a &#x27;#&#x27; at the start of the line.<p>Another one that gets commonly messed with is the search. If you use &#x27;&#x2F;&#x27; then you should expect the search to begin when you press the enter key, with the usual &#x27;n&#x27; to go to the next match. But no, some mystery .vimrc file has made this more newbie friendly, so the search happens before pressing enter. Which is not what you want if standard, expected behaviour is expected.<p>For reasons of teamworking I have moved away from vim plugins in the IDE, for this I have had to buy a new keyboard. Normally I do not use a full keyboard as that number block on the right hand side has no value whatsoever to me. If I was right handed and did accounts then sure, that would be a handy feature, but the number pad is really just not helping for me, most of the time, particularly on a laptop where the numpad skews the keyboard off to the left hand side. I want the spacebar in the centre, not an inch or so off skewed to one side.<p>So my new discovery - the gaming keyboards that have the home&#x2F;end and arrow keys but no number block - I think they are called 87 key keyboards. These are great if &#x27;moving away from vim&#x27; as the &#x27;home&#x2F;end&#x27; keys make it easy to get to a start&#x2F;end of a line. Under normal circumstances with vim there is no need for these extra keys, to add to the end of a line or the start is just a matter of using the right keystroke, just &#x27;o&#x27; or &#x27;a&#x27; is all that is needed with the magic that is vim.<p>Moving away from vim is quite dangerous, for a while you find programs breaking because there is a block of &#x27;kkjjj&#x27; or an &#x27;i&#x27; embedded in there somewhere!
评论 #17116859 未加载
评论 #17119015 未加载
keithnzalmost 7 years ago
The point in the article is that the Vim keyboard bindings are most useful. Most editors have an option or plugin for that. That&#x27;s what I use mainly. For instance I use Visual Studio + Resharper + VsVim ( + AceJump + RelativeLineNumbers) as my main development enviroment. I also use webstorm configured in a similar fashion. Visual Studio and R# understands the code and how to manipulate code far better than anything in the Vim world does, but I use it in combo with Vim keyboard bindings and it becomes incredibly quick to do things.<p>I don&#x27;t actually use Vim itself very much ( I still use it for various things, but its not my main editor ). Its nicest attribute is for quick editing tasks it loads quick and can load very large files.
bitofhopealmost 7 years ago
Vim user here. One thing I rarely see discussed is the idea that vim is not about speed. It&#x27;s about comfort.<p>Maybe hjkl is a little faster than arrow keys. I don&#x27;t care. I just like doing my editing with less hand movement.<p>I&#x27;m sure that I could perform many operations faster with a mouse. Select text, drag it a little below. Probably faster than d}}p even. The point is, mouse is finicky and annoying. The context switch between typing and moving the mouse breaks flow. Aiming the pointer is hell, and even worse if the target is small or the mouse of low quality. Anyone who plays click-heavy video games (RTS, many MMOs, 4X) can probably understand the pain of dragging the cursor between two points and clicking repeatedly.<p>Vim is terrible. It takes a while to learn and when you&#x27;ve learned it well enough you&#x27;re spoiled and everything else feels painful. Vim is the closest I can get with current technology to a neurally linked brain-controlled editor. It feels like the cursor obeys my thoughts, not the limits of my manual dexterity. The next step would be an editor actually wired to my brain where I just think what the text should look like.
daenzalmost 7 years ago
One thing I noticed when working with people who are only familiar with IDEs for coding and GUIs for version control: they&#x27;re helpless on remote servers. If they need to jump on a box and debug an issue live, they just can&#x27;t do it. For me, using tmux + vim + git cli locally, my workflow remains exactly the same remotely.<p>Tools are nice, but don&#x27;t let them make you weaker.
JoshMnemalmost 7 years ago
Tabs are great for organizing groups of related files. They are different from other editors that only let you have one file per tab.<p>With Vim you could split a tab with a frontend HTML and CSS file, and have a couple of backend files in another tab. Then `gt` or `gT` to switch between the groups.<p>If you use nerdtree, `t` opens a file in a new tab, so you don&#x27;t need to type `:tabnew` often.
FreeFullalmost 7 years ago
Nowadays, I prefer Kakoune ( <a href="http:&#x2F;&#x2F;kakoune.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;kakoune.org&#x2F;</a> ) to vim. Being based on selections rather than movements feels much nicer. It feels a bit like always being in a kind of visual mode. That said, there are the following caveats:<p>* Vim tends to be installed&#x2F;available almost everywhere, Kakoune isn&#x27;t<p>* Vim has a much bigger ecosystem<p>* There are some very advanced features hidden in vim that most people don&#x27;t know about. If you depend on those, substituting vim with another editor can be hard.
评论 #17118279 未加载
cgagalmost 7 years ago
It&#x27;s highly overstated how hard it is to learn imo. I would learn it again without a doubt.
评论 #17115693 未加载
gwn7almost 7 years ago
&gt; I don&#x27;t use arrow keys to move around in text anymore but forced myself to use h, j, k, l. Many people say that this is faster. After trying this for a few years, I don&#x27;t think that is true (at least for me). I now just stick to it out of habit.<p>Sounds like he&#x27;s not a touch-typist.<p>And as a general note; learning and mastering vim can hardly be a pleasant activity for non touch-typists, or otherwise typing heroes.
评论 #17117324 未加载
评论 #17118011 未加载
评论 #17115544 未加载
评论 #17121911 未加载
Zelphyralmost 7 years ago
I read an article a few years ago, the name of which escapes me. It was something like “Idiomatic Vim” or “Linguistic Vim”. I would love to find that article again, if anyone happens to know based on the sparse info I’ve just provided, I would greatly appreciate it.<p>One of the things I learned was that you can do things like yank to a character. In other words, if your cursor is at the beginning of “The quick brown fox jumped over the lazy dog” you can type ‘ytx’ (Yank To to the “x” next “x” character) and it’ll yank “The quick brown fo”. That’s really handy with code, I find.
评论 #17116579 未加载
评论 #17117026 未加载
spicyusernamealmost 7 years ago
All of the points in the &quot;Some things I wish I could do better&quot; section are the reason I use a regular memorization free-ish IDE.<p>Out of the box the things I want to do are easy (multiple files, manipulating structure of blocks of text, searching and manipulating information across my project simultaneously) and the things that aren&#x27;t are rare (Add a dollar sign at the beginning of the next 13 lines).<p>I know how to use vim solely because it&#x27;s necessary to edit files in a terminal.
评论 #17115513 未加载
archi42almost 7 years ago
Regarding tabs: I bound F2 to previous tab, F3 to next tab and F4 to new tab. Besides highlighting the current line, I think this is my most important customisation.
评论 #17115225 未加载
评论 #17118976 未加载
评论 #17115290 未加载
评论 #17115185 未加载
eadmundalmost 7 years ago
Wait until he discovers emacs!<p>I don&#x27;t mean that rudely, it&#x27;s just that emacs can do everything vim does &amp; far more.
评论 #17118346 未加载
评论 #17116719 未加载
评论 #17116984 未加载
hajderralmost 7 years ago
Long time Vim user here. Just switched to Emacs primarily. Use Vim for small tasks
nurettinalmost 7 years ago
Only 10 years? Feels old, man.
KasianFranksalmost 7 years ago
Vi
hungerstrikealmost 7 years ago
Whenever vim comes up I see someone trying to sell the audience on some &quot;amazing&quot;, obscure and rarely used feature that users of other editors should be jealous of... However, it seems to me that if anyone <i>actually wanted</i> those features then they&#x27;d be standard in other text editors and we&#x27;d have them already.<p>But what I find really hilarious is that whenever these features are mentioned I see people who have been using the thing for a decade say &quot;I never knew that!&quot; or they dicker about what the commands actually are.
alexandernstalmost 7 years ago
&quot;And I still can&#x27;t find how to quit&quot;
评论 #17116430 未加载