Live data from Hacker News

VIM Pays Excellent Dividends: Learn it early, if you can

medium.com

41–50 of 65 posts

Re: VIM Pays Excellent Dividends: Learn it early, if you can

#41
If I could go back in time and change one thing about my computing, it'd be to learn proper ergonomics and posture from the beginning and avoid the pain that came later. I often have to type slower than I can to avoid pain. I realize now that all the frenzy to get the ideas out as quickly as possible probably gained me very little time in exchange for a lot of pain. These days, a tool that might increase my data entry speed by 5% doesn't even make it onto the radar because my primary concern is my health and getting rid of RSI. Speed is antithetical to that. Interestingly enough, whether going full speed as before or in a more controlled manner like now, my actual productivity is the same.

Re: VIM Pays Excellent Dividends: Learn it early, if you can

#42
Ignoring generalities. For me, there are clearly times vim is the more efficient tool. I find that to be more often the case than not. At a minimum, learning it allows me to think about things differently than the standard wysiwyg editors. These both make me a better dev. But ultimately, using vim makes me happy. That's what matters to me, and should matter to others as they pick their tools.

Re: VIM Pays Excellent Dividends: Learn it early, if you can

#43
post #30

I can't claim to have ever "tried" to get into vim - in the sense of ditching my daily driver (Sublime/VS Code) and going 100% vim. I've done the vimtutor, I even know how to do basic text editing (cut, copy, paste, find-and-replace, visual mode highlight) in vim, plus some of those "magic" things where you can repeat an action multiple times (:2wi or whatever). And I'll happily fire up vim if it's something really q…

#1 I have been using pathogen since I started using vim, I can recommend it. (copy paste directions to install: https://github.com/tpope/vim-pathogen ) And this is where you can find vim plug-ins: http://vimawesome.com/ After installing pathogen, to install a plug-in: cd ~/.vim/bundle git clone and you are done in most cases, some require adding a few lines on ~/.vimrc. #2 There are multiple ways to work with multipl…

> I have been using pathogen since I started using vim

Thanks for the recommendation. The trouble (and again, maybe this is down to my lack of research) is that other commenters will recommend Vundle with links to similar resources (and I've tried both Vundle and Pathogen, sometimes one after another, ruining my ~/.vim dir :P). I can find all of these recommendations myself but (maybe I'm wrong here) there's no clear winner in the vim ecosystem. There's no single de-facto manager that's used by 90% of all vimmers. Hell, I know people who I think maintain their vim plugins and config and scripts using only git, so maybe a package manager isn't even that much of a priority for many users.

> There are tabs in vim, split screens, files in buffer etc, these are all without plug-ins.

Agreed, but cursory research tells me that you have to type multiple characters to switch between files. For example, the documentation page on buffers: http://vim.wikia.com/wiki/Vim_buffer_FAQ lists about 20 different buffer navigations (bNext, bnext, bprevious etc (and why there's no bPrevious is a big fat ¯\_(ツ)_/¯ )) but not a single command for toggling between two open files, a pretty common use case. Whereas text editors like Sublime leverage the already-known (from using browsers) Ctrl + T shortcut and provide you this really necessary action in fewer keystrokes (1 vs Esc (or your Esc shortcut key) + :bNext = 7 assuming there's no shortcut for "Next" though there probably is).

> There are multiple ways to work with multiple files.

And maybe that's the problem. There are multiple ways to do everything (multiple files, plugin management etc) rather than one "best" or "recommended" way that works for most users. This is understandable for a hacker's tool; options and flags rather than intelligent defaults. But it leaves newcomers somewhat adrift. I'm not criticizing the tool itself; Bram Molenaar and co. are doing an amazing job and we should all be grateful for such a high-quality tool that's freely available on practically every nix. Something like a canonical beginner's vim config that's aggressively maintained and everyone knows about would be nice though.

EDIT: How do you type a "*"?

