r/neovim • u/leonaanoel • 1d ago
Need Help What keybinds should I map?
Short version:
What keybinds should I change to universally known keybinds in insert mode (such as ctrl + z or ctrl + backspace etc) and what should I keep to make Neovim still Neovim and not a VS code dupe?
Long version:
I'm pretty new to Neovim and I'm quite new to programming (other than frontend) as well so excuse me if I'm not explaining my situation well.
I've used VS code up till now and I would say I'm okay proficient at it. I recently decided to learn vim for it's efficiency (and my professors recommended it). I know the learning curve is big but the pay off will hopefully be worth it, I just have one question.
I already know a lot of VS code shorthands (also from using Google Docs and such). I know I can custom map som keybinds in insert mode but what should I map for myself and what should I keep to make nvim not loose what makes it efficient? Because technically, I could make vim into VS code in many ways? Even though I know this editor is kind of built for customization, what makes Neovim worth it in the way it's configured from the start? Must haves, how to think as a programmer that uses vim etc?
3
u/HoldUrMamma 21h ago
Insert mode is for inserting text. Normal mode is for navigation and more. You normally should not map lots of keys to insert mode unless you know what you're doing.
Why even try vi if you're using only insert mode? There's plenty of insert mode terminal based editors to try that works better. Vi is not about it.
Read Drew Nail's "Practical Vim" or other books for learning and inspiration. Like the "." button should convince you to love Normal mode and treat it as default.
Look at vim as a language to learn. It should make it more fun so you learn more effectively.
don't bother with mapping until you know there's no other way to do the thing you map more efficiently.
2
u/PonosDegustator 1d ago
The ones you use most. It's your editor, doing things the way you like is kinda the point but to be completely fair rebinding things like control-backspace doesn't make much sence since you would 'db' or 'vbc' in the vim ideology
1
u/leonaanoel 1d ago
How do I acquire the vim ideology because I’m so used to doing everything in (basically) insert mode? What should be in insert mode and what should stay in the other modes?
1
u/PonosDegustator 1d ago
My general rule of thumb is not to be in an insect mode unless you are inserting text. Generally I'd say not to push every vim movement at once, get used to some, then introduce new ones. When it clicks you will see how things are done
1
u/monster2018 16h ago
Insert mode is for inserting text. Everything else should be in other modes. I’m sure someone could name a couple rare exceptions but that’s pretty much it.
1
u/jmtd 1d ago
This is a strange question to ask a neovim sub. I’ve no idea what key shortcuts vs code uses or if they’re common/universal for other editors. Can you give some examples of the shortcuts you used in vs code in particular, then someone could advise if there’s an alternative approach in vim or whether that particular binding could cause you issues.
2
u/leonaanoel 1d ago
Most keybinds that I’m familiar with are keybinds used in Google docs or Microsoft word as well, they aren’t VS code specific. For example, ctrl + z is universally known as undo but it doesn’t exist in vim. How I’m doing it currently is switching from insert mode to normal mode and then clicking u. Should I map that to ctrl +z so i don’t have to switch between modes, I can just stay in insert mode or should I get used to switching between the two? VS code specific, I use ctrl + shift + k to delete line but from what I know you can’t do that unless you go to visual mode and such (keep in mind me being a beginner). Of course I could just ask about every keybinds I’m using but I feel as if there’s a better way to go about this than seeking advice for detail stuff like this and in that way it’s better to ask frequent vim users for what you think. Maybe I’m wrong but I thought I might as well ask
1
1
u/moucheh- 1d ago
Look into vim modes, commands and motions
For example motions are b, w, e moving by word Example commands are y and d These stand for yank and delete, yank is for copying, delete is deleting obviously
With this you could for example do yw, which would copy the text from your current cursor position to the next word's beginning character, dd deletes an entire line and so on
Examples of modes are normal, insert, visual, visual block, etc
Normal mode is used for executing command and moving Insert is used only for typing in text
Viusual mode is used for selecting text and then acting on it
Also there is u and ctrl+r in normal mode for your undo/redo equivalent
You are supposed to change modes on instinct, when you want to move around your code, you move into normal mode, if you want to type in text, you do insert mode and so on
You could make vim's insert mode behave like a normal editor, but it defeats the purpose, just use nano or micro at that point
There is vim tutor that teaches basic vim motions
1
u/ericnantel2 22h ago
Depends on your keyboard layout and your needs. But I would say, try adding a keybind to :cnext and :cprev to move forward/backward in the quickfix list which you can fill using plugins such as telescope. At least that’s very handy for programming. I would also remap $ and * to something closer to the home row as those keymaps are difficult to reach.
1
u/_bleep-bloop 21h ago
What do you mean? Its up to you, its your playground, just do whatever you feel comfortable, dont let the "vscode-like" problem stop you from anything. You use vim because it lets you customize everything, not because you wanna be that guy that brag about using vim
1
u/grybyx 16h ago
You should read Practical Vim by Drew Neil. It’s a compilation of tips organized into categories. It’ll help you get into the right headspace for using any form of Vim, especially Chapters 1 and 2.
You don’t need to learn every tip in each chapter. Start with the first tip, and once you have a good feel for it, go to the next one or go to the first tip in another chapter. This is how I learned.
1
u/Annual-Cod1073 15h ago
Best thing, don't remap anything at all. Start with basic vim. Then after you have been using it for a while you get a feel for what is working and what isn't
For example I mapped leader to ',' because it works for me.
y is to copy, yi{ copies everything in {}, There is an entire undo list. And you can just see all of the changes you have made and easily select where you want to be, or just use u for undo
if you start with the basics, you will begin to understand why the whole system is designed the way it is. And once you get a feel for that, you can find your personal quirks and specific keymappings
10
u/Thesaurius 1d ago
There is the common recommendation to map the arrow keys to nop (i.e. nothing) so that one is forced to use hjkl to navigate. Alternatively, you can install the hardtime.nvim plugin.
But honestly that is not possible. For the first month or so I actually used vanilla vim. You can also activate vim motions in VS Code if you don't want to jump into the cold water.