# Questions tagged [key-bindings]

Doing an action when pressing a key. These are also called key mappings or mappings. For questions about default key bindings, as well as creating or redefining key bindings.

1,447 questions
Filter by
Sorted by
Tagged with
30 views

### Mapping key sequence begining with underscore (e.g. _x) cannot be used, why?

For a special application I am invoking vim with following mapping: vim -u /root/.vimrc ... -c "nnoremap _z \"zyyq:" If I map to another key sequence, e.g. <F5>, all works fine. ...
19 views

### Remap p if no register is specified

To stop pasting over a selection from yanking that selection, I would like to remap p so that it doesn't yank the just-rewritten selection: vim.keymap.set("x", "p", [["_dP]]) ...
• 1,931
1 vote
45 views

### Find git root directory in key mapping

I would like to find the git root directory and use it as argument for :FZF in a key mapping like this: nnoremap <Leader>eg :FZF git rev-parse --show-toplevel<CR> Unfortunately, this ...
• 207
22 views

### Increase a number with behave mswin

Is there a way to increase the number under the coursor while still using behave mswin? Since behave mswin overwrites CTRL_A
• 269
1 vote
116 views

### Enable github copilot in Neovim for shell command editing

I use bash and like to use the built-in command Ctrl xCtrl e to invoke an editor in the shell in order to edit the current line. This creates a temporary file, named /tmp/bash-fc.[Some random ...
1 vote
121 views

### Call original gf after remapping gf to custom function

gf doesn't work for absolute links used in Azure DevOps yaml files, p.e. - template: /devops/template/my-template.yml (It only works without the leading slash.) This is why I have created my custom ...
• 207
18 views

### How to map <LocalLeader>s to send send the selected text to SlimeRegionSend?

For python development, I use slime with tmux and the following configuration let g:slime_target = "tmux" " configuration for vim in a split tmux window with a REPL in the other pane: ...
1 vote
23 views

### How to execute a command in normal mode ignoring any mappings made to it?

For example, if I have the mapping nnoremap p ]p and want to put text only once with the unmapped p behaviour, is there a key I can press before p to bypass those mappings? Something like a shell ...
38 views

### How can I open MDN link in coc.css popup?

Sorry for my English. I installed coc-nvim plugin in my vim (gvim in windows) after that I insert CocInstall coc-css command for css snippets. In this picture I highlighted MDN Reference. How can I ...
25 views

### How can I set a shortcut for open popup in coc.nvim in two steps?

Sorry for my English. I installed coc-nvim plugin in my vim (gvim in windows) after that I insert CocInstall coc-css command for css snippets and it works correctly. When I start writing in vim both ...
36 views

### How to map Vim command and CTRL-W R together?

Problem I am trying to map the F10 key with theterminal bash % command so I can execute the current open file with bash in a split pane setup (this functions works). The problem is when I try to add ...
• 1
17 views

### How to remap F16 to F19 on macOS?

So far I managed to remap F1 to F15, but I can't remap F16 to F19. When I am in insert mode, nothing happens. What is weird is that in the terminal, I can see something is intercepted, for example, if ...
• 101
74 views

### Why doesn't ctrl+left and ctrl+right work by default in alacritty?