EDIT: Looks like switching buffers (which I think is the same as toggling between files) is :b#, which is still 4 characters vs 1. http://vim.wikia.com/wiki/VimTip686#Switching_to_the_previou...

Re: VIM Pays Excellent Dividends: Learn it early, if you can

#44
post #38
post #30

I can't claim to have ever "tried" to get into vim - in the sense of ditching my daily driver (Sublime/VS Code) and going 100% vim. I've done the vimtutor, I even know how to do basic text editing (cut, copy, paste, find-and-replace, visual mode highlight) in vim, plus some of those "magic" things where you can repeat an action multiple times (:2wi or whatever). And I'll happily fire up vim if it's something really q…

You should give spacemacs a look: vim mode in emacs plus all the stuff you are missing from the other editors. I don't use it because I am a happy vim user and more recently vscode using vim mode : the best of both worlds.

I've never used emacs, so it's not immediately obvious to me how that's better. I'll give it a shot though, thanks for the recommendation.

Re: VIM Pays Excellent Dividends: Learn it early, if you can

#45
When I read articles about vi/vim being great for coders I always wonder how you deal with having to use the same part of your brain for writing the code you are writing and to "code vim commands"

I mean, I understand it's attractive to a programmer's mind to be able to do fancy 'replace the next 3 words with x' and so on, and compose them in vim's language, but if I am deep in an algorithm the last thing I want is to have to context switch to "programming my editor"

When doing editing tasks in a more visual as opposed to programmatical way, it feels more that my "coding brain" is free to continue working on the algorithm at hand while some other part of my brain deals with the moving of text around.

Keeping the right cursor key pressed for 1 second is a lot slower than doing some fancy move to the X word in the line, but if engaging my brain to create the composite "move to the X word" command takes me out of the "flow state" I am in, it is way way way more expensive in the long run. In the end what you want is to be the most productive, and the most productive could mean that you are using the editor less efficiently because the more efficient parts of your brain are busy doing something else.

Not sure, maybe somebody that started with vim as their first editor does not have this context switching issue, I personally started with emacs and remained with it and I have my emacs config full of hyper / super / meta / alt / control / shift shortcuts and tons of cool packages, but while I am deep in coding flow state I still use the cursor keys with minimal package help (outside of multiple-cursors and macros sometimes) to avoid getting distracted.

Re: VIM Pays Excellent Dividends: Learn it early, if you can

#46
post #14

I've been interested in using vim and am not completely useless at using it, but I haven't quite been able to commit to it. The main reason is that I'm not sure it's any faster than using IntelliJs products well. Last time I mentioned to a coworker who is a vim user, that I was thinking if switching to it, he said he was thinking of switching to Idea after seeing me use it.

you can always learn vim stuff by using a plugin for your favorite editor. I'm frustrated quite a bit if I have to use an editor without basic vi shortcuts at the very least.

Thanks I'll start there. I keep feeling like I'm missing out on something by not being a Vim expert.

Re: VIM Pays Excellent Dividends: Learn it early, if you can

#47

When I read articles about vi/vim being great for coders I always wonder how you deal with having to use the same part of your brain for writing the code you are writing and to "code vim commands" I mean, I understand it's attractive to a programmer's mind to be able to do fancy 'replace the next 3 words with x' and so on, and compose them in vim's language, but if I am deep in an algorithm the last thing I want is t…

