Live data from Hacker News

Show HN: I built an interactive course that helps you learn Vim faster

vimified.com

211–220 of 265 posts

Re: Show HN: I built an interactive course that helps you learn Vim faster

#211
post #15

I really want to like vim and I love some things about it, like the ability to move chunks about with only the keyboard. But so many things about it kill me. Like, why can't I hit right at the end of a line, and move to the next line? Who thinks that is a good idea? Also, why do I have to have a special mode to insert things? Having to change modes just seems so complex and unintuitive. And why does the help system n…

I really want to like to swim and I love some things about it, like the ability to not sink when thrown in deep water. But so many things about it kill me. Like, why can't I just sit in the water, and float to the top? Who thinks that drowning by default is a good idea? Also, why do I have to have a special way to move my hands and legs? Having to coordinate my limbs just seems so complex and unintuitive. And why can I not see anything underwater? The frustration is that probably there are fixes for all these things, which if I were an expert swimmer I would know. But meanwhile I can use an ordinary kayak and I don't have to learn anything new.

Re: Show HN: I built an interactive course that helps you learn Vim faster

#212
I've been using Vim since 1994, but only this past year have I started getting better at juggling large numbers of buffers. There are three main improvements in how I use Vim compared to before and they are simple.

1. I switched to :autochdir, so that in any buffer, the current working directory is that of the file. Then I dumped :autochdir due to certain annoyances and found a nice way of emulating its good behaviors.

2. I started using sessions to save and recover the states of the buffers. I associate sessions with certain tasks and can return to those tasks quickly.

3. I started using a buffer navigator.

