Live data from Hacker News

Interactive Vim tutorial

openvim.com

111–120 of 230 posts

Re: Interactive Vim tutorial

#111
post #87

Alternatively, don't try to hurry enlightenment. First, learn :q! Next h,j,k,l Then i and ESC Finally :w Now you know vim. Don't let people tell you you're using too many keystrokes. Are you still reaching for the mouse? If not, you're using vim just fine. Most of the good stuff in vim, you'll learn accidentally, because you're in normal mode when you think you're in insert mode, or because you have caps lock on in n…

Sorry, but I think that's really bad advice. For one thing, it doesn't give new users any positive experience or reason to learn vim. If all you learn is to do things that are "pointless" (like learning hjkl), then you won't get any value out of vim. And if your way of learning is to do something that screws up your file and try to recreate how that happened, well, let's just say that every time I do something that s…

I think we just don't agree about what the good parts of vim are. I find f and t to be a minute improvement over forward search. I think hjkl is strictly better than arrow keys, because you don't have to move your fingers from the home row to navigate a file, and I think the basic editing commands I outlined are sufficient for a superior editing experience within a day of learning them, no deep study required.

Re: Interactive Vim tutorial

#112
post #106

The first thing I do on a new system is map my Caps Lock key to Escape[1][2][3] so that I can use Vim conveniently without having to reach the physical Escape key placed awkwardly at the corner of the keyboard. The choice of Escape key to return to normal mode and H, J, K, L for navigation makes total sense if we look at the original Lear Siegler ADM-3A terminal[4] that Bill Joy used while creating vi, but in the mod…

Mapping jk and kj to escape and mapping caps lock to some other hyper key is way better than caps lock to esc IMO. You can just mash both j and k together and you are out of it.

inoremap jk

And

inoremap kj

In your vimrc file should do it.

Re: Interactive Vim tutorial

#113

Here’s how I “learned” vim and many of the more proficient vimmers I know did too: go through vimtutor (type “vimtutor” on your command line), then write YOUR OWN .vimrc - in vim. Then use it and learn by doing.

I disagree with the notion that you have to write your own vimrc from scratch in order to become a proficient vim user. Don't waste your time pouring over the documentation and trying to get things just right, vim is a pretty old program and a lot of useful config options are not on by default, nor are they easy to understand by a skim of the documentation. There's no point to having a deep understanding of them, because you want them on 100% of the time.

Start by copying someone else's vimrc (vim-sensible [1] is a great starting point) and tweak it as needed. My $0.02 is to avoid plugins until you have used vim for a substantial amount of time.

[1]: https://github.com/tpope/vim-sensible/blob/master/plugin/sen...

Re: Interactive Vim tutorial

#114
post #103

Earlier quoted context omitted.

