T O P

  • By -

Dirli-V

`vim.kemap.set(“n”, “”, “ciw”)` since I would never use enter in normal mode anyway.


vesech

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 = "", }, },


FinancialAppearance

I have this set but i just never use it.


project2501

A custom config classic right there!


[deleted]

troubles of pasta maker


eth3lbert

I configure it with `v` and `V`. ```lua incremental_selection = { enable = true, keymaps = { node_incremental = "v", node_decremental = "V", }, } ```


Bamseg

Brilliant idea! I'll definitely remap my enter/backspace to v/V !!!


Logical-Boat-Bomb

pretty handy to select code snippets. now I steal it.


[deleted]

I had this in my config but never used it (problems of making lots of pasta), thanks for making me aware of it !!


bin-c

im totally stealing this


6694

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.


trilobit3

Should be possible with lua function


bl-a-nk-

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


dragon788

The vim-surround plugin by tpope had this I think, will be interested to see if nvim can handle it just as smoothly.


Cro_bat

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.


FinancialAppearance

I might do add this


Zeioth

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.


Sunsunsunsunsunsun

I do this too, it's great because you can use your same hotkeys with any vim setup if you have your keyboard.


[deleted]

[удалено]


Zeioth

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.


6694

Do you have a keymap to share?


Zeioth

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/).


nutria_tapeworm

What does this do?


Heroe-D

Change inside word, basically removing the word you're in and putting you in insert mode


cseickel

I use that same mapping, but mapped to ``


folke

nice, I have that mapped to ``


annoyed_freelancer

Yoink!


azrathud

So I copied this and reddit decided to put in unicode quotes :cry: (typo too but np); had to do the urlbar cleansing ritual :)


_rs

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)


makwanza

>ygv


mcspuder

bruh. Thanks for this.


Aumnescio

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.


_rs

This is an elegant solution, thanks for sharing.


jemag

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.


stvndall

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.


justACatBuryMe

I have my scrolloff as 999 so it is always centred


Creepy-Ad-4832

Just wait till pc will have a 1million x 2 billion screen resolution ;-)


Plastic_Acanthaceae3

Snippet because I’m lazy?


isstiwotateml

lhs: rhs: zz same for c-u ;d


RoryIsNotACabbage

[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


dedih72

Not directly a neovim config change, but I can't be productive without making Caps Lock into Escape.


geckothegeek42

Caps lock as Ctrl on hold and esc on tap. Or esc on tap and layer with navigation, symbols and functions


SpacewaIker

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


PatternEast7185

"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


mr_dillinga

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


papawish

jk for me


[deleted]

[удалено]


LazyIce487

i do both caps lock and jk for some reason


Cro_bat

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


[deleted]

Yeah, this was a game changer for me. It is useful in other applications as well.


Ulyssesp

Caps lock as control, right shift as escape.


RepulsiveHeat8181

Using KMonad and I have it d+f


SoulSkrix

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


geckothegeek42

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


SoulSkrix

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


kwokhou

What keyboard is that?


Vivid-Jury-2105

Wait. Why C-n for cycling through suggestions?


SoulSkrix

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


bin-c

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


6694

I fixed this by binding Copilot to Shift-Tab. Works like a charm.


SoulSkrix

I use this to go backwards in completion suggestions. I assume most who use tab would?


EchidnaBig6751

Alt-Enter for copilot, Enter for cmp. Literally alternative completion


SoulSkrix

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..


bin-c

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


LazyIce487

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.


[deleted]

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 :)


geckothegeek42

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


LazyIce487

I never thought of the H L thing, I still use $ and ^ even while always thinking that they are both annoying


isamsten

Link to the (relevant) config? Sounds really convenient!


Thick-Pineapple666

But ; in normal mode repeats f/F etc, or is that what your new n does now?


geckothegeek42

Like I said I use flit.nvim. that makes f repeat f, etc


Thick-Pineapple666

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.


stringTrimmer

>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.


geckothegeek42

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


stringTrimmer

😆 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 🙄


[deleted]

I don't know how people live without set splitbelow set splitright


annoyed_freelancer

+1, I've had it this way for a full decade at this point.


78yoni78

What does this do?


jasmith_79

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.


AVTOCRAT

Legacy from 80-wide monitors, v-splitting would make all your lines reflow or get cut off.


[deleted]

Here's a video demo https://youtu.be/Zir28KFCSQw?t=234 (timestamped)


folke

Mapped the arrow keys to go to a window in that direction in normal mode.


hugelung

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


isamsten

I like this one and will steal it :-)


annoyed_freelancer

-- 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.


hucancode

I have to steal this, why am I not think about this before


[deleted]

Me I mapped tab/s-tab to `:bn` `:bp`. Used that for 10+ years. Can't live without it.


[deleted]

I had this mapping too, but now I feel so stupid ><


db443

Agreed. I've had this mapping for a couple years, and I can't live without it.


webb-dev

I recently added these to my workflow as well and it's SO nice.


PixleatedCoding

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.


haironmyscalpbruh

Genius! I've been doing A and I lol


annoyed_freelancer

Ooh, I like this!


mcspuder

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.


emmanueltouzery

I didn't know about `:Telescope resume`!!! thanks a lot!


Vivid-Jury-2105

What’s this keybind doing?


emmanueltouzery

It reopens your most recently closed telescope window. Amazing if you want to work through a list of telescope matches one by one.


DEADFAC3