As in the title. I run vim in xterm and ctrl-left and ctrl-right does work (skips over one word in the text by default -- this is likely the intended behavior, also because it works the same way in ...
• 339
1 vote
41 views

### Remap square bracket commands to fit a swiss layout keyboard

I'm new to vim and currently trying to understand the different commands. :help index shows me a list of all commands for each mode. Section 2.3 is about "Square bracket commands" like [* ...
• 113
26 views

### How to remove empty lines from visually selected block?

I am using following mapping. The command works fine but when I open a new file, all the empty lines are highlighted. Could you please check my mapping? vnoremap <leader>n :g/^\$/d<CR><...
1 vote
32 views

### x (delete character under cursor) not working when creating a shortcut

Yeah... let me explain. So I have this text that has hyphens on some words at the end of the line to join words, like this: hello, my na- me is bruh... This is a scanned book with OCR, and on every ...
25 views

### How to use AG plugin to search a word inside a git repo?

I want to enable vim-ag to search a word inside specific directory. Currently I have the following mapping in my vimrc: noremap <leader>a :Ag! <C-r>=expand('<cword>')<CR><...
34 views

### How to implement a symbol keyboard layer in Vim?

I recently came across this question: Mapping symbols and special characters to home row in insert mode, which introduced me to the idea of a symbol layer on the keyboard. This seems like a nice thing ...
• 23
1 vote
25 views

### How to map both keymaps <C-w>q and <C-w><C-q> to do nothing?

As title. I usually mistyped <C-w> into <C-w><C-q> and it close the window I was working on. That is really annoying... I have tried mapping this keymap into <nop> but it didn'...
• 1,131
345 views

### How can I create mappings to execute specific Vim commands, depending on if a makefile exists?

In general, I have makefiles setup anytime I'm working on C projects. To save and compile these projects, I've bound the ' key to do this: map ' :wa<CR>:!make<CR> However, I sometimes ...
1 vote
100 views

### <Tab> out of insert mode - lua keymap

I'm a relatively new neovim user. I use nvim-autopairs to always induce matching (, [, {, ', " character pairs, and automatically placing my cursor inside them. As an example, in insert mode, if ...
• 111
75 views

### How to grep only the contents of the current file?

I have this alias to grep under the cursor (for the entire project): " bind K to grep word under cursor nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR><ENTER>...
• 591
30 views

I have a text file with lots of links to local directories which cointains .pdf files. I know about gf, but is there a way to open only the directory and not the file? For example, from this link ~/...
85 views

### How to remap the esc key to "capslock" in linux?

Having to press the esc key every time that you want to enter normal mode is a pain. I have seen multiple answers where people map combinations like jj. But why use that when you can map the capslock ...
34 views

### How to debug this problem with the :map command?

I was trying to view my key mappings because I can't seem to jump through parts of snippets in UltiSnips. So I type :map and hit enter and it comes up with the start of the list, but there I can't ...
1 vote
50 views

### ci" or ci' doesn't work in vim key bindings for zsh command line editing [closed]

I have vim keybindings enabled for command line editing by bindkey -v. When I am trying to use ci", ci', di" or di' it doesn't work. For example: If I have a command echo "hello" '...
• 11
23 views

### Mapping <c-h> behaves like <c-s-h>

I am adding the basic config to mi vim nnoremap <C-h> <C-W>h nnoremap <C-j> <C-W>j nnoremap <C-k> <C-W>k nnoremap <C-l> <C-W>l but I see the weird ...
• 101
31 views

My nmap returns the following two lines among other things: n bh * <Lua 5: vim/_editor.lua:344> n bl * <Lua 4: vim/_editor.lua:344> I don't want those mappings because ...
• 103
52 views

### mapping > (and <) to function for special indent

I would like to map > (and <) in normal mode to a function such that it indents the line and keeps the cursor at the original position after performing the indent Here my code in the file ...
24 views

### Is it possible to delete part of a wildcard autocmd?

If I put this augroup AU_NAME autocmd! autocmd CursorMoved *.cpp,*.hs echo localtime() augroup END autocmd! AU_NAME CursorMoved *.cpp in my vimrc, then open a file and enter :au AU_NAME, I see --...
• 2,014
15 views

### Why does the help suggest to end the lhs of a plug mapping with a semicolon?

In :help using-<Plug> a suggestion is given as to how to name the left hand side of a <Plug> mapping: To make it very unlikely that other plugins use the same sequence of characters, use ...
• 2,014
1 vote
20 views

### Why doesn't the dot command work after pasting in visual mode?

1. Why doesn't this work? If my text file is: aaa test bbbb test test bbbb test test bbbb test I can yank aaa, select bbbb in visual mode, and type "0p, to replace it with aaa, with the idea of ...
• 111
43 views

### Can I make a new mode in Nvim?

I want to create a new mode other than normal, visual, or insert because I want to: change the functions of all keys at once allow remapping preserve the mappings of other modes and retrieve when go ...
• 63
19 views

### Why inoremapping <c-e> shadows <c-e> completion functionality?

Foreword Open a new file with vim -Nu NONE and insert the following text (| is to indicate the position of the cursor, in insert mode) longline lo| longerline Now hit Ctrl-XCtrl-N and the ...
• 2,014
23 views

### Remove words from comments in vim autocompletion

I have looked for similar questions but I was quite surprised to not find anything similar... either I am the first person on this planet to have this issue, or I have searched using bad keywords. ...
• 109
31 views

### My key mapping appears when I run :map, but when I try to trigger it I get "E492: Not an editor command"

I am learning vim. I am at a part that I am very excited about because I think it will lead to a lot of productivity gains: key mapping. I added the following mapping to my .vimrc: let mapleader = &...
• 107
18 views

### How do I disable access keys in gVim

I'm looking for a way to disable the access keys in gVim. For example, when I press alt+f, the "File" menu pops up. This is behavior that I want to remove, so I can use these keybinds for ...
34 views

### How to make a keymap for a series of action atomic (which can be undo by just press one time 'u')?

Here is my keymap: nmap <A-y> viW<Plug>VSurround]%a()<ESC>h"+pF(<CR>l vmap <A-y> <Plug>VSurround]%a()<ESC>h"+pF(<CR>l Which is a markdown ...
• 127
24 views

### Double Shift event to map some events

I'd like to migrate some of the my favourite features of Intellij into Vim - double shift to search everywhere and integrate it with FZF. But I have doubts whether it is possible in vim/nvim or any ...
• 101
38 views

### NeoVim runs part of mapping while starting

I am using a Raspberry Pi for learning C. I use NeoVim and Mingw-GCC on the Pi over SSH. Building is done with a custom script named build. Initial builds were done by calling ./build from the command ...
19 views

### Map key code to specific forward search query

I'm trying to remap <leader>t to search for a specific string [ ] to save time running / every time I search for it. Things I've tried :nnoremap <leader>t /<CR> but it ...
32 views

### What other than mappings and abbreviations can change the text I'm typing?

The question When editing TeX files (to do so, I use vimtex) if I've discovered that if I write lll in insert mode, I get \ell. How do I find why this is happening? My research I thought "ok, I'...
• 2,014
43 views

### vnoremap to sort highlighted lines by length not working as expected

I found a command that would sort highlighted lines by their length and wanted to make a mapping for it so that I could avoid typing it every time. vnoremap ,s :<C-U>'<,'> ! awk '{ print ...
1 vote
78 views

### Short delay in buffer swtich with nnoremap binding

I have nnoremap <C-]> :bn<Enter> nnoremap <C-[> :bp<Enter> so that I can use Ctrl + [ and ] to flip between buffers. I'm experiencing an issue where these two shortcuts behave ...
• 113
34 views

### Behavior of feedkeys() with "x" in {mode}

This is what it says in the help: 'x' Execute commands until typeahead is empty. This is similar to using ":normal!". You can call feedkeys() several times without 'x' and then one ...
1 vote
29 views

### How can I repeat a command a hexadecimal number of times?

The file I'm working on contains a hexdump. I pulled it directly out of memory, so it starts from an arbitrary offset, like this: 0x1234: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0x1244: 00 00 ...
• 243
31 views

### <Ctrl-Left> in insert and normal mode deletes lines yet no such mapping in .vimrc

On my machine, mapping Ctrl← ends up deleting lines in both insert as well as normal mode. I tried to find where exactly these mappings were being sourced from: I tried: :verbose map <C-Left>, :...
• 207
12 views

### Change " to  or '' depending on whether it's typed after a space or non-space

The usecase is LaTeX, which I write using VimTeX. To make double quoted words one would write words''. However, I'm much more used, from many other contexts (both prose and code), to type " for ...
• 2,014