8 ms·
Vim: from n00b to meh
- TheLegace 13y agoI want to learn Vim, but I cannot even dream to remember even the most primitive commands.
- dionidium 13y agoTreat learning vim like you'd treat learning a natural language. You weren't having conversations when you were two years old, but you were learning words that you'd need later when you were ready to string them into sentences. That's how vim works. I've been using vim for 10 years and I learn new things all the time.
- yogo 13y agoThat's the best thing about vim... there is always more to learn. I think it might be boring otherwise
- madvoid 13y agoTo be honest, I found that the only way to remember the commands is to commit them to muscle memory. However, this means coding enough in vim that you look things up enough for them to just stick.
- danieldk 13y agoOnce you know how to switch between modes, it's easy to use vim as a basic text editor using the cursor keys. At that point I wouldn't start looking things up all the time. Just set out to learn one new command or shortcut every two days, applying it in your daily use. Usually that's enough to get them in your mid-term muscle memory, so that you continue to use when you move on to the next command. The Vim pocket guide is great to choose what's up next. I was already fairly adept at Vim when I applied this method to teach myself less frequently used Vim commands.
- nolite 13y agothe best way to learn VIM is to learn the basic commands, and then make your own
- djblue 13y agoThe Vim Adventures games is actually pretty useful for getting use to sticking with the keyboard and laying off the mouse.
- adambard 13y agoThere is definitely a basic set of commands to remember, but the real power of vim is that it forms a succinct and consistent text-editing language where complex operations can very often be synthesized from what you already know about it. For example, there are a set of commands that move the cursor in different ways (beginning of line, end of line, first line, last line, line #x, next word, previous word, etc. (that's ^/$/gg/G/g#/w/b) ), and a set of commands that performs actions (copy, cut mostly (y/d)). The real magic is how the two sets interact. I don't have to memorize the sequence of keys to delete a word; I know the key to cut (d), and the key to move a word forward (w). I press d, then w, and the word is gone! It's a whole world of editing possibilities. My secret shame: since I use GUI vims almost exclusively, I've never developed the muscle memory for hjkl movement; I use the arrow keys. When I started out, I knew i, esc, and that, and I figured out the rest as I needed it.
- mynameishere 13y agoI press d, then w, and the word is gone! There's got to be a better reason to use vim than this. I mean...the standard for every other editor is ctrl-shift-left arrow, then the delete key and the word is gone! Whoopee. It works in most editors, even Microsoft notepad and this textarea I'm typing in right now. I use unfashionable, clumsy old eclipse most of the time and could probably list 100 important things it does that vim never could. Things that actually matter. Maybe I'm wrong, but I doubt vim can launch and debug and continuously deploy to Apache tomcat. That sort of thing.
- leephillips 13y agoI think the real joy of vim is in the next level, when you start depending less on movement commands in favor of text objects.
- ethanazir 13y agoor you try to finish your HN comment with :w
- leephillips 13y ago
- codenut 13y agoMy fingers remember the primitive command but my mind doesnt. If you ask me for a command and its function, I will not be able to answer some of it. But if I start typing on the keyboard my fingers know what to do.
- leephillips 13y agoIt's like when I was a kid in New York. I could walk anywhere without thinking about it, but if someone asked me for directions I had no idea how to tell him to get where he wanted to go.
- danieldk 13y agoYes, it's funny how our brain works. I wouldn't be able to write down passwords that I use daily. Therein lies a pitfall - once you start think about a particular password, it becomes much harder to type it in.
- DigitalJack 13y agoI highly don't recommend using a starter kit, and particularly Janus. Janus started out ok but quickly morphed into an amalgamated mess of crap. The only thing I recommend is Pathogen which keeps addons modular. From there only add things to the baseline as needed.
- bgar 13y agoI agree so much with this. When someone new to Vim touches it they should start out with a blank slate.
- ethanazir 13y agoand then you start bind and learning key patterns that are sub-optimal
- dmix 13y agoAgreed I experienced this VIM, emacs...and also surprisingly linux. I tried switching to Ubuntu from OSX as many times as I tried abandoning Textmate for VIM. The thing that made me finally keep using Linux was using a very stripped down version called "Arch Linux". This made me appreciate the basic fundamentals of the operating system, with no fluff [1]. It was rough around the edges at first but you learn how to deal with quickly. I eventually switched to larger and easier-to-use Linux distros like Fedora/Debian. But whenever I run into problems with them, I have the experience to understand/fix it from working with Arch. I now have no interest in going back to OSX and use VIM obsessively. Many comedians will say this too: the only way to get motivated to be successful is with your back against the wall. Being partially comfortable makes you complacent. [1] https://www.archlinux.org/ https://www.archlinux.org/
- tsironakos 13y agoYeah, Janus is very complicated but maximum-awesome is very simple, just a vimrc and some plugins.
- wyclif 13y agoYou definitely do not want to use Janus right out of the gate, or use a copied ~/.vimrc file. Beginners who do that have no way of knowing where default vim ends and the plugins begin. If you are learning vim I think it's counterproductive to install any plugin unless you know exactly what it does first. That means incrementally building up your array of useful plugins and not installing them all at once. You want to be very selective about plugins in general anyway, and pay attention to which ones are the most useful to programmers who get a lot done, which will make you want to try them (I'm thinking NERDTree and Ctrl-P here).
- bgar 13y agoI use Vim but I don't understand why people try to force themselves to use it. If you are comfortable with another editor, then go ahead, keep using it. Everyones treats Vim as if it's some hallowed apex of programming ability, and that eventually you have to be weaned from your inferior Sublime or Textmate usage. Sure, Vim is awesome, but the idea that you _must_ sooner or later learn it is wrong. Unless of course you really are interested in Vim for what it offers and not just for its reputation.
- themodelplumber 13y agoI've been forcing myself to use it, but not in an unhealthy way. I just picked up a side project that excited me (new subdomain blog driven by a static site generator) and decided I'd only work on it in Vim. I'm learning lots, because that's all I've got to work with. But I think it's important to consider the circumstances under which you "force" yourself to use it. If I had decided to use it for work, I calculated that I would have lost $300 this week, which is painful even if I earn back more in saved time later. I actually did that with Linux, and the initial loss of efficiency was more than offset later by a functional knowledge of a variety of really cool software packages.
- wyclif 13y agoIf you really want to learn vim but are worried that the learning curve will impair your productivity for a few weeks at work, why not use it at home for a while on your own projects? I still think total immersion is the fastest way, but if you can't do that, then using it away from real work is better than nothing. I did it by using vim to edit everything, including long form writing and email.
- bgar 13y agoYes of course, many people that choose to learn Vim do so because they've heard how great it is from blog posts and coworkers, and are genuinely interested in it. There is also another group of people who feel compelled to learn Vim because they've heard it's the One True Editor and no other reason than that. I'm not saying tsironakos is this way, just pointing out a trend I've noticed. In the end, the best editor is the one you can leverage the most.
- rsamvit 13y agoOne of the best resources I used to build up my vim customizations was probably this video http://www.youtube.com/watch?v=xZuy4gBghho http://www.youtube.com/watch?v=xZuy4gBghho. It's got a lot of good stuff in it
- gamegoblin 13y agoI got pretty proficient at vim using basically the defaults (I added tabs to spaces and tab width to 4 spaces, and auto/smart indent in the .vimrc). These are the keys I use regularly. If you can memorize these, you can use vim proficiently: h/j/k/l (movement keys) i (insert mode) esc (leave current mode/go to default state) u (undo) >> / << (indent, unindent) dd (delete line) yy (copy line) p (paste) v (visual mode, used to highlight stuff) gg (go to beginning of file) G (go to end of file) r (replace the char under the cursor with the next char entered) % (jump to next paren/bracket, or if on a paren/bracket, jump to matching paren/bracket) w (go to next word) dw (delete word) cw (change word (deletes the word then goes into insert mode)) A (append (goes to the end of the line and into insert mode) 0 (go to beginning of line) $ (go to end of line) /some_word (searches for some_word, hit n to jump to the next occurrence) ?some_word (searches for some_word, in reverse direction) Common commands: :%s/regex/replacement/g (replace regex matches with replacement) :q (quit) :q! (quit without saving) :w (save) :wq (save then quit) :x (save then quit) :set blah (turns on setting blah) :set noblah (turns off setting blah) Most vim commands you can stick a number N before to execute N times. e.g. 5d deletes 5 lines. 5y copies 5 lines. 5> indents 5 lines. 5j jumps down 5 lines. Some common command combinations: %v%> (jump to next bracket, go into visual mode, jump to next bracket (highlighting everything in between), then indent it all) ggdG (jump to top, then delete everything to the end of file, (clears a file)) ddp (deletes a line of text and then pastes it (below where it currently it), thus this transposes two lines) You can see how you quickly develop strings of commands you rattle off by chaining basic commands together. EDIT (joke): Q. How do you algorithmically generate a cryptographically strong random string? A. Put a newbie in front of vim.
- dmix 13y agoI have a scenario that I need help with in VIM: switching between 2-3 files while working on them simultaneously. For ex: working on an HMTL+CSS+JS documents all at once. Assuming smaller screen where I can't have a vsplit screen. How to I jump between them quickly? Buffers/tabs? I love VIM but I haven't found a good tab/file switching solution. In Textmate tabbing was straight-forward. VIM doesn't seem well suited for tabs (especially with things like NERDTree and control-p).
- ethanazir 13y agothis title suggests , meh, that you lost interest in vim but the article seems to state otherwise...
- rDr4g0n 13y agoI wonder what the author didn't like about sublime text's vintage (vim) mode? I have not used vim, but i have been using vintage mode for about a month now and really love it. I grab my mouse occassionally, but mostly stay out of insert mode and navigate with movement keys. Plus I still have my sublime text environment that I've built up for the past 2 years. I don't think I could've made it this far by diving in head first. Like it or not, I have to get work done, and when I couldn't get a motion to work right or didnt know the best way to do something, I could fall back on sublimes regular tools.
- tsironakos 13y agoWhen I tried the vintage mode in Sublime Text, I already had some knowledge about vim and its behavior. I find that the vintage mode was restricting me, which exactly the opposite of what it's supposed to do. > I don't think I could've made it this far by diving in head first. That's exactly my point! Take it easy and don't go hardcore from the first day. You'll get annoyed right away and you'll go back to Sublime Text in 10 mins.
- akurilin 13y agoRead Practical Vim published by the Pragmatic Bookshelf. You'll go from n00b to "pretty good". Takes a long time to work your way through the text, as it's both thick and very dense, but every single page will empower you further.
- autoreverse 13y agoTry the Vimium plugin for Chrome for a bit of fun. https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb?hl=en https://chrome.google.com/webstore/detail/vimium/dbepggeogba...
- wildermuthn 13y agoI've been using Vim for a few weeks now, and the biggest time saver is not having to use FTP or Mac Finder. I can do everything from the terminal now.
- contingencies 13y agoIf this is a serious comment then please be advised everyone else stopped using FTP 10 years ago. For the love of god, at least use sftp, but preferably check out http://www.scribd.com/doc/120792448/CI http://www.scribd.com/doc/120792448/CI which is the way things are going (use git before deployment, CI handles the after). If you are just getting in to terminal stuff, then try Viscosity, SourceTree, iTerm, brew and opendiff on OSX. Once comfy, do consider moving to a desktop running a source-oriented distribution of Linux instead... despite the setup hassle, it's far superior and will force you to pick up loads of useful knowledge in a slow and manageable way. Hell, we even have Steam these days!
- wildermuthn 13y agoEveryone stopped using FTP 10 years ago? Pretty general statement, one I know to be untrue because most of my non-profit clients still use FTP. But I take your point, and on my own projects, I stick with git, grunt, and rsync. Not a fan of SourceTree, and now that I know Vim, I can use git diff to good effect.
- jdkanani 13y agoI would suggest not to use anyone's configuration, add config/plugin as per your need. And yes, don't forget to take a look at learnvimscriptthehardway.stevelosh.com
- vinceguidry 13y agoI don't understand the hoopla about editors. It takes me eight hours to write a half page of code. That half-page is well-understood, bug-free, and accomplishes the mission. The more I learn, the less I write. I don't want tools to help me write faster. I want tools to help me understand what it is I am writing.
- aerique 13y agoWhile I agree with most of your points it does matter to me that I can do the few editing actions I do quickly otherwise it breaks my concentration of focussing on the code. I also need to be able to navigate the code quickly but that might be part if your "tools to help me understand" remark.
- vinceguidry 13y ago> I also need to be able to navigate the code quickly but that might be part if your "tools to help me understand" remark. It often takes me 20-30 minutes to edit a single line of code. Understanding why I need to change the program, what the effects of making that change are, determining which line of the code to edit, figuring out whether I need to edit or refactor, spending time in a REPL to test the proposed changes... I just use the mouse.
- aerique 13y agoFor me, part of getting that understanding is navigating the code and I do not always have room for another window on my screens. It seems we have different approaches to working on code, or perhaps we just use different language. The main languages I currently work in are: Common Lisp, Python, JavaScript and C++.
- EricDeb 13y agoIs it a big switch from ST2 with vim bindings to straight vi?
- helloTree 13y ago... and one should always remap ESC. For me this was a big improvement (from an ergonomic viewpoint). My suggestion: imap jf <ESC>
- Tomis02 13y agoSo many people talk about learning vim, vim philosophy, getting proficient at vim, changing your workflow so that you can use vim better. You what this sounds like? A cult. Vim is a (surprise surprise) text editor, not a way of life. It's perfectly ok not knowing how to use vim and being put off by how awkward it feels. It's perfectly ok to use notepad++ or sublime text or whatever else you are comfortable with. To my knowledge nobody gets paid to use vim instead of some other editor; money comes from lines of code. It does not matter that you use vim, it does not make you a smarter person or better programmer (I should know, I often use vim at my work place). On the same note, it does not matter how cool you think you are when you manage to persuade git to do some complicated thing in a two liner command which could be achieved in svn or hg in two words, you are just being silly. Being proficient at vim/git when your job doesn't require it is like being able to rotate your left and right eyes simultaneuosly - one clockwise, the other counterclockwise. It's very funny/interesting, but utterly useless. Forcing yourself to learn vim for vim's sake or because you read on the internet how cool vim is and how 3l1t3 vim makes you is one of the things you'd be better off avoiding. Again, I should know. Seriously, don't drink the Kool-Aid.
- Walkman 13y agoYou probably don't understand well enough how big a difference these tools can make in your efficiency. Of course number one priority is to know the technology, nobody argues that.
- Tomis02 13y agoIn my experience, when working with anything but very small projects vim is a liability. Vim's main feature (speed of editing) is of marginal use when you only write about 10 LOC per day (as I would say is still the case 40 years after The Mythical Man Month was published, at least on average). The time when you're not writing code (which is most of the time) is used switching back and forth between files, going to declaration/definition, debugging,(auto)refactoring, changing between project configurations and so on. All this is very difficult to do with vim since it comes naked out of the box and you need to use all sorts of crutches to make is resemble a modern IDE. And when you switch another machine all you usually get is another barebones vim. For instance, when working on a C++ code base, vim will never come close to the ease of use of Visual C++. It might be better at "delete 2 lines starting at line #256", but that's about it. This can be improved by plugins that most of the time will not do exactly what you'd like them to do, so you will have to "adjust your workflow" to work around that. My original point was about using tools because it's cool or because the internet said so, and there's load of stories where people buy into how good vim is and then after a few months they still don't 'get it' so they are told they're doing it wrong (or just not smart enough). Ditto for git, lisp and other silver bullets. If you ask me, if efficiency were important people would be using hg instead of git most of the time because most of the things you can do in git you can do easier/simpler in hg - at least for the most usual cases. After a short intro to hg people will keep using it happily ever after, whereas the git user will keep coming back to StackOverflow questions to find out how to hard reset to head after rebasing from origin and rewinding. Speaking of SO, this quote matches my thoughts exactly: "It seems to me, that people using Mercurial are not so easily impressed. This is reflected in how each system do what Linus described as "the coolest merge EVER!". In Git you can merge with an unrelated repository by doing: git fetch <project-to-union-merge> GIT_INDEX_FILE=.git/tmp-index git-read-tree FETCH_HEAD GIT_INDEX_FILE=.git/tmp-index git-checkout-cache -a -u git-update-cache --add -- (GIT_INDEX_FILE=.git/tmp-index git-ls-files) cp .git/FETCH_HEAD .git/MERGE_HEAD git commit Those commands look quite arcane to my eye. In Mercurial we do: hg pull --force <project-to-union-merge> hg merge hg commit" I would like to read your insights related to efficiency.
- bayesianhorse 13y agoI've been a Vimp too... I knew about vim for years, sometimes trying the switch, but it never stuck. By now, it did stick. What finally convinced me the most is that a lot of really smart people not only use it but have developed a fierce loyalty to this text editor.
- paozac 13y agoIn the last 15 years I remember having used as my main editor: TextPad, Vim, KEdit, Textmate, Vim (again), Sublime Text. I consider myself a decent vim user, but went back to non-modal editors, they feel more comfortable to me. My muscle memory works best with "synchronous" keyboard shortcuts (ctrl-alt-shift-whatever) rather than "fluent" vim-style commands like ciw, ct" etc, that require a mental context switch. It's important being able to use vim, because sooner or later you'll edit some files on a remote server, but I don't understand the enthusiasm of so many people for it. Vimscript is horrible BTW.
- clarry 13y agoThere are other editors out there. I edit files on remote servers regularly, but I've never used vim for that.
- shandip 13y agoI don't understand this nostalgia with shell editors, just move on and use something like sublime text.
- johncoltrane 13y agoFirst mistake: starting with someone else's config. Second mistake: using a distribution. Third mistake: forking a distribution, itself built by amateurs, after only three months and advertizing it on the net. Seriously, when did parents stop teaching the value of patience (among other values) to their kids? You are the one in charge of your config, people, not some random guy on the internet.
- wmalik 13y agoI wouldn't recommend using a vim distribution. They have some good features but they also tend to add bloat to your vim and make it slow. They also impose a certain workflow which might not be suitable for everyone. I have been using vim full time for more than an year now, I started with an empty vimrc. Now I have about 200 lines, and I added all of them on a need basis. Text editor is the most important piece of software in my workflow (or probably any developer's workflow), so I want it to behave exactly like I want.