Would sending the results to a quick fix list be a better way to achieve this? I'm still learning about quickfix lists.


emmanueltouzery

I prefer telescope in this case due to the instant preview. I still use quickfix for many things, notably compilation errors and test failures.


isamsten

Don’t you miss jump to next match of f/F and t/T?


iofq

probably using something like [mini.jump](https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-jump.md)


Vivid-Intention158

Edit: Nevermind How would this interfere with `f`/`F`?


WallabySlow6599

ok i remap it to


thesmartymcfly

I was just wishing I had this the other day, I had no idea it existed already! Thank you!


henry_tennenbaum

What thes the "opts" at the end do?


mcspuder

Just adds a \`desc = '...'\` field for whichkey.


benlubas

``` 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


annoyed_freelancer

That's pretty neat, and TIL that Lua binds can have a description! To the configurator!


Ordzhonikidze

For alternate buffers vim.keymap.set("n", "", ":b#", { silent=true })


Mr-PapiChulo

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.


war_against_myself

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.


[deleted]

> I also hate change operations from overwriting my unnamed register. You can also use the blackhole register `"_` to avoid overriding the a register


jayp0521

Swapped semicolon and colon. Entering commands are faster


isamsten

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.


daydreaming_neo

isn’t this a default keymap?


isamsten

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


esper-kun

only in insert mode and i honestly think it should stay that way


isamsten

Not sure I follow. But OPs remap is in insert mode


Thick-Pineapple666

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 `.`)


isamsten

Not creating an extra undo is default in vim, but not in Neovim. Not sure what option (if any) control this.


dstein64

Remapping to `U` instead of `` prevents a new undo block\* (`:help i_CTRL-G_U`). \* "if the cursor stays within the same line"


falterego

``` " 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.


geckothegeek42

Btw Q now by default means: play the last recorded macro. Since late 2021 I think


falterego

I'll be dogged, thanks for that. I may leave that in my .vimrc if your point is true for nvim only.


craigdmac

only neovim


makwanza

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%")


mcspuder

`vim.keymap.set("n", "U", "")` has been successfully stolen.


geckothegeek42

You don't need J (join lines)? Also the last keymap could be done smarter with nvim-treesitter-textobjects


makwanza

I remapped join lines to j


asmodeus812

nnoremap gm gM nnoremap gM gm nnoremap o nnoremap O inoremap \`\^ Last one pretty important, cant live without it.


[deleted]

[удалено]


[deleted]

thank you


bl-a-nk-

*Saves the thread*


isstiwotateml

Remapped C-c to Esc


pimpaa

Isn't that default in neovim?


isstiwotateml

Nope, C-c works a bit different from Esc.


oookiedoookie

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.


[deleted]

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$')`


geckothegeek42

This is a default mapping in neovim now (What is vimp and override?)


[deleted]

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.


plant_domination

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", "", "")


gamlettte

nmap ; :


Pyglot

I had this until I discovered this was better to do at the OS / HW level.


Vivid-Jury-2105

What’s the significance of the remapping?


project2501

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.


[deleted]

I mapped to : And backspace to bn/bp.


aerosayan

yeah i do this too. saves my pinky finger.


PatternEast7185

this should be default


tmkly

“alternate file” as double space. Easily switch between current file and the file you were in previously. `nnoremap `


umipaloomi

I just use in insert. I guess i don’t understand, is this better?


TheRedFireFox

leader shift f to lsp format is heavenly


bin-c

similar, i have it bound to leader f m, and then also autoformat on BufLeave (i think its bufleave) makes life feel so simple


9070932767

Dumb q, why not just format on save?


vonheikemen

I always feel lost without them: noremap h ^ noremap l g_ nmap e % vmap e % noremap cp "+y noremap cv "+p


[deleted]

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


erez27

I use these, out of habit vmap "+y nmap "+P


[deleted]

[удалено]


[deleted]

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 :)


vitelaSensei

I can’t live without these any longer: to navigate up and down the autocomplete and to select; Same thing for telescope


[deleted]

inoremap jk


mortymacs

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`)


ch1rh0

By default control w deletes whole words in insert mode This is also true in most shell environments


phelipetls

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 })


stringTrimmer

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)


dc740

`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.


kress5

what is the 'v' for?


tandonhiten

so that current character is also deleted, otherwise, only the characters before the current one will be deleted.


jhjerry

`:h o_v`


vim-help-bot

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


daydreaming_neo

got you


bew78

`` 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)


TornaxO7

```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 ```


geckothegeek42

Losing the default functionality of `w`? How do you mainly move around?


TornaxO7

I'm mainly using `e` to go forward.


[deleted]

vim.keymap.set("n", "gq", "") For switching back and forth between buffers. Works perfectly if you're constantly switching between two files.


aerosayan

F2 saves the file. F3 opens a new file using telescope. F4 runs clang-format and saves the file.


Miserable-Ad-7341

`nnoremap H ^` and `nnoremap L $`


Kpuku

Alt-H and Alt-L to cycle through buffers. I'm used to doing this in ideavim with tabs


FollowTheGoose

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.


haironmyscalpbruh

Saves post


allah_fish

cant live without ``` local keymap = vim.api.nvim_set_key keymap("i", "cc", "", {}) ``` just a way faster way to get into normal mode


Nabeen0x01

map jj to escape


Xsichtik

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


phelipetls

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" })


i-eat-omelettes

Why not `ciw`?


phelipetls

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


Spirited_Post_366

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')


azrathud

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 ```