back

by firefax·1y ago·view on hn ↗
Does anyone have any suggestions on useful vi commands to learn?

I prefer vi over emacs, but mostly because before I was a hacker, I had an interest in systems administration -- it's so much simpler to edit config files in vi than rely on a tool that seems to require a lot of customization, but I actually usually use Sublime for anything more than a short shell script.

4 comments
I personally use neovim and something I love doing is :tabedit to create a new tab and then I slap a :term in there and baby you've got a fullscreen terminal in a separate tab right inside vim and get this, you can yank text from this buffer and easily move this between your terminal tab and the files you have open.

I think regular vim will do all this as well but I think maybe the commands are different?

If you're in a terminal and want to edit just that command (and Vim is your $EDITOR), you can type `ctrl-x ctrl-e` and it will open your command in a buffer. Once you're satisfied, you can `:wq` and the edited command will be ready to execute in your terminal.

Not exactly your usecase, but a useful one nevertheless.

Since Neovim 0.10, `:tab term` now opens the terminal window in a new tab. And you could use the exact same command in Vim since they introduced their own terminal emulation feature in Vim 8.0.0693.
yes vim does this. same commands.
For gaining expertise in vim, I generally point people at https://danielmiessler.com/p/vim/ which will teach you how to think about vim as a text manipulation language rather than just as an editor.
Thanks for this, just the sort of primer I was looking for.

(I was wondering why the name seemed familiar, then realized... they also are the person who put together a bunch of password lists[1] that are incredibly useful.)

[1] https://github.com/danielmiessler/SecLists/

Vi is power but you are limiting yourself using it because its much harder to extend it. Emacs is very extendable but not everyone likes writing lisp to do so. And nvim offers Lua as opposed to vimscript which can be opinionated.

If you need help setting up an config file I recommend checking out ThePrimeagen or just look at some peoples .dotfiles repos they already did the setup! I won't plug my own but I challenge you to challenge yourself with the complex setup for the downstream knock-on effects you get.

Find a good pre-pack that can help, is my recommendation.

I went from pretty vanilla neovim to using AstroVim, & it's been pretty lovely. It uses the very widely used lazy.nvim for plugin loading, which is quite standard. It has a pretty nice visual leader-key menu that helps explore &show off what is setup; great for discovery. https://astronvim.com/

As well as being a good base, AstroVim also has an excellent "community pack" setup, which is a collection of many many many mostly drop in init files that setup a couple plugins in a nice way. If trying to get LSP working or better, or looking for better treesitter nav options, the community packs are great drop ones or references to get started, show what's out there. It's a huge part of what makes AdtroVim community so good. https://github.com/AstroNvim/astrocommunity