9 ms·
Vim – Minimal Setup Explained
- softwarebeware 5y agoMy “minimal” setup is nothing. I just use vim the way it is, out of the box.
- JNRowe 5y agoWhile the information in there is good, a bunch of the settings are now redundant¹. The ones that jumped out to me were esckeys, ruler and showcmd. Not that I'm saying you can't — or shouldn't — re-set options, just that the linked documentation is a little dated. FWIW, I personally re-set a couple of default options mostly so that I have a point of reference for how an option works when I'm digging about in my config. I'm of the opinion that the combination of recent vim and Tim Pope's sensible.vim² is The Minimal Setup™. ¹ The site says the last update was 2014, and back then $VIMRUNTIME/defaults.vim wasn't a thing for example(7.4.2111). ² https://github.com/tpope/vim-sensible https://github.com/tpope/vim-sensible
- johncoltrane 5y agodefaults.vim was and still is an abject idea that we sadly can't get rid off, now that it has been there for a few years. The least desirable property of defaults.vim is also present in sensible or in system-wide vimrcs written by package maintainers: you get a black box where things are added/changed/removed without your knowledge or consent. "Your" so-called minimal setup is going to evolve over time, but not according to "your" needs. We got so many support request related to that silly mechanism that's not even funny.
- tremon 5y agoSame here. Vim's new "default" to tie middle-click paste to vim's buffer rather than the X selection drives me up the wall, every time. It's not just that I have multiple machines to administer, it's that there's multiple users (roles) to configure separate things. And for every user my default workflow is now broken. I've given up on vim. I'm now teaching myself Emacs on my own machine, and replace vim with neovim everywhere I can.
- sharperguy 5y agoEvery time I use vim on server that doesn't have my .vimrc file that I copy around I inevitably end up googleing "disable mouse in vim"
- dsr_ 5y ago:set mouse=''
- johncoltrane 5y agoLooks like you should look it up, too.
- gpvos 5y agoI took a second to see who the "we" is in your last sentence. The site vimways.org is unusable because its certificate has expired. Also, amen. Having used vi since before vim, I actually have a few settings to restore vi features and quirks that I like ( cpoptions+=vxZ!$- ).
- johncoltrane 5y agoYeah, I know about the certificate issue but the person who can fix that appears to be unreachable. I hope it will be settled soon.
- orsenthil 5y agoRIP Sven Guckes. I remember finding this page very helpful. Thank you.
- shmerl 5y agoOne of the things that annoys me about default vim (nvim more exactly) behavior is that it shifts the cursor left when exiting Insert mode. I use this to disable it: au InsertLeave * :normal `^ That goes along with this: set virtualedit=block,onemore
- danschumann 5y agoFor me, minimal setup means installing on a fresh machine. At this point, my vimrc automatically installs plugins if they're not installed.. otherwise it's one command. So it's just copy/paste and maybe one run command, and then vim environment is exactly the same on the new machine (it auto downloads).
- markus_zhang 5y agoQuestion for Vim users: how do you get used to hitting Esc very often? I know some switch Cap with Esc but still clunky.
- sbankowi 5y agoI type using my old Sun keyboard still. The escape key is where the tilde key is on normal US PC keyboards. So the pinky stretch is quite easy. (Also the control key is where the caps lock is. Also another fine position.) :)
- nabogh 5y agoI've bound it to double J in my vim configuration file. First thing I do on every computer.
- kiwijamo 5y agoI've just got used to over time. It's gotten to the point I accidently use vi keybindings in other applications. Luckily there's keybindings in common applications e.g. typing / followed by a search phrase works in Firefox as it does in Vi which is pretty cool.
- danhab99 5y ago
- dosethree 5y agohow is using cap clunky? works great
- ambrose2 5y agoNot a great answer, but I switched Cap with Esc and it took several months before I was hitting Esc automatically like you might Ctrl + s a document when stopping typing.
- krat0sprakhar 5y agoI use `jk` or `jj` instead of esc. Its so much easier imap jj <ESC>
- asicsp 5y agoSee also `:h defaults.vim-explained` (https://vimhelp.org/usr_05.txt.html#05.3 https://vimhelp.org/usr_05.txt.html#05.3) which now comes by default. You can either copy the settings you are interested in or source it entirely in your vimrc file: source $VIMRUNTIME/defaults.vim --- Here's some more related resource links: * stackoverflow: useful .vimrc tips - (https://stackoverflow.com/q/164847/4082052 https://stackoverflow.com/q/164847/4082052) * vi.stackexchange: How do I debug my vimrc file? - (https://vi.stackexchange.com/q/2003/1616 https://vi.stackexchange.com/q/2003/1616) * vim-sensible - (https://github.com/tpope/vim-sensible https://github.com/tpope/vim-sensible) * minimal vimrc for new users - (https://gist.github.com/benmccormick/4e4bc44d8135cfc43fc3 https://gist.github.com/benmccormick/4e4bc44d8135cfc43fc3) * Vim Configuration From Scratch - (https://marcgg.com/blog/2016/03/01/vimrc-example https://marcgg.com/blog/2016/03/01/vimrc-example) * vimconfig: generate `.vimrc` by selecting options - (https://vimconfig.com/ https://vimconfig.com/)
- johncoltrane 5y agoPlease, no. Someone else's vimrc is the last thing newcomers need.
- bikingbismuth 5y agoI sort of agree. When I was first getting into Vim, reading a couple of well documented vimrcs really helped me out.
- wyclif 5y agoI also agree in theory, but Ben McCormick's ~/.vimrc is tiny and is easy to understand for newbies, so I'm OK with it. But yes, adopting the rule that you should never put anything in your ~/.vimrc that you don't understand from building it up over time and usage is a good one.
- johncoltrane 5y agoI definitely get how looking at someone else's vimrc could be considered interesting but someone else's config is an expression of their own circumstances, that are very likely to be different from yours. Yes, picking up something that makes sense for you and that you understand _can_ be a win, but a) it doesn't replace actual learning, and b) using someone else's vimrc wholesale is not. All you get is a damn black box that you don't understand better than Vim itself… and yet more commands to learn. That's a losing strategy. As for Ben McCormick's vimrc… - line 18 is useless and its comment is misleading - line 30 is a matter of taste so it has nothing to do in that context - the comment for line 33 is wrong and shows how much the author cares about "new vim users" and how much he knows about the subject Building one's vimrc from scratch is an integral part of the learning so shortcuts are to be avoided.
- somecommit 5y agoSince I was in university 15 years ago I promised myself to learn Vim commands seriously. Well I see that finally I did my programmer life learning only switching insert mode / edit mode, maybe 5 commands like A x etc...,and :q or :wq!
- dskloet 5y agoPlease learn dot ".". It repeats the last edit action. It's so powerful.
- mbwgh 5y agoI use macros way more often than dot. With a macro I can include the movement action of getting to the correct position before the edit takes place, I'm not sure if this can be done with the dot key alone.
- johncoltrane 5y agoWhether one uses . or a macro (manual or recorded) should depend on the current situation. It's really not a "pick one and stick with" it kind of situation.
- Lio 5y agoI agree, so many ways to do it it’s horses for courses. Eg from the first “pick” you could press * to highlight occurrences and move to the next one use cw to change it to “s” and bounce on n to move to the next one you to squash and use . to repeat the change. That’s visual and lets you decide which commits to squash. If I wanted to squash all the other commits I’d probably use visual block and } instead, but that’s just me. I’d save a macro for more complex edits.
- ohmahjong 5y agoI relate quite heavily to this when using vi to do all my git-related activities. git rebase -i ... followed by ↓dw ↓←dw ↓←dw ↓←dw ↓←dw ↓←dw i s ↓s ↓s ↓s ↓s ↓s because I keep forgetting :s/pick/s/g is a thing i, a, :q, :wq, dd, xdd, and D are all the ones I remember, but cutting/yanking pasting is still something I don't have the muscle memory for. Shift+G takes me to the bottom of a file, but I don't know how to get back to the top :D . I really need to make time for vimtutor and commit to it.
- 29athrowaway 5y agoMany decades ago, you had to resort to abbreviations so that you could use memory in the most efficient way possible. Computer hardware at that time was more expensive than labor. People having to adapt to how computers worked was the doctrine at that time. But in 2022, this is no longer true. Even the most limited platform you can think of can comfortably run vim. A $5 Raspberry Pi Zero is overkill for vim. And now, labor is more far more expensive than hardware. So, economically, having commands like "set ek" are objectively a waste of resources. Make commands self-explanatory, drop the abbreviations, and just add autocomplete and suggestions to compensate for the verbosity. It's time to evolve. The reason this page exists, is because vim is unintuitive. But it doesn't have to.
- yjftsjthsd-h 5y ago> Make commands self-explanatory, drop the abbreviations, and just add autocomplete and suggestions to compensate for the verbosity. Vim has autocomplete. That said, while I support long commands, I like having short commands because it's less typing, and I use vim on awkward keyboards where it matters. Also, any changes need to leave the old way or you break people's muscle memory (so again, just add the friendlier versions in addition, not as replacements, and I'm probably on board).
- darrenf 5y agoQuite apart from the fact that many (most?) vim short forms have long form equivalents, and vim has autocomplete - this argument feels misguided to me, mostly because I don't see why it would be limited to just vim. It seems natural, if you hold such a position, to also advocate abandoning CLIs like `ls`, `cd`, `jq`, `aws`, et al? - and I would despise having to put up with stuff like: $ change-directory foo/bar $ amazon-web-services elastic-compute-cloud describe-instances $ javascript-object-notation-query ... Not to mention short parameters: `ls -AF`, `grep -v`, `curl -H`, ... One of my most valuable resources is time. I would rather invest it in learning each tool's vocabulary than spend so much time typing (a prefix longer than the existing name, tab, then pick the answer) in an "everything is spelt out in full, acronyms and abbreviations are banned" world.
- 5y ago
- Danielle69 5y ago[flagged]
- tuxlifan 5y agoTIL: nocp is so much shorter than nocompatible :-) I just really really wish my minimal comfortable setup would not need to include set mouse= on all "newer" machines/vim versions :-\
- CollinEMac 5y agoThe only thing I've really struggled with when trying to get into using vim full-time is navigating my project. In VSCode I basically hit CTRL+SHIT+F -> "portion_of_a_function_name_or_something" constantly. I abuse the heck out of global search. Is there a way of navigating your project in vim that's similar/easier? How do vim people quickly navigate their code without going "what was the name of that file with that function"?
- so_this_is_me 5y agoI use neovim now and have switched my search over to using Telescope.nvim which is a fuzzy search basically. It lets you do pretty much what you say allowing me to type <leader>-f and partially type things to remember where I am with a preview pane. Seems moderately fast most of the time for the monolith I work on.
- infinitezest 5y agoThe only catch with this is that it's neo vim only. It works incredibly well and can fuzzy find lots of things not just files.
- ZeroGravitas 5y agoHistorically, people used :grep and the quicklist to jump between project files based on abitrary strings and Ctags to generate a language specific index of functions, variables which you can jump to. These days people generally use some kind of fuzzy finder plugin thats basically the same as the vscode experience. Exactly which one you use depends on various factors, but Telescope and Fzf are two big names and both allow searching through a bunch of other stuff, setting names, edit history etc. (You can also save the fuzzy search results to the quicklist so you've basically got a reusable index). And neovim is heavily embracing the LSP paradigm, where you'd use something like gd to jump to definition when on top of a function and a language specific LSP server will tell Neovim where to jump to.
- chestervonwinch 5y ago
- swah 5y agoI prefer VsCode these days - but every now and then a Vim macro is needed - the rare case where multiple cursors won't cut - I just C-p Open in Vim [1]... for fun and saving a few minutes (not always) [1] https://marketplace.visualstudio.com/items?itemName=jonsmithers.open-in-vim https://marketplace.visualstudio.com/items?itemName=jonsmith...
- PestoDiRucola 5y agoDoesn't the VSCode vim plugin support Vim macros as well?
- swah 5y agoI think it does - at least the NeoVim one should. (But I feel like I'm faster with regular VSCode - multi cursors easily solve many "text editing" problems that Vim solves with macros/repeat/regexp)
- xaxaxb 5y agoFound the post pretentious
- dsr_ 5y agoDid you not like the style, or the content? Do you have a better alternative to suggest?
- xaxaxb 5y agoI found it pretentious on first read. The first feature: `nocmp` is not explained well enough and is vague. What is buffer in `hidden`? Not beginner friendly. As a neovim user, I haven't had the need to all these settings.
- sheerun 5y agoAnother take on this: https://github.com/sheerun/vimrc/blob/master/plugin/vimrc.vim https://github.com/sheerun/vimrc/blob/master/plugin/vimrc.vi... You can use it as plugin