9 ms·
A Vim Guide for Advanced Users
- cryptonector 4y agoWhat, an explanation of `g` but no mention of `gq`?? :)
- navan 4y agoThere are lots of useful g commands. See also thread above talking about g commands. My favorite is g;
- cryptonector 4y agoI didn't know about many of them, so TFA was very useful for me!
- g0xA52A2A 4y agoThe best guide is built in to Vim but sadly often overlooked. https://vimhelp.org/usr_01.txt.html#usr_01.txt https://vimhelp.org/usr_01.txt.html#usr_01.txt
- asicsp 4y agoTable of contents for this user manual: https://vimhelp.org/usr_toc.txt.html https://vimhelp.org/usr_toc.txt.html (`:h usr_toc.txt`) Here's the reference manual: https://vimhelp.org/#reference_toc https://vimhelp.org/#reference_toc (`:h reference_toc`) There's also a cheatsheet: https://vimhelp.org/quickref.txt.html https://vimhelp.org/quickref.txt.html (`:h quickref`)
- marklgr 4y agoReading the docs and searching into it on a regular basis is the single best advice I could give to Vim users wanting to improve. The odd cheatsheet, the post with a few tricks and cool plugins, all those can be well and good, but nothing beats sitting down and reading the docs. I've been use Vim daily for 10+ years, and I still check help files very regularly. Knowing _how_ to search efficiently is also a skill worth acquiring. Incidentally, the same advice apply to Bash: just read the man page, and search into it each time it is needed. It is just worth it.
- thanato0s 4y agoI tried to go through it multiple time, but I couldn't: 1. It's way too long, the complete stuff is ten of thousand of lines. 2. It goes into needless details, especially at the beginning (the "finding help" section is intense for example). It turns me off each time. 3. It's too dry, not really enjoyable to read to me.
- kreetx 4y agoIs there such a thing for emacs?
- asicsp 4y agoCheck out https://www.masteringemacs.org/ https://www.masteringemacs.org/
- yakubin 4y agoThere is the info manual. C-h i
- dotancohen 4y ago> Is there such a thing for emacs? Evil ))
- asicsp 4y agoPrevious discussion: https://news.ycombinator.com/item?id=26284618 https://news.ycombinator.com/item?id=26284618 (603 points | Feb 27, 2021 | 172 comments)
- alxmng 4y agoThis is really great. I’ve recently switched to Helix editor after 10 years of vim and haven’t looked back. If you’re looking for something a bit simpler, zero configuration, but with the same philosophy as vim (select -> action) give it a try.
- johntb86 4y agoAre there any good VSCode extensions that support helix-style input?
- sp33der89 4y agoYes, you'll have to tweak the default keybindings a bit to match Helix but I am using dance successfully: https://github.com/71/dance https://github.com/71/dance
- dragonelite 4y agoIm also in the process of switching to Helix and Zellij. I like the minimal configuration of Helix compared to going through multiple git repos just to find the needed neovim config and adjust them to taste.
- jalino23 4y agoHoly cow I switch to Helix a couple months ago but its my first time hearing about Zellij and wow this is too powerful with Helix! thank you so much for this!!!!!
- xrayarx 4y agoI think the best explanation of vi is the seminal post: You don’t grok vi https://stackoverflow.com/questions/72498282/your-problem-with-vim-is-that-you-dont-grok-vi https://stackoverflow.com/questions/72498282/your-problem-wi...
- suprfnk 4y agoI think you meant this one: https://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118 https://stackoverflow.com/questions/1218390/what-is-your-mos...
- toxik 4y agoI love how this elaborate reply never mentions the obvious thing that the OP wants, text objects.
- Daunk 4y agoI enjoy using Vim, but I feel like it's a pain to use with lesser known languages. Especially when it comes to compiling and such.
- ngcc_hk 4y agoAs a beginner user for decades, some basic like visual mode is not covered even in the intermediate one. And so is plug-in not in advanced one. Not sure about this arrangement.
- lou1306 4y agoThe "g" namespace is one of the few things I find annoying in Vim (which I like a lot). It is a grabbag of operations at cursor position ("gu", "gU"), mode switches ("gn"), file operations ("gf") and... weird stuff? Like, "ga" (prints the ascii value of the character under the cursor). This really does not help with memorizing the commands. On the plus side, it enables "* + cgn + ." which is a neat way to do quick multiple substitutions, so yay I guess?
- asicsp 4y agoI imagine "g" as Vim's builtin leader mappings due to all other keys already being mapped to something else.
- lordgrenville 4y agoAgreed, that's the only time I find myself missing Emacs' which-key. (Looks like there is https://github.com/liuchengxu/vim-which-key https://github.com/liuchengxu/vim-which-key for this.)
- kagevf 4y agoMaybe it's g for "grabbag" ...
- nerdponx 4y agoThe "g" namespace is a dumping ground for "alternate" versions of things that already have normal-mode mappings. Personally I think most of the normal mode mappings make no sense, other than the core motions and "q". A lot of precious "one-key" mappings are kind of wasted. You can of course override them, but it feels very "bolted on" One of my high hopes for Neovim is that eventually they will start migrating the hard-coded default mappings to something more akin to a default config layer, which will be easier to override or disable. They have already started doing this for built-in commands, e.g. :cscope has been removed.
- Jenk 4y agoIt's on the homerow in the middle of the keyboard, equally accessible to both hands. If it were a symbol key I suspect there would be less perplexity, but because it's a letter key users are left wondering what the mnenomic is :)
- janvdberg 4y agoI keep this URL in my bookmarks: https://jemma.dev/blog/intermediate-vim-tips https://jemma.dev/blog/intermediate-vim-tips Most advanced guides throw a lot at you at once. Digesting one or few commands at a time works better for me to really make it stick (and that is the goal right?)
- SnooSux 4y agoIf I could add one thing to the list I would include `cib` as equivilent to `ci(` for changing everything in a set of parentheses (or brackets for the mnemonic's sake). For me at least the `b` is easier to reach than the `(`. I need to use `z` for refocusing more
- koningrobot 4y agoI notice it mentions Ctrl-a and Ctrl-x which "increment or decrement any number after the cursor on the same line". I hate these shortcuts because several times I've accidentally pressed them (e.g. on some level thinking I'm in Spacemacs or in readline) and introduced a hard-to-find bug into my code without knowing it.
- quesera 4y agoAgreed. I love vi, but this is almost always an anti-feature. To disable, add these lines to .vimrc: map <C-a> <Nop> map <C-x> <Nop>
- civopsec 4y agoWon’t you spot that through you source control?
- srik 4y agoShows how crucial customizability is because I don't think I can work without being being able to rely on <c-a/x>, and more importantly g<c-a/x>.
- jcul 4y agoThey can be quite useful, but I just stopped using them due to muscle memory of Ctrl-a for screen / tmux.
- dontbenebby 4y agoThanks for this. I still remind having one of the kindest TAs of my undergrad remark in a thick Ukrainian accent “ahhh, vi, a true master” and move on to helping folks use pico during a *nix programming primer. (Sometimes ppl would demand I follow the syllabus. I don’t like to follow the guidelines.) You could always use emacs if you’re into that kind of thing, but telling them you should use pico is like telling them to clean their dorm with equal parts bleach and ammonia soaked in castor beans. (Don’t do that.)
- dotancohen 4y agoTwenty years on VIM and I didn't know: gI - Insert text at the beginning of the line, no matter what the first characters are. There's always more to learn.
- johncoltrane 4y agoThe range injected for you by Vim when you do `:` in visual mode? Registers? Substitutions? Really? There is nothing advanced about this and nothing to learn for an "advanced user".
- talkingtab 4y agoThe most annoying thing about vim/vi is that after using it for twenty years I still don't know all the useful things you can do with it. To put that in context, I find vim indispensable. And adding stuff like markdown preview and fzf integration just makes the problem worse. Sigh.
- christophilus 4y agoFalse. The most annoying thing about vim is that I can’t type properly in web input boxes, email clients, rich text editors… I want vim in all the places.
- zach_garwood 4y agoI was doing a live coding challenge in some online editor the other day, and I think they were really confused as to why I kept typing "h" and "k" and "g" all over the place.
- gorjusborg 4y agoThis is me, and it has gotten worse since using the neovim extension with vscode. I used to have a mental cue that terminal was hjkl; and GUI was pointy-clicky. Now if I ever go to something like intellij IDEA, I'm spamming home row all over the code :)
- dontlaugh 4y agoIntelliJ has a pretty good vim emulation plugin, actually.
- cturtle 4y agoFirenvim may be a partial solution: https://github.com/glacambre/firenvim https://github.com/glacambre/firenvim
- aeonik 4y agoYou can do this with Emacs Evil Mode using the emacs-everywhere package. https://github.com/tecosaur/emacs-everywhere https://github.com/tecosaur/emacs-everywhere
- TheRealDunkirk 4y agoMeh. I used vim for 20 years. Got to the point of tricking it all out with some of the full-blown ~/.vim configs you can just grab from GitHub. Some of the advanced tips on that site take it into the realm of being emacs. But I found that I was basically trying to get it to be... a GUI, with NERDtree and the lot. When I discovered Sublime Text, and multiple cursors, I quickly gave up on vim. I develop web applications (mostly). I'm pointing and clicking all throughout the process, since web pages are inherently graphical. I still haven't masted all of the keybindings for ST, but I think that being obstinate about keeping my hands on the keyboard when I'm editing is a waste of mental effort. YMMV. I think my lack of being able to fly through editor options without using a mouse cost me a job once, but if a place is going to fetishize that over being a deep expert with 25+ years of experience, go for it. I can solve business problems with software. * Edited for "Sublime Text," though I don't know why I'm bothering, as this is being downvoted.
- dopp0 4y agopardon me, but what is ST?
- layer8 4y agoWhat’s ST?
- doseofgose 4y agoSublime Text, I assume
- deleted 4y ago[deleted]
- bloopernova 4y agoI think it's being downvoted because people may be interpreting the opening "meh" as too negative. Or possibly not meeting the standards of Hacker News.
- TheRealDunkirk 4y ago
- mstudio 4y agoI recently picked up a copy of "Practical Vim" https://pragprog.com/titles/dnvim2/practical-vim-second-edition/ https://pragprog.com/titles/dnvim2/practical-vim-second-edit... based on a recommendation from a comment on HN. The first chapter mentions the built-in `vimtutor` I never it existed! It was incredibly helpful with some features I'd never used such as Put, Replace and Visual mode. If you have vim, you should just be able to run `vimtutor` in the command line. If you have trouble, you can run `:help vimtutor` within vim.
- dunham 4y agoYeah, I've known and used "vi" for a couple of decades, saw someone use visual mode in a video a few months ago, and it blew my mind. I still don't know how to do project navigation in vi, as I mainly use it for editing config files. I used emacs back in the day, but vscode is what I'm currently most comfortable with for moving between files in a large, deeply nested project.
- patricius 4y agoUse fzf for file navigation and perhaps vim-vinegar. When you open Vim, use :cd to change to your project directory and you’re ready. Use :term to start stuff, e.g., a local web server or whatever. Use fzf to navigate between open buffers.
- mstudio 4y agoYou might find the ":NERDTree" plugin useful for project/directory navigation: https://catonmat.net/vim-plugins-nerdtree-vim https://catonmat.net/vim-plugins-nerdtree-vim and https://github.com/preservim/nerdtree https://github.com/preservim/nerdtree
- jb3689 4y agoThis is a good list. I need to get more comfortable with quickfix and location. I’d like to build something like the fzf plug-in some day I’d highly recommend folks learn some vimscript. Mappings, functions, commands. My most recent use for these was for quickly generating a lot of permalinks for building internal documentation. Macros and argdo are also invaluable for large scale edits.
- galtenberg 4y agoI need an Advent of Vim to practice all of these
- ZeroGravitas 4y agoTry "Vimways": https://vimways.org/2018/ https://vimways.org/2018/ https://vimways.org/2019/ https://vimways.org/2019/
- PyWoody 4y agoA useful Vi/m feature is splitting viewports with Ctrl-w + v/s. Ctrl-w + v == split current viewport vertically Ctrl-w + s == split current viewport horizontally Ctrl-w + = == resize viewports to equal height/widths You can then move around the viewports with Ctrl-w + j == move one viewport down from current viewport (if available) Ctrl-w + k == moves one viewport up from current viewport (if available) Ctrl-w + h == moves one viewport to the left from current viewport (if available) Ctrl-w + l == moves one viewport to the right from current viewport (if available) You can then :q viewports or :e to open a different file in that viewport. Maybe it's so basic it never gets mentioned but I find a lot of people under utilize it. Another good one is typing . to repeat previous command. You can do A, "something" and then just type `.` to have "something" appended to whatever line the cursor is on.
- argonaut07 4y agoI am struggling to get started on a German keyboard. Some special characters are hard to reach.
- jdrek1 4y agoI recommend using the American keyboard layout if you're doing anything remotely programming related, otherwise all the special characters are just way too annoying (even though personally there's also a few of those in the American layout that are suboptimal, but a keyboard only has so much space...). If you frequently find yourself needing German (or other European) symbols like ä then you can also look into using EurKEY [1] which is basically the American layout but gives you easy access to the "umlauts". [1] https://eurkey.steffen.bruentjen.eu/ https://eurkey.steffen.bruentjen.eu/
- FranklinMaillot 4y agoHave you tried the US-International layout[0]? It's basically the standard QWERTY US layout but ", ', ^ are dead keys used to generate diacritics. If you press " followed by o you get ö. ' + e prints é. The only thing to get used to is that if you want quotes for example, you need to press <space> or another character that doesn't accept accents after the key. I used this layout for French and it's way better than the weird French AZERTY layout. [0] https://en.wikipedia.org/wiki/QWERTY#US-International https://en.wikipedia.org/wiki/QWERTY#US-International
- argonaut07 4y agoTbh I have not. I was afraid of being slower to type or making more mistakes. But I think at least it is worth to try. Thank you.