I am actively using a vim-like control scheme for almost any text I write for about 15 months now. I certainly am not the most proficient in it (in fact, I suspect I could do much better if I weren't "confined" to VS and VSVIM at work - I use Spacemacs privately), but I have enough "training" to make the basic moves I need unconciously. If you come from more limited IDEs or text editors this alone is already well worth it. And at the moment when you understand the basic gist of macros on top of that, it basically becomes a superweapon.

I'm sure there's something to get out of being an "expert Vim user", but even if you're starting out, there's already much to be gained from the simple routines. I find the notion of a "Vim Kata" very compelling as a metaphor, since it's really the repetition that teaches those "reflexes" at first.

I don't know how much an avid Emacs user could get out of it though. I guess that comes down to personal preferences. I couldn't get myself to memorize all the weird key combinations for example, but I quite like Spacemacs' mnemonics system.

Re: VIM Pays Excellent Dividends: Learn it early, if you can

#48

When I read articles about vi/vim being great for coders I always wonder how you deal with having to use the same part of your brain for writing the code you are writing and to "code vim commands" I mean, I understand it's attractive to a programmer's mind to be able to do fancy 'replace the next 3 words with x' and so on, and compose them in vim's language, but if I am deep in an algorithm the last thing I want is t…

I'm not a super advanced Vim user (I mostly use hjklbw with numeric prefixes to get around) but it's all muscle memory, and I don't ever feel like I'm context switching.

Re: VIM Pays Excellent Dividends: Learn it early, if you can

#49
post #46

Earlier quoted context omitted.

you can always learn vim stuff by using a plugin for your favorite editor. I'm frustrated quite a bit if I have to use an editor without basic vi shortcuts at the very least.

Thanks I'll start there. I keep feeling like I'm missing out on something by not being a Vim expert.

the basics of vim are easy... it's a language to manipulate text with mnemonic shortcuts for the most part and composeable actions.

`daw` is delete around a word(includes the ending space if there).

`ciw` is change inner word.(change the word under the cursor by deleting it and leaving you in insert mode to make changes).

`ci"` is change inside the double quotes.

p is put or paste

d is delete

c is change

f is find

a is insert [a]fter

first answer here[1] is a classic.

1. http://stackoverflow.com/questions/1218390/what-is-your-most...

Re: VIM Pays Excellent Dividends: Learn it early, if you can

#50
post #43

Earlier quoted context omitted.

#1 I have been using pathogen since I started using vim, I can recommend it. (copy paste directions to install: https://github.com/tpope/vim-pathogen ) And this is where you can find vim plug-ins: http://vimawesome.com/ After installing pathogen, to install a plug-in: cd ~/.vim/bundle git clone and you are done in most cases, some require adding a few lines on ~/.vimrc. #2 There are multiple ways to work with multipl…

> I have been using pathogen since I started using vim Thanks for the recommendation. The trouble (and again, maybe this is down to my lack of research) is that other commenters will recommend Vundle with links to similar resources (and I've tried both Vundle and Pathogen, sometimes one after another, ruining my ~/.vim dir :P). I can find all of these recommendations myself but (maybe I'm wrong here) there's no clear…

Watch this three minute video or view the concise notes below it for some very nice tips on handling buffers.

http://vimcasts.org/episodes/working-with-buffers/

> You can quickly jump between the active buffer and the alternate buffer using the command . Pressing it again takes you back to where you were before.

If you don't like the command for this, you could map it to something else, such as the tab key, with a line in your .vimrc:

  nnoremap  
----

> There's no single de-facto manager that's used by 90% of all vimmers.

Most recently updated plugins work with each of the managers. I use a handful of plugins with Pathogen, but the same plugins could be used with another manager.

However, the latest release of Vim now includes a built in plugin system, does that satisfy your need to have one blessed version?

https://shapeshed.com/vim-packages/

----

> 20 different buffer navigations

Keep in mind, all these commands can be shortened to the smallest unique prefix. So with `:bn` and `:bp` you can go forward and backward. But if you don't like typing three characters, just sacrifice something else by remapping it in your .vimrc!

----

> toggling between two open files, a pretty common use case

When I am working on two files at once, I'll usually put them both up at the same time. If I have "a.txt" open and I also want to work on "b.txt" I can type `:vsp b.txt" and now I have them up side-by-side. I can switch between them with whatever command I have set up to do that.

Post reply on HN