Regarding (1) here is the setup:

  :let $top=getcwd()
  :au BufWinEnter * exec "lcd " . expand('%:h')
  :au BufWinEnter * if expand("%") == "" | exec "lcd $top" | endif
  :au BufWinEnter *.git/* exec "lcd $top"
I know you don't need the colon in your vimrc, but I have it anyway.

The $top variable captures the top level directory on startup; I refer to it in command lines when I need it using $top. Why the dollar sign? Ah, this makes it an environment variable. Vim is much better about interpolating environment variables than other variables; there are more places you can use them thanks to the dollar sigil.

The other three commands above set up a local chdir (lcd) to the directory of the file containing the buffer. The third rule is smart: if we are editing something under .git/ then we go back to the top. This is what autochdir gets wrong. What do we edit under .git? Oh, COMMIT_EDITMSG, for one thing! I want to be in the repository root when editing a commit message.

Regarding 2, here is my setup for working with sessions:

  :nmap + :waexe "mksession! " . v:this_session
  :command -nargs=1 S exec "mksession! " . expand('$top/') . expand('')
+ becomes a command for saving the current session. Then I have a :S command to save a session under a new name, relative to the top directory: the $top variable rears its head.

Regarding 3, there are many buffer navigators. I'm using bufexplorer (version 7.4.32). I make the following tweak to the plugin/bufexplorer.vim file:

  " added before the other maps

  if !hasmapto('BufExplorer') && g:bufExplorerDisableDefaultKeyMapping == 0
      nnoremap    \ :BufExplorer
  endif
In Vim the "leader key" for hot key commands is backslash by default. Instead of using the default key binding for launching the bufexplorer view, which is like \be or something, I map the backslash key to do that. So just by hitting \\ (backslash twice) I get the buffer explorer.

Mostly I use the LRU view in buffer explorer (most recently used buffer goes to top, pushing others down). Should be called MRU, but everyone who knows memory cache hierarchies understands LRU.

The above three things are very simple, and have a big payoff. I have many more tricks in my vimrc. For instance I use a C program called autotab to analyze a sample of lines from the loaded file and adjust the indentation settings.

Re: Show HN: I built an interactive course that helps you learn Vim faster

#213
post #204

This looks very cool, kudos on the launch! I feel like vim tutorials mostly focus on navigating and editing a single file, which is great! But I mostly struggle with how to replicate opening a whole directory in VSCode, which makes it easy to browse the directory, switch between files, open multiple panels, etc. I'm almost certain vim does all these things out of the box, but tutorials always end at "this is how you…

That's exactly how I feel too. I just started using neovim a few weeks ago. I'm using `nvim .` to get to a navigable tree, but have no idea if that's the right way to do it.

Re: Show HN: I built an interactive course that helps you learn Vim faster

#214
post #15

I really want to like vim and I love some things about it, like the ability to move chunks about with only the keyboard. But so many things about it kill me. Like, why can't I hit right at the end of a line, and move to the next line? Who thinks that is a good idea? Also, why do I have to have a special mode to insert things? Having to change modes just seems so complex and unintuitive. And why does the help system n…

> But meanwhile I can use an ordinary visual text editor and I don't have to learn anything new.

Then do that?

Re: Show HN: I built an interactive course that helps you learn Vim faster

#215

Learning to remap escape to Caps Lock or to jk or what the Ctrl combination are to switch to normal mode should be the first lesson of all vim courses. This was the biggest cognitive discrepancy for me as a vim beginner : What did you use your smarts to create a modal editor while choosing the worst key ever to switch modes!?

> What did you use your smarts to create a modal editor while choosing the worst key ever to switch modes!? I believe when vi was originally created, the Esc key was often placed to the left of Q, where the Tab key is now located on QWERTY layouts.

Correct; vi was born on this layout: https://en.m.wikipedia.org/wiki/File:KB_Terminal_ADM3A.svg (see https://en.wikipedia.org/wiki/Vi). Notice the arrow keys, and Ctrl and escape. In this case, the history of the program basically explains everything in my opinion.

Re: Show HN: I built an interactive course that helps you learn Vim faster

#216
post #187

Just type "vimtutor". If you have vim you should also have vimtutor.

Ah, the lost ritual of descending into accompanying manuals. Only a few are able to practice it nowadays.

In fairness, a lot of software doesn't come with good documentation built-in anymore, so it's understandable that people would get out of the habit.

Re: Show HN: I built an interactive course that helps you learn Vim faster

#217
I am a designer that got fed up with "mouse" control everywhere.

One day I asked myself: Is there a way to scroll in the browser without using a mouse or arrow keys?. Enter Vimium.:)

I have tried in the past Emacs, but I have an operating system, and I don't need a new one (for now). So now you can take MacVim only from my cold hands. P.S. > You can paste the buffer in insert mode with ctrl+r+0.

Re: Show HN: I built an interactive course that helps you learn Vim faster

#218

I once tried to migrate from VS Code to Neovim. I use TypeScript at work, and use many languages for my side projects. But the worst part was making Vim provide with things that you'd expect programming editors to have. So many options, what's best is up to opinion, integrating language servers, getting intellisense to work as you would expect, searching the project folder for file names. Then I realized that all I'm…

I use VSCode with NeoVim as a backend. https://github.com/vscode-neovim/vscode-neovim I highly recommend this if you know vim keybindings and want an IDE experience.

I use this too. This extension used to work amazingly well for me, but lately it’s been troublesome. I switched to it from vscode-vim after it destroyed my undo buffer one too many times, and vscode-neovim was great. It was fast, and it seemed solid. Now though, it will randomly stay stuck in command mode no matter how many times I mash i or I or A or o. Other times it will make changes a few lines away from where the cursor is. I’m not sure what’s changed - maybe VSCode changes that the plugin hasn’t kept up with? Maybe the rust-analyzer plugin is messing with it? - but it’s been a real bummer to not be able to trust that the editor will do what I tell it, and I’ve been thinking of switching to something else. I’m not sure if there’s anything better, though. (I mean, real vim would work better, but I do really like rust-analyzer)

Re: Show HN: I built an interactive course that helps you learn Vim faster

#219

Earlier quoted context omitted.

If you’re trying to achieve VS Code with the keyboard navigation of vim, have you given the VSCode vim plugin a try? I’ve had positive experiences mixing editors/IDEs with a vim plugin to get the best of both for my workflow.

I use this but my god the VS Code vim plugin pisses me off sometimes. It's good probably 99% of the time. But I feel that (from time to time) it collapses multiple commands into a single undo action. Frequently I find myself frustrated that I can't undo exactly what I need to, and it ends up undoing more than I want it to. I never had this problem with vim but with vscode, I probably experience it once a day.

That plugin’s handling of undo drove me absolutely nuts! It would randomly decide to eat the entire undo stack when I accidentally mixed the native cmd+z with using u to undo. At least I think that’s what happened… I was never able to reproduce it on command, though. It would happen unexpectedly, and often would destroy a whole swath of text that was then impossible to get back.

I switched to the vscode-neovim plugin which works better… at least, it doesn’t do this undo thing, and it’s faster. But it’s not entirely perfect either and lately the command/insert/cursor location has been bugging out.

Re: Show HN: I built an interactive course that helps you learn Vim faster

#220
post #12

Earlier quoted context omitted.

This may be a little elitist, but if you're not going to use vim the way it's really made to be used, why even bother? I get that `mouse=a` makes it more familiar, but if you're always going to reach for your mouse, you're never going to really get used to the motions.

Vim was designed on qwerty keyboards. On other layouts (e.g. neo2) hjkl are not in a row.

Very minor issue, speaking as someone who switched to dvorak and then workman while continuing to use vim daily. No keys remapped. It's just not even an issue. Those letters still make those movements. They're in different spots, but I already had to get used to the new spots for writing words in the first place. Doesn't even feel slower.

IIRC dvorak even happens to split the vertical and horizontal movements between hands but while keeping them near each other, almost like RC car controls. Workman is comparatively a bit crazier with its placement, but it still doesn't bother me.

Post reply on HN