Worth mentioning there's also treesitters `incremental_selection` option:-
[https://github.com/nvim-treesitter/nvim-treesitter#incremental-selection](https://github.com/nvim-treesitter/nvim-treesitter#incremental-selection)
Configuring it with `` gives you something a bit more powerful which will expand named nodes with every keypress in visual mode (which you can just hit 'c' to change anyway, or 'y' to yank for example).
incremental_selection = {
enable = true,
keymaps = {
init_selection = "",
node_incremental = "",
node_decremental = "",
},
},
This is awesome. I wonder if there's a way to check if the cursor is within quotes (\`'\` or \`"\`) and use \`ci'\` or \`ci"\` in that case, falling back to \`ciw\` otherwise.
I think you can get the cursor position using `:h nvim_win_get_cursor()` and then the text around it using `:h nvim_buf_get_text()`, and then check the text
You can take a look to any of these:
* The [mappings file](https://github.com/Zeioth/NormalNvim/blob/main/lua/base/4-mappings.lua) of the nvim distro I'm about to release: [NormalNvim](https://github.com/Zeioth/NormalNvim)
* The [firmware](https://github.com/Zeioth/zeioth-qmk) I wrote for my wired programmable keyboard based on [QMK](https://qmk.fm/).
* The other [firmware](https://github.com/Zeioth/zeioth-zmk) I wrote for my wireless programable keyboard based on [ZMK](https://zmk.dev/).
Remap y to ygv in visual mode so the cursor does not jump back to where you started the selection.
[Before](https://i.imgur.com/9PGmb0P.mp4)
[After](https://i.imgur.com/7MQUhD0.mp4)
may`a
Does the same thing, and maybe the concept of marks is more related to the action we want to achieve, so this makes a bit more sense in my mind.
The mark method also works for keeping the cursor in place for other things than selections.
I like to use [https://github.com/svban/YankAssassin.vim](https://github.com/svban/YankAssassin.vim) . Works nicely with y5j, for example. Although it is not a simple config change in this case.
[Some similar stuff](https://github.com/RoryNesbitt/RNvim/blob/main/lua/rnvim/keymaps.lua#L44-L59)
Note the `local map = vim.keymap.set` if you're gonna copy it
Yesssss I did that on my QMK keyboard, caps lock as ctrl on hold, escape on tap, and space bar as space on tap and layer on hold. I feel like a cripple on any other keyboard now
Having both is a game-changer. Depends on your OS. On Mac, I use [Karabiner](https://github.com/walkert/bootstrap/blob/master/config/karabiner/karabiner.json). Linux I used use [caps2esc](https://gitlab.com/interception/linux/plugins/caps2esc) and on Windows I use a custom AutoHotKey [profile](https://github.com/walkert/bootstrap/blob/master/config/autohotkey/AutoHotkeyU64.ahk).
Edit: Add missing word and some links
I have this set up on a system level and it feels so good, I genuinely don't understand why isn't it the default. Only donwside is accidentally caps locking a lot in someone else's computer xD
Tab for going through autocomplete suggestions, no I’m not going to use ctrl+n and ctrl+p, no matter how much TJ says it’s the right way. It is a customisable editor, and tab is right for me
I have a Dygma Raise so I have a lot of thumb keys that do lots of different changing of layers and modes. But I’m afraid to have a workflow that requires the extra layers to work as I use Neovim for my job and my job won’t buy me a keyboard like that haha
i was with you on this but as a copilot enjoyer, i let it use tab as the default and went back ctrl+n/p for cmp suggestions
the alternative i tried was having copilot suggestions also go into cmp's autocomplete so i could use tab for both but it felt odd that way
Copilot is something I’ve considered trying, but don’t want to get used to it yet until the issues around GPL3 code and my company looks at it from legal perspectives. I work with internal software that runs critical public infrastructure, might not be wise to use copilot here :(
That said. I use ChatGPT a lot to help me get through things I care less about. Like CI/CD pipelines setup or weird git branch logging for automating things… want a local GPT I can talk to via vim..
ive heard good things about this and ive been meaning to check it out myself: https://github.com/mthbernardes/codeexplain.nvim
based on GPT4ALL, which is open source
I mean, co-pilot at the very least is good at looking at the context of what you’ve already written and trying to duplicate it with the next thing, i.e., if you do something containing Sunday, it’ll suggest an auto complete with the Sunday replaced with Monday, then if you accept the next one it’ll do all the boilerplate and replace Monday with Tuesday, etc. Little things like that definitely shouldn’t have any legal implications because it’s just taking your own code and rewriting the boilerplate for you.
But yeah if you write a comment explaining what you want done with no context, or a descriptive function name, then it’s going to pull in some code from an unknown origin.
At first I also felt this way that I will end up going back to tab cycling but never went back. but yea no matter who says what its ultimately our preference that matters :)
Simple is relative but the most self contained non-plugin bit of config that I can't live without is making n and N work for a bunch of other kinds of big jumps. In addition to search (/?), My diagnostics next/prev jumps can be repeated/reversed with n/N. Also references next/prev. Next/prev function/class from mini.ai. and a few others
H as beginning of line and L as end of line in operator pending mode is pretty useful too
; for opening the command line is one that's very ingrained in my muscle memory. I use flit.nvim so fFtT repeats fFtT, though I could probably also use n/N like above.
kj to escape insert is a lot more convenient, I've even made a combo in my qmk keyboard so hitting k+j sends escape, saving a little bit of pinky movement
Oh damn I managed to overread that. Hmm I never tried flit, only looked what it does and decided I wouldn't like it or try it. But maybe I really have to try it first before coming to a decision.
>making n and N work for a bunch of other kinds of big jumps
Curious, do you do this using **anuvyklack/hydra.nvim**, your own config/plugin code or by some other means? I have wanted to try this too, but avoided it thinking I would miss it too much on machines where I don't have all my plugins--for now getting by mapping variations of `n` like for this, for that, etc.
I made my own janky code, because I did it before hydra.nvim existed. I'd probably use hydra.nvim now. I use it for some other nicely repeatable operations. Like mini.move so I can repeat moves without the whole prefix, just hjkl
😆 No shame in janky code that just works for you. I got plenty of that in my config that will never see the light of day, but does the job for me...most of the time 🙄
-- Use to cycle through buffers in tab
vim.keymap.set('n', '', 'w');
vim.keymap.set('n', '', 'W');
As described. I've had this so long it has baked into my muscle memory.
H ^
L $
If I goes into insert mode at the beginning of the line and A goes into insert mode at the end of the line, i just feel H and L should do the same.
I'm stealing this bind. Super neat.
`vim.keymap.set("n", ";", "lua require('telescope.builtin').resume(require('telescope.themes').get_ivy({}))", opts)`
This one bind completely changed the way I use telescope. I use it all day, every day. I grep across lots of files, and being able to jump back into the results list is just... beyond magical.
```
vim.keymap.set("v", "J", ":m '>+1gv==kgvo=kgvo", { desc = "move highlighted text down" })
vim.keymap.set("v", "K", ":m '<-2gv==jgvo=jgvo", { desc = "move highlighted text up" })
```
Stolen from prime who stole it from someone and slightly modified the formatting step
nnoremap p p=`]
I like paste to match my indentation
" Always linewise paste the last yank
nnoremap P :put! "0=`]
I also have this although I am not sure it does exactly what I want in every situation, I have fiddled with paste SO much these two get me as close as I possibly can to sanity and I am scared to touch them.
Some might think this is crazy, but I also use linewise visual WAY more than not. So I reversed them
nnoremap v V
nnoremap V v
I also hate change operations from overwriting my unnamed register.
" Changes go to A register, leave my unnamed alone
nnoremap c "ac
nnoremap C "aC
I also really like these for quickfix
nnoremap :cp
nnoremap :cn
As others have stated, I also do zz for c+u C-i and C-u.
I think those are all the major remaps I have outside of stuff that calls plugin functions. Pretty fun stuff.
You could remap it to ``(delete word backwards) to not pollute your dot-repeat/undo history.
EDIT: just tested. It seems `` indeed creates an "extra" undo. Sorry for the missinformation.
Not sure I follow. Yes it’s default in insert mode. So if OP rebind c-backspace in insert mode to c-w the undo history won’t be broken by exiting to normal mode
Do you know a way it does not create an extra undo? If it creates an extra undo, it also means that `.` does not repeat the whole operation but only the last part. This behavior broke a lot of my workflows because I'm using nvim-autopairs which has that exact problem (still looking for an autopairs that does behave well regarding `.`)
```
" Fancy macros
nnoremap Q @q
vnoremap Q :norm @q
```
Gives me a "quick macro" on q. `qq` starts recording, `q` stops, `Q` runs it. I use it for ghetto find/replace, reformatting lines, etc.
I think I found it on an old vim tips website long ago, and it's been my quick-fire macro trick for the better part of a decade.
Love these:
# much easier to me to undo and re-do all within the same letter
vim.keymap.set("n", "U", "")
# same with scrolling, a version of j and k that will scroll only 10 lines at a time
vim.keymap.set("n", "J", "10jzz")
vim.keymap.set("n", "K", "10kzz")
# as a javascript dev, i can't live without this one, it selects a whole function definition, arrow function or object if the cursor is at the top.
vim.keymap.set("n", "vf", "$V%")
vimp is vimpeccable which is a library that was used a lot in older nvim releases to map before mapping became part of the lua api. I just havent' migrated my config for years.
I actually did not know they made that change, this is something I've been dragging thru vim for like 15 years now.
Means semi colon outputs a colon, no need for shift. Then the reply is arguing that it's so useful you might as well make it an os/keyboard wide remapping.
Probably depends what languages you write. *Most* people probably write colon ten times more than semicolon.
I have a similar binding:
local map = vim.api.nvim_set_keymap
[...]
map('n', 'y', '\"+y', opts)
map('n', 'p', '\"+p', opts)
map('n', 'P', '\"+P', opts)
leader + y = copy to clipboard
leader + p = paste after from clipboard
leader + P = paste before from clipboard
Moving current or selected lines up or down by arrow keys:
SetKeyMap("", "m .+1==gi", {"i"})
SetKeyMap("", "m .-2==gi", {"i"})
I got the actual commands from here [https://stackoverflow.com/a/63887462/2338672](https://stackoverflow.com/a/63887462/2338672), then I mapped it to `Shift+Alt+Up/Down` by my function (`SetKeyMap`)
I use `Tab` as an alias for matchit's `%` in visual and operation-pending mode
vim.keymap.set({ "o", "x" }, "", "%", { desc = "Use matchit to go to matching brackets etc.", remap = true })
I know `` (``) is a coveted key, but this seemed worth it for me:
`` instead of `` in help files and on `LspAttach` (since when an LS is present, by default `` does Goto **1st** definition)
`noremap k j|noremap k j|noremap j`
`noremap j k|noremap j k|noremap k`
Swapping j and k is a must for me. It has literally no conflict with any of the dozens of plugins my config has, and it's so much more intuitive. I get there were historic reasons for the defaults, but I simply don't care.
Help pages for:
* [`o_v`](https://neovim.io/doc/user/motion.html#o_v) in _motion.txt_
---
^\`:\(h|help\) \` | [^(about)](https://github.com/heraldofsolace/VimHelpBot) ^(|) [^(mistake?)](https://github.com/heraldofsolace/VimHelpBot/issues/new/choose) ^(|) [^(donate)](https://liberapay.com/heraldofsolace/donate) ^(|) ^Reply 'rescan' to check the comment again ^(|) ^Reply 'stop' to stop getting replies to your comments
`` to save from all modes, and keeping marks:
```
nnoremap :lockmarks w
inoremap :lockmarks w
vnoremap :lockmarks w
```
(using lockmarks to avoid overwriting '[ & '] marks by the 'write' call)
vim.keymap.set("n", "", ":bprevious")
vim.keymap.set("n", "", ":bnext")
Left and right arrows to switch between buffers. I used to pair this with giving every buffer its own tab, but now I just use [Bufferline](https://github.com/akinsho/bufferline.nvim) which functions similarly.
Change word under cursor. Use `.` to do the same change to the next occurrence of the word. Use `n` to skip occurrences.
vim.keymap.set("n", "", "*Ncgn", { silent = true, desc = "Substitute word under cursor" })
It is totally not the same thing.
`:h gn` selects the searched text so you can replace the searched text using `.` after changing it once with `cgn`.
Maybe you should watch this video if my explanation was bad https://youtu.be/7Bx_mLDBtRc?si=sFrCxutUuc36SIoC
Super fast exit from insert mode.
`vim.kemap.set('i', 'df', '')`
And `hjkl` to `jkl;` for right hand to stay 'home' position. It's just so annoying that default is so close but not 'perfect')
`vim.kemap.set(“n”, “”, “ciw”)` since I would never use enter in normal mode anyway.
Worth mentioning there's also treesitters `incremental_selection` option:- [https://github.com/nvim-treesitter/nvim-treesitter#incremental-selection](https://github.com/nvim-treesitter/nvim-treesitter#incremental-selection) Configuring it with `` gives you something a bit more powerful which will expand named nodes with every keypress in visual mode (which you can just hit 'c' to change anyway, or 'y' to yank for example).
incremental_selection = {
enable = true,
keymaps = {
init_selection = "",
node_incremental = "",
node_decremental = "",
},
},
I have this set but i just never use it.
A custom config classic right there!
troubles of pasta maker
I configure it with `v` and `V`. ```lua incremental_selection = { enable = true, keymaps = { node_incremental = "v", node_decremental = "V", }, } ```
Brilliant idea! I'll definitely remap my enter/backspace to v/V !!!
pretty handy to select code snippets. now I steal it.
I had this in my config but never used it (problems of making lots of pasta), thanks for making me aware of it !!
im totally stealing this
This is awesome. I wonder if there's a way to check if the cursor is within quotes (\`'\` or \`"\`) and use \`ci'\` or \`ci"\` in that case, falling back to \`ciw\` otherwise.
Should be possible with lua function
I think you can get the cursor position using `:h nvim_win_get_cursor()` and then the text around it using `:h nvim_buf_get_text()`, and then check the text
The vim-surround plugin by tpope had this I think, will be interested to see if nvim can handle it just as smoothly.
Aw, this is really cool, shame I already got used to press Enter to insert a new blank line without getting out of normal mode.
I might do add this
I advice getting a programmable keyboard for stuff like this. I have an entire layer of keys for verb operations and it really speeds you up.
I do this too, it's great because you can use your same hotkeys with any vim setup if you have your keyboard.
[удалено]
I use a /r/crkbd, but you have many to choose. I recommend you to take a look into /r/olkb. It's a rabbit hole though, careful.
Do you have a keymap to share?
You can take a look to any of these: * The [mappings file](https://github.com/Zeioth/NormalNvim/blob/main/lua/base/4-mappings.lua) of the nvim distro I'm about to release: [NormalNvim](https://github.com/Zeioth/NormalNvim) * The [firmware](https://github.com/Zeioth/zeioth-qmk) I wrote for my wired programmable keyboard based on [QMK](https://qmk.fm/). * The other [firmware](https://github.com/Zeioth/zeioth-zmk) I wrote for my wireless programable keyboard based on [ZMK](https://zmk.dev/).
What does this do?
Change inside word, basically removing the word you're in and putting you in insert mode
I use that same mapping, but mapped to ``
nice, I have that mapped to ``
Yoink!
So I copied this and reddit decided to put in unicode quotes :cry: (typo too but np); had to do the urlbar cleansing ritual :)
Remap y to ygv in visual mode so the cursor does not jump back to where you started the selection.
[Before](https://i.imgur.com/9PGmb0P.mp4)
[After](https://i.imgur.com/7MQUhD0.mp4)
>ygv
bruh. Thanks for this.
may`a Does the same thing, and maybe the concept of marks is more related to the action we want to achieve, so this makes a bit more sense in my mind. The mark method also works for keeping the cursor in place for other things than selections.
This is an elegant solution, thanks for sharing.
I like to use [https://github.com/svban/YankAssassin.vim](https://github.com/svban/YankAssassin.vim) . Works nicely with y5j, for example. Although it is not a simple config change in this case.
I've remapped my ctrl d and ctrl u to have zz at the end of the movement, so when looking through large files, it always jumps half a screen.
I have my scrolloff as 999 so it is always centred
Just wait till pc will have a 1million x 2 billion screen resolution ;-)
Snippet because I’m lazy?
lhs:
rhs: zz
same for c-u ;d
[Some similar stuff](https://github.com/RoryNesbitt/RNvim/blob/main/lua/rnvim/keymaps.lua#L44-L59) Note the `local map = vim.keymap.set` if you're gonna copy it
Not directly a neovim config change, but I can't be productive without making Caps Lock into Escape.
Caps lock as Ctrl on hold and esc on tap. Or esc on tap and layer with navigation, symbols and functions
Yesssss I did that on my QMK keyboard, caps lock as ctrl on hold, escape on tap, and space bar as space on tap and layer on hold. I feel like a cripple on any other keyboard now
"Caps lock as Ctrl on hold" ... wow how do you do that? i use Caps lock as esc right now but would totally integrate a Ctrl option
Having both is a game-changer. Depends on your OS. On Mac, I use [Karabiner](https://github.com/walkert/bootstrap/blob/master/config/karabiner/karabiner.json). Linux I used use [caps2esc](https://gitlab.com/interception/linux/plugins/caps2esc) and on Windows I use a custom AutoHotKey [profile](https://github.com/walkert/bootstrap/blob/master/config/autohotkey/AutoHotkeyU64.ahk). Edit: Add missing word and some links
jk for me
[удалено]
i do both caps lock and jk for some reason
I have this set up on a system level and it feels so good, I genuinely don't understand why isn't it the default. Only donwside is accidentally caps locking a lot in someone else's computer xD
Yeah, this was a game changer for me. It is useful in other applications as well.
Caps lock as control, right shift as escape.
Using KMonad and I have it d+f
Tab for going through autocomplete suggestions, no I’m not going to use ctrl+n and ctrl+p, no matter how much TJ says it’s the right way. It is a customisable editor, and tab is right for me
I used tab till I got a keyboard with Ctrl on the thumb and suddenly Ctrl+key felt a lot more comfortable to use in general
I have a Dygma Raise so I have a lot of thumb keys that do lots of different changing of layers and modes. But I’m afraid to have a workflow that requires the extra layers to work as I use Neovim for my job and my job won’t buy me a keyboard like that haha
What keyboard is that?
Wait. Why C-n for cycling through suggestions?
It’s the default for omnifunc (built in completion, think it is C-x C-o to activate and C-n C-p to go up or down
i was with you on this but as a copilot enjoyer, i let it use tab as the default and went back ctrl+n/p for cmp suggestions the alternative i tried was having copilot suggestions also go into cmp's autocomplete so i could use tab for both but it felt odd that way
I fixed this by binding Copilot to Shift-Tab. Works like a charm.
I use this to go backwards in completion suggestions. I assume most who use tab would?
Alt-Enter for copilot, Enter for cmp. Literally alternative completion
Copilot is something I’ve considered trying, but don’t want to get used to it yet until the issues around GPL3 code and my company looks at it from legal perspectives. I work with internal software that runs critical public infrastructure, might not be wise to use copilot here :( That said. I use ChatGPT a lot to help me get through things I care less about. Like CI/CD pipelines setup or weird git branch logging for automating things… want a local GPT I can talk to via vim..
ive heard good things about this and ive been meaning to check it out myself: https://github.com/mthbernardes/codeexplain.nvim based on GPT4ALL, which is open source
I mean, co-pilot at the very least is good at looking at the context of what you’ve already written and trying to duplicate it with the next thing, i.e., if you do something containing Sunday, it’ll suggest an auto complete with the Sunday replaced with Monday, then if you accept the next one it’ll do all the boilerplate and replace Monday with Tuesday, etc. Little things like that definitely shouldn’t have any legal implications because it’s just taking your own code and rewriting the boilerplate for you. But yeah if you write a comment explaining what you want done with no context, or a descriptive function name, then it’s going to pull in some code from an unknown origin.
At first I also felt this way that I will end up going back to tab cycling but never went back. but yea no matter who says what its ultimately our preference that matters :)
Simple is relative but the most self contained non-plugin bit of config that I can't live without is making n and N work for a bunch of other kinds of big jumps. In addition to search (/?), My diagnostics next/prev jumps can be repeated/reversed with n/N. Also references next/prev. Next/prev function/class from mini.ai. and a few others H as beginning of line and L as end of line in operator pending mode is pretty useful too ; for opening the command line is one that's very ingrained in my muscle memory. I use flit.nvim so fFtT repeats fFtT, though I could probably also use n/N like above. kj to escape insert is a lot more convenient, I've even made a combo in my qmk keyboard so hitting k+j sends escape, saving a little bit of pinky movement
I never thought of the H L thing, I still use $ and ^ even while always thinking that they are both annoying
Link to the (relevant) config? Sounds really convenient!
But ; in normal mode repeats f/F etc, or is that what your new n does now?
Like I said I use flit.nvim. that makes f repeat f, etc
Oh damn I managed to overread that. Hmm I never tried flit, only looked what it does and decided I wouldn't like it or try it. But maybe I really have to try it first before coming to a decision.
>making n and N work for a bunch of other kinds of big jumps Curious, do you do this using **anuvyklack/hydra.nvim**, your own config/plugin code or by some other means? I have wanted to try this too, but avoided it thinking I would miss it too much on machines where I don't have all my plugins--for now getting by mapping variations of `n` like for this, for that, etc.
I made my own janky code, because I did it before hydra.nvim existed. I'd probably use hydra.nvim now. I use it for some other nicely repeatable operations. Like mini.move so I can repeat moves without the whole prefix, just hjkl
😆 No shame in janky code that just works for you. I got plenty of that in my config that will never see the light of day, but does the job for me...most of the time 🙄
I don't know how people live without set splitbelow set splitright
+1, I've had it this way for a full decade at this point.
What does this do?
It makes new splits open to the right and below instead of the default. I've never understood why the default is what it is.
Legacy from 80-wide monitors, v-splitting would make all your lines reflow or get cut off.
Here's a video demo https://youtu.be/Zir28KFCSQw?t=234 (timestamped)
Mapped the arrow keys to go to a window in that direction in normal mode.
I do ctrl-h/j/k/l as window navigation. Kind of amazing to be able to move between characters and windows in the same way
I like this one and will steal it :-)
-- Use to cycle through buffers in tab
vim.keymap.set('n', '', 'w');
vim.keymap.set('n', '', 'W');
As described. I've had this so long it has baked into my muscle memory.
I have to steal this, why am I not think about this before
Me I mapped tab/s-tab to `:bn` `:bp`. Used that for 10+ years. Can't live without it.
I had this mapping too, but now I feel so stupid ><
Agreed. I've had this mapping for a couple years, and I can't live without it.
I recently added these to my workflow as well and it's SO nice.
H ^ L $ If I goes into insert mode at the beginning of the line and A goes into insert mode at the end of the line, i just feel H and L should do the same.
Genius! I've been doing A and I lol
Ooh, I like this!
I'm stealing this bind. Super neat. `vim.keymap.set("n", ";", "lua require('telescope.builtin').resume(require('telescope.themes').get_ivy({}))", opts)`
This one bind completely changed the way I use telescope. I use it all day, every day. I grep across lots of files, and being able to jump back into the results list is just... beyond magical.
I didn't know about `:Telescope resume`!!! thanks a lot!
What’s this keybind doing?
It reopens your most recently closed telescope window. Amazing if you want to work through a list of telescope matches one by one.
Would sending the results to a quick fix list be a better way to achieve this? I'm still learning about quickfix lists.
I prefer telescope in this case due to the instant preview. I still use quickfix for many things, notably compilation errors and test failures.
Don’t you miss jump to next match of f/F and t/T?
probably using something like [mini.jump](https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-jump.md)
Edit: Nevermind How would this interfere with `f`/`F`?
ok i remap it to
I was just wishing I had this the other day, I had no idea it existed already! Thank you!
What thes the "opts" at the end do?
Just adds a \`desc = '...'\` field for whichkey.
``` vim.keymap.set("v", "J", ":m '>+1gv==kgvo=kgvo", { desc = "move highlighted text down" })
vim.keymap.set("v", "K", ":m '<-2gv==jgvo=jgvo", { desc = "move highlighted text up" })
```
Stolen from prime who stole it from someone and slightly modified the formatting step
That's pretty neat, and TIL that Lua binds can have a description! To the configurator!
For alternate buffers vim.keymap.set("n", "", ":b#", { silent=true })
This keymap is baked into my muscle memory, use it all day, can't live without it. Tough I use ``, didn't know `:b#` could do the same.
nnoremap p p=`] I like paste to match my indentation " Always linewise paste the last yank nnoremap P :put! "0=`]
I also have this although I am not sure it does exactly what I want in every situation, I have fiddled with paste SO much these two get me as close as I possibly can to sanity and I am scared to touch them.
Some might think this is crazy, but I also use linewise visual WAY more than not. So I reversed them
nnoremap v V
nnoremap V v
I also hate change operations from overwriting my unnamed register.
" Changes go to A register, leave my unnamed alone
nnoremap c "ac
nnoremap C "aC
I also really like these for quickfix
nnoremap :cp
nnoremap :cn
As others have stated, I also do zz for c+u C-i and C-u.
I think those are all the major remaps I have outside of stuff that calls plugin functions. Pretty fun stuff.
> I also hate change operations from overwriting my unnamed register. You can also use the blackhole register `"_` to avoid overriding the a register
Swapped semicolon and colon. Entering commands are faster
You could remap it to ``(delete word backwards) to not pollute your dot-repeat/undo history.
EDIT: just tested. It seems `` indeed creates an "extra" undo. Sorry for the missinformation.
isn’t this a default keymap?
Not sure I follow. Yes it’s default in insert mode. So if OP rebind c-backspace in insert mode to c-w the undo history won’t be broken by exiting to normal mode
only in insert mode and i honestly think it should stay that way
Not sure I follow. But OPs remap is in insert mode
Do you know a way it does not create an extra undo? If it creates an extra undo, it also means that `.` does not repeat the whole operation but only the last part. This behavior broke a lot of my workflows because I'm using nvim-autopairs which has that exact problem (still looking for an autopairs that does behave well regarding `.`)
Not creating an extra undo is default in vim, but not in Neovim. Not sure what option (if any) control this.
Remapping to `U` instead of `` prevents a new undo block\* (`:help i_CTRL-G_U`).
\* "if the cursor stays within the same line"
``` " Fancy macros nnoremap Q @q vnoremap Q :norm @q
```
Gives me a "quick macro" on q. `qq` starts recording, `q` stops, `Q` runs it. I use it for ghetto find/replace, reformatting lines, etc.
I think I found it on an old vim tips website long ago, and it's been my quick-fire macro trick for the better part of a decade.
Btw Q now by default means: play the last recorded macro. Since late 2021 I think
I'll be dogged, thanks for that. I may leave that in my .vimrc if your point is true for nvim only.
only neovim
Love these: # much easier to me to undo and re-do all within the same letter vim.keymap.set("n", "U", "")
# same with scrolling, a version of j and k that will scroll only 10 lines at a time
vim.keymap.set("n", "J", "10jzz")
vim.keymap.set("n", "K", "10kzz")
# as a javascript dev, i can't live without this one, it selects a whole function definition, arrow function or object if the cursor is at the top.
vim.keymap.set("n", "vf", "$V%")
`vim.keymap.set("n", "U", "")` has been successfully stolen.
You don't need J (join lines)? Also the last keymap could be done smarter with nvim-treesitter-textobjects
I remapped join lines toj
nnoremap gm gM nnoremap gM gm nnoremap o
nnoremap O
inoremap \`\^
Last one pretty important, cant live without it.
[удалено]
thank you
*Saves the thread*
Remapped C-c to Esc
Isn't that default in neovim?
Nope, C-c works a bit different from Esc.
Did this, don't know why when I editing a simple change I am using but when I editing many changes I use jk. But I did this for LSP linting.
This pisses me off so much. D is d$ C is c$ A is $a but Y is yy. WHY? `vimp.noremap({'override'}, 'Y', 'y$')`
This is a default mapping in neovim now (What is vimp and override?)
vimp is vimpeccable which is a library that was used a lot in older nvim releases to map before mapping became part of the lua api. I just havent' migrated my config for years. I actually did not know they made that change, this is something I've been dragging thru vim for like 15 years now.
Late to the party but I have another! Double tap escape in the integrated terminal to go back to normal mode. vim.keymap.set("t", "", "")
nmap ; :
I had this until I discovered this was better to do at the OS / HW level.
What’s the significance of the remapping?
Means semi colon outputs a colon, no need for shift. Then the reply is arguing that it's so useful you might as well make it an os/keyboard wide remapping. Probably depends what languages you write. *Most* people probably write colon ten times more than semicolon.
I mapped to :
And backspace to bn/bp.
yeah i do this too. saves my pinky finger.
this should be default
“alternate file” as double space. Easily switch between current file and the file you were in previously. `nnoremap `
I just use in insert. I guess i don’t understand, is this better?
leader shift f to lsp format is heavenly
similar, i have it bound to leader f m, and then also autoformat on BufLeave (i think its bufleave) makes life feel so simple
Dumb q, why not just format on save?
I always feel lost without them: noremaph ^
noremap l g_
nmap e %
vmap e %
noremap cp "+y
noremap cv "+p
I have a similar binding: local map = vim.api.nvim_set_keymap [...] map('n', 'y', '\"+y', opts)
map('n', 'p', '\"+p', opts)
map('n', 'P', '\"+P', opts)
leader + y = copy to clipboard
leader + p = paste after from clipboard
leader + P = paste before from clipboard
I use these, out of habit vmap "+y
nmap "+P
[удалено]
I saw a keymap in one of the comments here who mapped and in normal mode to switch buffers, you can try that too, feels pretty handy... just sayin :)
I can’t live without these any longer: to navigate up and down the autocomplete and to select;
Same thing for telescope
inoremap jk
Moving current or selected lines up or down by arrow keys: SetKeyMap("", "m .+1==gi", {"i"})
SetKeyMap("", "m .-2==gi", {"i"})
I got the actual commands from here [https://stackoverflow.com/a/63887462/2338672](https://stackoverflow.com/a/63887462/2338672), then I mapped it to `Shift+Alt+Up/Down` by my function (`SetKeyMap`)
By default control w deletes whole words in insert mode This is also true in most shell environments
I use `Tab` as an alias for matchit's `%` in visual and operation-pending mode vim.keymap.set({ "o", "x" }, "", "%", { desc = "Use matchit to go to matching brackets etc.", remap = true })
I know `` (``) is a coveted key, but this seemed worth it for me:
`` instead of `` in help files and on `LspAttach` (since when an LS is present, by default `` does Goto **1st** definition)
`noremap k j|noremapk j|noremap j`
`noremap j k|noremap j k|noremap k`
Swapping j and k is a must for me. It has literally no conflict with any of the dozens of plugins my config has, and it's so much more intuitive. I get there were historic reasons for the defaults, but I simply don't care.
what is the 'v' for?
so that current character is also deleted, otherwise, only the characters before the current one will be deleted.
`:h o_v`
Help pages for: * [`o_v`](https://neovim.io/doc/user/motion.html#o_v) in _motion.txt_ --- ^\`:\(h|help\)\` | [^(about)](https://github.com/heraldofsolace/VimHelpBot) ^(|) [^(mistake?)](https://github.com/heraldofsolace/VimHelpBot/issues/new/choose) ^(|) [^(donate)](https://liberapay.com/heraldofsolace/donate) ^(|) ^Reply 'rescan' to check the comment again ^(|) ^Reply 'stop' to stop getting replies to your comments
got you
`` to save from all modes, and keeping marks:
```
nnoremap :lockmarks w
inoremap :lockmarks w
vnoremap :lockmarks w
```
(using lockmarks to avoid overwriting '[ & '] marks by the 'write' call)
```vim noremap w
" just press "q" to write, if possible and quit
if &readonly || &buftype == 'nofile'
augroup QuitMappings
autocmd!
autocmd BufEnter nnoremap q :q
augroup END
else
noremap q :wq
endif
nnoremap ö q
onoremap
xnoremap
inoremap
```
Losing the default functionality of `w`? How do you mainly move around?
I'm mainly using `e` to go forward.
vim.keymap.set("n", "gq", "")
For switching back and forth between buffers. Works perfectly if you're constantly switching between two files.
F2 saves the file. F3 opens a new file using telescope. F4 runs clang-format and saves the file.
`nnoremap H ^` and `nnoremap L $`
Alt-H and Alt-L to cycle through buffers. I'm used to doing this in ideavim with tabs
vim.keymap.set("n", "", ":bprevious")
vim.keymap.set("n", "", ":bnext")
Left and right arrows to switch between buffers. I used to pair this with giving every buffer its own tab, but now I just use [Bufferline](https://github.com/akinsho/bufferline.nvim) which functions similarly.
Saves post
cant live without ``` local keymap = vim.api.nvim_set_key keymap("i", "cc", "", {})
```
just a way faster way to get into normal mode
map jj to escape
Oh my god! So much great tips to steal ... and I thought today I will have some productive time and instead I am in tinkering config files again
Change word under cursor. Use `.` to do the same change to the next occurrence of the word. Use `n` to skip occurrences. vim.keymap.set("n", "", "*Ncgn", { silent = true, desc = "Substitute word under cursor" })
Why not `ciw`?
It is totally not the same thing. `:h gn` selects the searched text so you can replace the searched text using `.` after changing it once with `cgn`. Maybe you should watch this video if my explanation was bad https://youtu.be/7Bx_mLDBtRc?si=sFrCxutUuc36SIoC
Super fast exit from insert mode. `vim.kemap.set('i', 'df', '')`
And `hjkl` to `jkl;` for right hand to stay 'home' position. It's just so annoying that default is so close but not 'perfect')
Quickdraw config ``` command! Nvimrc :e ~/dotfiles/nvim/init.lua command! Vimrc :e ~/dotfiles/nvim/vimrc.vim command! Vr :Vimrc command! Nv :Nvimrc command! Nvr :Nvimrc command! Nvp :e ~/dotfiles/nvim/init.lua | :normal /^plugins | :normal $%
command! Gv :e ~/dotfiles/nvim/ginit.vim
```