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…
Show HN: I built an interactive course that helps you learn Vim faster
211–220 of 265 posts
Re: Show HN: I built an interactive course that helps you learn Vim faster
#2121. 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
#213This 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…
Re: Show HN: I built an interactive course that helps you learn Vim faster
#214I 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…
Then do that?
Re: Show HN: I built an interactive course that helps you learn Vim faster
#215Learning 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.
Re: Show HN: I built an interactive course that helps you learn Vim faster
#216Just 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.
Re: Show HN: I built an interactive course that helps you learn Vim faster
#217One 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
#218I 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.
Re: Show HN: I built an interactive course that helps you learn Vim faster
#219Earlier 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.
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
#220Earlier 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.
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.