History and effective use of Vim (2019)
begriffs.com
begriffs.com
Now, if there is one feature I would add to Vim, it would be "cat detection". I have a ginger cat that is irritatingly in the habit of jumping on the keyboard when he wants food.
You can only imagine how, in command mode, he effectively summons the textual equivalent of the Nine Hells of Ba'ator upon my open documents if I am not quick enough...
There's always [u]ndo. Or you can use
:earlier 2m
to go back 2 minutes in time.
Wut.
~27 years of using vim, you just blew my mind.
:later 8h
One can dream...
Fair enough
I normally use u (undo) though.
If you have `set backupdir` enabled, any and all savepoints on a file are backed up with timestamps and a revision number.
Honestly this is single-handed my favorite thing about vim.
Not the ability to fluently traverse through text (and apparently time).
But that you can use it for a almost decade, and still have a stranger on the internet blow your mind with simple features you didn't know existed. There's so many of those one-off commands that are so useful, yet you've somehow never heard of them?
- C-u and C-d to jump up/down
- [ and ] to go prev/next empty line (I have a macro to clear empty spaces at the end of lines so this works well for jumping functions in code)
- from the article: 50% to go the halfway point of a document
- 100gg to go to line 100
- 100k to go 100 lines down
Are there any more good ones?
Edit: occurs to me that you might have remapped kkk to escape normal mode. At one time I had done this for jj. Now I just use C-[ as it’s portable to vanilla vim setups and less of a stretch than the escape key.
I find these handy, especially after doing a search (quoted from :h z):
- z. redraw, cursor line to center of window
- z<CR> redraw, cursor line to top of window
- z- redraw, cursor line at bottom of window
:set relativenumber
The line the cursor is on is now shown in the left sidebar as 0, counting up for each line away from the cursor. So now it tells you what number to use for "10j" and "10k" to move up and down a specific number of lines. m[a-z]
`[a-z]
Mark a point in a file into a register, and jump back to that point. Or even more interesting: m[A-Z]
`[A-Z]
Same as above, except capital marks are global and work across files.Also,
``
Jump back to the last place you jumped from (but only within the same file).Or just use the directional keys and PgUp/PgDown like any person in the last 30 yrs
zt, zz, and zb are similar but move the text not the cursor. So, zt will take the current line the cursor is on and make it the first visible line on the screen (and keep the cursor on that line). zz to the middle, zb to the bottom.
Personally, I use [ and ] to jump around most often in code, but the above are handy when you are working with documents.
Between that and 20j and (blasphemy probably) just using the scroll wheel, that handles most of my scrolling needs.
I may still try it out. But decade long habits...
I thought it meant that you were laughing like haha (a leas in Brazil)
I didn't know it had bad connotations
A friend of mine I met through my own similar (free) library is developing this like a madman: https://kindavim.app
It costs $3/month (coffee) but for a Vim person like me I gladly pay. Making this work across macOS is a total mess and a full-time job, and it's not trivial work.
If you want a free version, I have https://github.com/dbalatero/VimMode.spoon as a Hammerspoon plugin that works pretty OK, but I'm not actively developing it and prefer the kindaVim app at this point.
he seems to have tried that and it didn’t work out, more likely to happen for advanced or power user.
Edit: typo
The problem comes in when the IDE struggles to keep up, or is busy trying to move my cursor somewhere that I don't want it to be.
IntelliJ is really bad about this, I'll often type something and hit esc to go back to normal mode. Mentally I'm moving to another line using a Vim motion, but IntelliJ lags, and eventually moves the cursor to some problem it thinks I need to solve right now (and I might or might not be back in insert mode).
It's frustrating, but probably less frustrating than not using the Vim bindings. Maybe it's something with the Vim plugin, or something I've done. It's more of a minor headache as opposed to a migraine.
Agree completely. Even completely common Vim actions are often just way too sluggish. Not to mention I've remapped "<Esc>" to "jj", which is often unsupported by Vim extensions.
This is before even mentioning all the "helpful" features like parenthesis-completion that IDEs like to foist on me. Word processors don't try to insert matching double-quotes, why do I want an IDE to insert matched parens?
(A tip... if you do `echo "import fs" >> ~/.bashrc`, the 'fs' command library—which contains the vim command—will be automatically imported into the current shell's execution context.)
There are GUI versions for Windows/Linux/Mac/etc: https://www.vim.org/download.php
I use GVim (without the menu/tool bars).
And I don't see how such features are necessary to rule GVim as GUI. I have a fairly basic classification: TUI runs in a terminal, GUI have their own windows.
Put this another way, you can tell the difference between something like vim and Emacs versus Kate and Microsoft Word. It is not necessary to get into the minutia of what makes all these text editors different to understand that they are fundamentally different kinds of applications. The former two are clearly terminal apps with GUI chrome around them, the latter two are clearly GUI apps.
Lack of mouse-led discovery likely also contributes to vim veterans being surprised that vim has this or that feature. TUI-orientation is quite tenuous when it comes to discovery of behavior. The whichkey family of plugins[0][1] is an interesting experiment in combatting this, but does nothing for the large case of commands that aren't mapped to a key by default, like the example of the 'earlier' command mentioned higher in this thread.
When we broke our sourcemaps for a bit, I was the dedicated human source map for a while and vim was an absolute life saver.
And just in case you missed it, you may gj gk to navigate visual lines or remap j, k (and <Up>, <Down>) to gj gk to make that default.
I have a genuine question why use nvim at all if it has such issues with presenting text in a window.
The complaint in that ticket is that you can't make it the default for all the other ways of scrolling
[1] https://github.com/neovim/neovim/wiki/Related-projects#gui [2] https://github.com/qvacua/vimr
[0]: https://neovim.io/
Or maybe I’m missing something here too, what “gui” means for you?
Edit: oh I see from other comments. No, this type of gui vim doesn’t do.
What I noticed that people build "their own" IDE installing and configuring third party plugins and spend a lot of time to maintain this configuration. And there is no guarrantie it will be better then what is already supported in vsCode for example. So as an alternative one can go other way around and just install vim plugin.
* Use an LSP client plugin, whichever you prefer. It's better than any ctags circus you can do. coc.nvim is more feature rich but also heavier. Vim-lsc if you prefer more barebones.
* FZF.vim; fuzzy searching files as well as lines in same file.
On a related note, does anyone know proper parenthesis / bracket completion plugin? I never got that functionality to work as good as IntelliJ.
> [...]
> viper - 1995 for Emacs
One can add "vi.el" (approx 1985/86) and "vip.el" (approx 1986/87) to the list too. Both of these were obsoleted in 2014, but are still distributed as part of Emacs.