I like the "Learn Vim Progressively" guide. It starts with just a few commands, and introduces new ones in small batches when you feel comfortable with the ones you're using. http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressiv... I'd add windows to your list of things to take a look at once you feel comfortable with the editor. You can split your workspace with ctrl+w followed by 'v' (vertical) or 's' (split…

I feel like window management is a good way to introduce vimscript as well. Lets you tweak some of the features like having the windows open on the right instead of left or getting rid of the w so it's just ctrl+{hjkl}.

I learned vi 20 years ago now, and vim a year or three later. In all that time, I've never seen the point to vimscript. If you want a heavily customized, scriptable editor, why just not use emacs? Vi works the way it works.

Re: Interactive Vim tutorial

#115
post #77

Honestly though, is it even worth learning? I've tried learning VIM a few times and always gave up, and feel like my editors shortcuts cover most cases anyway. There's also not that many times where I feel like coding speed is required. Honestly curious how much more productive you guys feel after learning VIM.

No. If you could improve your typing efficiency by an order of magnitude (not likely), how much time would you save? Minutes per day? Certainly not a whole hour. Use a modern IDE with sane out-of-the-box configuration (ex: JetBrains.) Realize that you spend more time thinking than typing. Eliminate redundant typing with templates. I used vi for years, then emacs for nearly two decades. I will never go back.

Same here, used both vim and emacs for many years, reading all the books and customizing them both endlessly. Getting older now and tired of wasting time trying to get vim and/or emacs to work under a certain configuration/environment. Any good IDE has both vim/emacs key configs, which do me just fine, although they are never quite exactly the same, I can do 75+% of the vim commands that in JetBrains/whatever that I'd do in vim.

Re: Interactive Vim tutorial

#116
Here's a plug for bash with vim on the command line. (Ubuntu but also wsl). In your login dir, in .inputrc, add:

set editing-mode vi set keymap vi-command:w

This gives you vim on the command line, very handy.

Interactively, set -o vi will work.

This is a great way to 'live in vim.'

Re: Interactive Vim tutorial

#117
post #106

The first thing I do on a new system is map my Caps Lock key to Escape[1][2][3] so that I can use Vim conveniently without having to reach the physical Escape key placed awkwardly at the corner of the keyboard. The choice of Escape key to return to normal mode and H, J, K, L for navigation makes total sense if we look at the original Lear Siegler ADM-3A terminal[4] that Bill Joy used while creating vi, but in the mod…

Mapping jk and kj to escape and mapping caps lock to some other hyper key is way better than caps lock to esc IMO. You can just mash both j and k together and you are out of it. inoremap jk And inoremap kj In your vimrc file should do it.

I have considered such alternatives in the past and they did not work for me. For example, how can I conveniently type the string "jk" or "kj" with such a configuration?

The artificial delay I have to introduce between typing "j" and "k" to actually type "jk" is unacceptable. Although it is rare, I sometimes do have to type "jk" in special circumstances such as while typing LaTeX code.

Mapping Caps Lock to Escape is just a much cleaner solution that does not come with any surprises.

Re: Interactive Vim tutorial

#118
post #77

Honestly though, is it even worth learning? I've tried learning VIM a few times and always gave up, and feel like my editors shortcuts cover most cases anyway. There's also not that many times where I feel like coding speed is required. Honestly curious how much more productive you guys feel after learning VIM.

I have been using Vim for 15 years now and I see no other editor (not even Emacs) that comes anywhere close to the ergonomics of Vim. I can edit code the fastest in Vim.

If you think Vim is not helping you being more productive, I suggest reading the excellent StackOverflow answer that explains how learning Vim is like learning a language (not just learning keyboard shortcuts): https://stackoverflow.com/a/1220118/1175080

The only things that I find lacking in Vim is good support for various software development environments, for example, Java development. Another thing that used to bother me is the awkward placement of the Escape key but I overcome that easily by remapping my Caps Lock to Escape (see https://github.com/susam/uncap#uncap for examples).

Re: Interactive Vim tutorial

#119
post #87

Earlier quoted context omitted.

Sorry, but I think that's really bad advice. For one thing, it doesn't give new users any positive experience or reason to learn vim. If all you learn is to do things that are "pointless" (like learning hjkl), then you won't get any value out of vim. And if your way of learning is to do something that screws up your file and try to recreate how that happened, well, let's just say that every time I do something that s…

I think we just don't agree about what the good parts of vim are. I find f and t to be a minute improvement over forward search. I think hjkl is strictly better than arrow keys, because you don't have to move your fingers from the home row to navigate a file, and I think the basic editing commands I outlined are sufficient for a superior editing experience within a day of learning them, no deep study required.

i'm sure it becomes intuitive with lots of use, bit i find it awkward with having to move my finger off the home keys to move left. somehow for me, its even more confusing that way. where as my arrow keys are completely intuitive, one finger for the left and right keys and the middle finger handles up down. to me its not a big deal to remove my fingers from the home row if i already have to move from the home keys.
Post reply on HN