12 ms·
Intermediate Vim
- ryannevius 8y agoI'm not sure I'd call any of this "intermediate" Vim. Most of it appears in vimtutor, and the rest in the "basic editing" portion of the reference manual.
- hyperpallium 8y agoVim: difficult to learn, difficult to master. Most of it is "intemediate".
- knolax 8y agoAs a Vim user one of my gripes when first using Vim was how cumbersome the built in help files were. I guess that's why there are so many "vim cheatsheets" out there, the built in documentation is a pain to use.
- preommr 8y agoThe biggest pain in vim is the escape key. And no, ctrl+[ isn't any better.
- isostatic 8y agoI have capslock mapped to escape and never notice which one I use (started doing that after my escape key broke on a laptop about 15 years ago) I believe people with poor keyboards don't even have escape keys any more though
- jwilk 8y agoWhat do you mean by "poor keyboards"?
- opan 8y agoI imagine poor is a measurement of quality rather than personal wealth here. MacBook keyboards with the touchbar come to mind.
- isostatic 8y agoMy collegues are constantly complaining their (mac) laptop keyboards are terrible, however aren't ballsy enough to say "F-U" to the corporate choice of a mac or a windows laptop.
- pcr910303 8y agoWell, HNers complains the MacBook keyboard as it’s a complete trash, but please remember that there are plenty of people that likes and even loves the butterfly keyboard. The keyboard itself is pretty awesome and provides much stabler keys than usual keyboards (whether it’s membrane or mechanical). They work regardless of what part of key I press, which means that typo rates significantly decreases. I’m happily using my MBP’s butterfly keyboard with Vim. Just please, don’t say keyboards are terrible after using for a few hours. There’s a reason why Apple is keep placing the butterfly keyboards in top-range Macbooks.
- isostatic 8y agoI'm not saying it, the people using them all the time are saying it. I'm happy with the generic HP keyboard I'm using at the moment, circa 2014, and my T410s old style thinkpad keyboard.
- patrickdavey 8y agoI added this very handy little mapping a while back: noremap! kj <esc> it means when you press kj [0] that it's the same as pressing escape.. very handy (the times when I deliberately want to press k and then j are still zero) [0] https://github.com/patrickdavey/dotfiles/blob/335254dce90d5c478d66319ce0d6562b17b7ddbe/vim/.vimrc#L128 https://github.com/patrickdavey/dotfiles/blob/335254dce90d5c...
- intertextuality 8y agoWhy is ctrl-[ not better? You split the workload between two hands. You -do- have the useless, enormous capslock key remapped to control, right? ;-) Anyway, it's common to remap jj or jk to esc.
- bingerman 8y agoMapping Capslock simultaneously to both ESC and Control solved this problem for me. It might not be your piece of cake but it definitely improved my vim experience greatly. See for example (I'm not the author) https://www.dannyguo.com/blog/remap-caps-lock-to-escape-and-control/ https://www.dannyguo.com/blog/remap-caps-lock-to-escape-and-...
- srik 8y agoRespectfully disagree. I think vim's help documentation is quite good. The inbuilt reference is extensive and with examples as well. Perhaps it's navigating the :help window you find cumbersome?
- zahreeley 8y agoGreat article
- dhotson 8y agoHey all, I'm the author. Feedback is welcome! :) The reason I wrote this is because I've been pair programming quite a bit lately and also mentoring some new vim users—so I wrote this little guide to help vim beginners level up their skills a bit. What I noticed is that a lot of vim beginners find composing commands and text-objects to be kind of mind blowing.. and even more experienced vim users mentioned that these were the things that made them have that "aha" moment and convinced them to learn more.
- jakecopp 8y agoI think the concerns others have mentioned about the title/content level are valid, but even though I knew most of the commands I enjoyed reading this! I quite liked your writing style and page design.
- dmortin 8y ago> I've been pair programming quite a bit lately Does it mean both party have to use the same editor? I wouldn't participate in a pair programmnig like that. Pair programming is best when everyone can use one's favorite editor. When there is a pair switch there is also an editor switch if the other party prefers a different editor.
- jhoh 8y agoGreat article! The features you showed were some of the ones I've had my first "Oh, now I get why vim is so great"-moments and that really boost your productivity. > Tip: Generally after you’ve inserted some text, you want to return to command mode so that you’re ready to enter your next command. I’d recommend pressing esc any time you’ve finished typing. Totally agree with this. What really helped me with getting this into my muscle memory was remapping Capslock to ESC which seems to be what many (most?) vim users do.
- bingerman 8y agoSome of us even prefer mapping Capslock to both ESC and Control, as explained for example here (I'm not the author): https://www.dannyguo.com/blog/remap-caps-lock-to-escape-and-control/ https://www.dannyguo.com/blog/remap-caps-lock-to-escape-and-...
- stevebmark 8y agoThis is less than beginner Vim, certainly less than vimtutor, and far less than any other Vim tutorial I've seen. This makes the title feel like clickbait.
- dhotson 8y agoHey yeah thanks, it's really difficult to know where to start and how much to cover in an article like this. I think I agree now that the title isn't quite right—my intention was to help beginners get towards some intermediate topics.
- mikekchar 8y agoWhat about "Towards Vim Fluency"? Just as click-baity, but maybe a bit more precise ;-) BTW, even though I've used vim for a long time and consider myself fairly advanced, I had somehow forgotten about "I". You've saved me countless "^i" invocations... Wait... That's cording! It's cheating :-) (But it's OK because I'm a closet Emacs fan)
- declank 8y agoI use Emacs/Evil for hobby programming and vi for quick edits on servers. Wish I had this guide years ago. Incredibly helpful. :)
- manjana 8y agoAdding one to the great article: Shift+k on a word to enter the corresponding man-page if such one exists :)
- dredmorbius 8y agoThat command can be remapped according to context. For email and other prose, I set it to 'dict' instead.
- sepisoad 8y agoI liked it, as someone who has just started learning vim. Thanks.
- asadjb 8y agoI feel composing commands is where the real power of Vi(m) comes from. This can be really helpful to someone just starting out with Vim. I got a boost in my Vim productivity after reading a similar StackOverflow answer a couple of years ago. It's a nice read for people familiar with Vim, and another good resource for new users. "Your problem with Vim is that you don't grok vi." https://stackoverflow.com/a/1220118 https://stackoverflow.com/a/1220118
- jnurmine 8y agoMaybe you can cover macros since they are conceptually very simple and very powerful. They may seem a bit complex but are quite simple. Basically you just record your editing movements and play it back. How macros work: press q x to record and q to end. Then repeat with @ x, where x is the name of the macro you want to use (you can have several macros). Anything you do will be played back. That's it... Conceptually simple. A nice trick is to record a macro for a single line and place the cursor on the start of the next line at the end of the recording. This way it's possible to operate upon large blocks of text in a similar way by just repeating the macro. The key then is to use generic movements like "go to the beginning of line" (^), "go to the end of line" ($), "skip word" (w), etc. As a silly toy example, if you have a list of strings in a text file, you can turn it into a list of quotes with (from the top of my head): qx<Home>i"<Esc>$i<Right>",<Down><Home><Esc>q (Record macro, go to beginning of line, insert mode, write a quote, exit insert mode, go to end of line, insert mode, move right, write a quote and a comma, move down to next line, move to the beginning of line, exit insert mode, end macro recording) Then to process 100 lines, you'd do: 100@x That turns these: alpha bravo charlie delta ... into "alpha", "bravo", "charlie", "delta", ... If you have hundreds of lines of that you'll start to appreciate the easy automation. I use macros to do drive-by mass-edits without resorting to sed, scripting, regular expressions etc. since the cognitive load of those is higher for me. Edit: formatting
- isostatic 8y agoI've used vim for a couple of decades, but never pushed to many advanced features. For your example above I'd do :%s/^/"/ and :%s/$/",/ Unless I use a feature regularly I find it's a higher cognative load. I use bash, sed and perl regexps on a near daily basis. Macros are very rare.
- jermy 8y agoLikewise - with visual mode it's normally pretty quick to select an area and do a basic regex, even for things like re-indentation (auto-completes to something like :'<,'>s/^/\t/) even though I'm sure there's a 'proper' way to do that
- cranium 8y agoOne thing I miss on Vim I have on Spacemacs with the Evil layer is the "a" object (for "argument"). With it I can delete/change an argument of a function in a flash. Example (cursor on the last arg): importAntigravity(usePython, crashTheUniverse) <type daa for "delete an arg"> importAntigravity(usePython)
- url00 8y agoThis does that in Vim: https://github.com/wellle/targets.vim https://github.com/wellle/targets.vim I use it all the time! The only reason I don't use Spacemacs is the startup time/GUI lag, but if it works for you keep at it!
- Lathie 8y agoRunning emacs as a daemon will get rid of the lag :)
- aoeusnth1 8y agoAs an emacs refugee, I disagree. I tried everything to get rid of the lag and it just became unbearable after having significant exposure to vim through pair programming. Now I just use Vim instead of trying to get Emacs to work like Vim.
- dredmorbius 8y agoRecommended: Learn vim For the Last Time: A Tutorial and Primer https://danielmiessler.com/study/vim/ https://danielmiessler.com/study/vim/ Mastering the Vim Language https://youtube.com/watch?v=wlR5gYd6um0 https://youtube.com/watch?v=wlR5gYd6um0 An Incremental Approach to Vim https://ctoomey.com/writing/an-incremental-approach-to-vim/ https://ctoomey.com/writing/an-incremental-approach-to-vim/
- isostatic 8y agoThe defaults in vim 8 in debian and ubuntu really changed the way vim worked, it was horrendous As far as I'm concerned, the following is an non-negotiable requirement for vimrc. source /usr/share/vim/vim80/defaults.vim set noincsearch set scrolloff=0 set mouse=
- jermy 8y agoJust to extend this - if you're often using different users (or need to otherwise deploy via a configuration manager), I've found out that a good way of having system-wide options on Debian is /etc/vim/vimrc.local with something like: " Workaround stupid defaults.vim behaviour if filereadable("/usr/share/vim/vim80/defaults.vim") source /usr/share/vim/vim80/defaults.vim endif let g:skip_defaults_vim = 1 " Disable stupid seeking to last position autocmd! vimStartup BufRead " Disable stupid mouse support set mouse=
- KhoomeiK 8y agoTIL I'm an intermediate user of Vim! /s I think this is pretty basic in terms of general vim commands. Navigation and insertion are all basic use cases that beginners should know. That said, the section about composing commands was really interesting!
- msaharia 8y agoThat's what I was thinking! These are pretty basic.
- tutfbhuf 8y agoI think I need the expert guide.
- intertextuality 8y agoIt exists, it's called :h(elp). I've barely begun to delve into the mountain of documentation that is :h. You can read Pro Vim or Modern Vim as well.
- cbzbc 8y agoOn an Ubuntu box install the nvi-doc package, in /usr/share/doc there'll be two documents vi.beginner and vi.advanced. Open the latter with vim and it'll teach you the more advanced commands.
- Ice_cream_suit 8y agoDisappointingly elementary. Even I, an Emacs user who occasionally uses vi am familiar the material in this. Can anybody suggest any real intermediate vi material?
- throwawaylolx 8y ago>Can anybody suggest any real intermediate vi material? http://vimcasts.org/episodes/ http://vimcasts.org/episodes/
- LocalPCGuy 8y agoBeginner vim is being able to exit vim successfully, knowing how to hit i to insert text, and how to save your file. Just because you are familiar with it doesn't mean it isn't intermediate, it just means you are already intermediate.
- throwawaylolx 8y agoIf this is considered "intermediate," then for more advanced Vim tips I recommend http://vimcasts.org/episodes/ http://vimcasts.org/episodes/
- rezeroed 8y agoThese are the basics, not intermediate. Otherwise what are the basics - just i and esc? Undo and redo are intermediate? Nope.
- robertlf 8y agoIf this is intermediate, then I must be an expert.
- chapium 8y agoIts so easy you can become an expert in merely hours :)
- robjwells 8y agoI’d highly recommend Drew Neil’s Practical Vim[0] for much more like this; it’s broken down into easy chunks and gets into the _why_ as well as the _how_ of Vim’s techniques. Modern Vim[1], mentioned elsewhere in the comments, covers more advanced Vim usage. [0]: https://pragprog.com/book/dnvim2/practical-vim-second-edition https://pragprog.com/book/dnvim2/practical-vim-second-editio... [1]: https://pragprog.com/book/modvim/modern-vim https://pragprog.com/book/modvim/modern-vim
- wodny 8y agoDrew Neil also created great video tutorials, the vimcasts[1]. [1]: http://vimcasts.org/episodes/ http://vimcasts.org/episodes/
- opan 8y agoThe balloon comparison is strange. I would've just said that adding shift to a shortcut often reverses it... / for search and ? for search backwards, alt-tab to switch windows, alt-shift-tab to go the other way, ctrl-tab to go to next tab in Firefox, ctrl-shift-tab for backwards. It's incredibly common.
- Izkata 8y agoSo common, that cars shift into reverse!
- tebs1200 8y agoA well written guide for introducing some of the power of Vim to a new user. One thing I'd suggest for the author, based on a quote from the article - "Invest your time to learn new skills" - Try and invest some time to learn touch typing. I worked as a developer for years thinking that it wasn't worth the effort, but after taking a couple of weeks to learn, I never looked back. My productivity, particularly with Vim has jumped leaps and bounds.
- commandlinefan 8y agoWell I didn't think I would learn anything but I didn't know about cit/cat - very cool!
- campbellmorgan 8y agoFor anybody who's found more IDE-y activities a bit beyond the current generation of VIM plugins (looking at you Typescript), the Vim plugins for VsCode and Visual Studio are actually surprisingly good and I find myself at least as productive as I do in Vim. I imagine it might be quite a good starting point for somebody who's used to VsCode productivity but wanted to get into vim without going full vim!
- diehunde 8y agoThe problem I have with those plugins is that I use a lot of split buffers not just for editing but also for exploring directories using :Explore for example. Some IDEs+vim plugins support horizontal splits but then when you have to jump between different modes such as explorer or console they use different shortcuts. Nevertheless, I think that VIM support for IDEs has improved a lot these past years. VSCode and Jet brains have done an awesome work integrating it to their software.
- campbellmorgan 8y agoI've managed to get the classic vim `<C>-w` + h|j|k|l working in VSCode. Sadly my convenient remapping of that doesn't work :( My annoyances are pretty small: not being able to do `:e ` and then tab complete the directory structure and the fact that VSCode has splits with tabs rather than tabs with splits.
- choward 8y agoJust a warning for VSCode users, this issue still exists: https://github.com/VSCodeVim/Vim/issues/2007 https://github.com/VSCodeVim/Vim/issues/2007
- kaitari 8y agoPer the PR comments, a workaround I've been using is to have VSCodeVim use VSCode's own undo/redo stack (appended to settings.json) "vim.normalModeKeyBindingsNonRecursive": [ { "before": ["u"], "after": [], "commands": [ { "command": "undo", "args": [] } ] }, { "before": ["<C-r>"], "after": [], "commands": [ { "command": "redo", "args": [] } ] } ],
- ptah 8y agotbh this looks like beginner vim to me
- jaequery 8y ago“If you’re like me and never learned to touch type properly, just use the arrow keys, it’s fine, don’t worry about it.” Are touch typists rare these days? I feel like people these days forego even learning to type properly. I dont understand why they refuse to just learn it, it is such an essential skill to have.
- hhmc 8y agoYeah, the cost-value benefit of learning touch typing will vastly eclipse the cost-value benefit of learning intermediate vim, that's for sure.
- marcoperaza 8y agoI think it’s hard for people to make themselves dedicate the time to learn something when they aren’t forced to. A big function of school is to force people to learn things, things they could perfectly well learn on their own if they didn’t lack the willpower. I’m very grateful that my dad, recognizing back in the 90s how important a skill it was, made me learn to touch type when I was just six years old. I never got as good with the number row as with the letters, which was fine for a long time as I am very quick with the number pad, but nowadays I mostly use my laptop which doesn't have a number pad. It is a silly thing, because I could with a few minutes every day for a couple of weeks train myself to be as quick with the number row as with the letters, but I haven't and probably never will. There is no pressing need for it in my life and no one to force me to do it.
- breyerjs 8y agoWe were taught to touch type in grade school, but I goofed off during those lessons. I got through college without needing it. I was a speedy point-and-peck typist, which was good enough for that period of my life. Later on, when I learned to program, I found that my slow typing speed frequently caused me to lose my train of thought midway through a line of code. It was frustrating enough that I spent a month teaching myself to touch type. Basically, I took online typing tests over and over after work. Since then, my typing speed has at least doubled. I don't look at the keyboard anymore, and I'm able to get my thoughts down with _much_ less friction. I can't recommend it enough.
- johannkokos 8y agoI learned a new one recently. zt redraw so that current line is at top, zb redraw so that current line is at bottom, zz redraw so that current line is at the center. If you are on twitter, you might want to follow MasteringVim. You'll learn one trick every day.
- lenkite 8y agoOne thing I always wished VIM had was the generalized ability to repeat the last navigation command with "," and ";". I mean if I use "[m" to go to the previous method, then I want to be able to repeat that with ",". Never understood why ",' and ";" are only for "f" and "F"
- kaitari 8y agoAfter years of using Vim, I recently learned that I could use `Ctrl+C` instead of `ESC` to get back to command mode. Mind blown.
- simplicio 8y agoAlt+Movement is what I usually use, since it's easy to hit on my keyboard, and lets you combine dropping out of insert mode and a movement command to move you towards where you want to be for whatever you want to do next. If you don't want to move, you can just hit Alt+l as the "default" escape.
- EduardoBautista 8y agoSeveral years ago I wrote a simple blog post on ESC alternatives: https://www.eduardobautista.com/escape-key-alternatives-in-vim/ https://www.eduardobautista.com/escape-key-alternatives-in-v...
- ludsan 8y agoI use that all the time except for the case where I'm doing a visual block insert when the control-c doesn't do what an escape does.
- alanning 8y agoInteresting! I didn't know about `CTRL+C`. You may like to also try `CTRL+[`. It's the telnet escape character and seems to be a general substitute for ESC on OSX, Windows, and I think Linux too. I find it pretty quick since my hands can work together. Another handy tip I ran across was to remap CAPS LOCK to CTRL. Quite nice for both Vim and Emacs users once you get used to it.
- gfiorav 8y agoFunny, after two years on Vim, I just discovered Esc
- cheunste 8y agoHoly crap really?!? Man, that'll definitely save my pinky from cramping up every so often.
- gigatexal 8y agoLove the not shaming for using the arrow keys.
- flogfr 8y agoThe most notable tool to help improving your skill in vim (after doing the excellent vimtutor), is to go and do some vim golf. You can see the solution from just one point better than you, improving your skill gradually.
- cityhome 8y agoCityhometution is an online portal to find the professional tutors and tutor jobs which give the special and wide opportunity to the students/learners to select the best Home/online Tutor by their own choice under one roof with our unique features. We are in the field of connecting Qualified Home/Online Tutors since 2005 with an extensive experience in dealing students and tutors in a familiar way. • Trustworthy Home Tuition Providers • All Major Cities Of India • Over 12 Years Of Impeccable Service • Qualified And Verified Home / Online Tutors • Provided Tutors to Thousands Of Students Since 2005 • Our Students Are From Prestigious Corporate Schools and Colleges • Having more than 1,00,000 tutors in around In India • International Experience Trainer in Corporate Teaching For more information: https://www.cityhometution.com/ https://www.cityhometution.com/ WhatsApp : +91 9948464333