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.

Filter by
Sorted by
Tagged with
1 vote
1 answer
29 views

How to use tmap with <Plug>?

I am wondering how shall I use tmap along with <Plug>. Here is a snippet of the context where I am using it: vim9script import autoload "../lib/foo.vim" noremap <unique> <...
Barzi2001's user avatar
  • 481
-1 votes
1 answer
28 views

noremap not working in modeline

For a specific file I need some dedicate configurations. So, I put this in the top of the file: % vim: noremap a <ESC>l<ESC> I get the following error message: "test" 2L, 30B ...
fauve's user avatar
  • 111
1 vote
1 answer
31 views

Remapping a Family of Shortcuts

I would like to remap/create the family of shortcuts starting with d into a version that does not yank it to any register. Is there a programmatic way of doing this or do I have to do it manually? For ...
Philippe Fanaro's user avatar
0 votes
1 answer
40 views

Make operator that doesn't change gv

I'm trying to redefine my inner and outer line text objects so that they don't change gv. First I had onoremap <silent> il :<C-u>normal! $v^<CR> I changed it based on Using visual ...
theonlygusti's user avatar
  • 2,229
0 votes
2 answers
80 views

Set command-line local variable

How can I set a variable that only the current command line sees? So that :let s:one = 1 | echo s:one prints 1 but running two commands :let s:one = 1 :echo s:one errors E121: Undefined variable: s:...
theonlygusti's user avatar
  • 2,229
1 vote
2 answers
185 views

How do I remap `%` with `K` in visual and normal mode in `init.vim` (and vice-versa)?

I have the following in my init.vim: nnoremap K \% " Swap K with % in [n]ormal mode vnoremap K \% " Swap K with % in [v]isual mode xnoremap K \% " ...
M.A Shahbazi's user avatar
1 vote
2 answers
407 views

Using VSCode key bindings inside Vim

Is there any way to use VS Code key bindings in Vim? I really like the VSCode linux key bindings, but would like to give a try to Vim without losing productivity.
S. br's user avatar
  • 19
0 votes
1 answer
61 views

Passing arguments to function in remapping

I have the following solution in my .vimrc that allows me to wrap text with certain delimiters that works function! Wrap(action, delim) let l:delims = {'(': ')', '[': ']', '{': '}', '"': '&...
hilbor's user avatar
  • 15
1 vote
1 answer
98 views

verbose map shows the mapping but not the source file it is defined

I use Neovim 0.8.3 with LazyVim setup. In my setup, line movement commands such as j and k move cursor from one displayed line to another displayed line. I checked the mapping of these letters with ...
Mert Nuhoglu's user avatar
1 vote
1 answer
62 views

change behaviour of > / < and >> / << to insert / remove only leading tabs

i want > / < and >> / << to simply insert and remove tab characters at the beginning of the line. variant: i would even prefer to have> / < and >>/ << insert / ...
windfish's user avatar
  • 123
0 votes
0 answers
19 views

Shortcut keys sometimes type commands into the buffer for the file I am editing

I'm using gvim with the included mswin.vim keybindings, so Ctrl+S AKA C-S will save the buffer. It provides these mappings. " Use CTRL-S for saving, also in Insert mode (<C-O> doesn't work ...
interfect's user avatar
  • 163
0 votes
1 answer
40 views

Why doesn't my cmdwin remapping work?

I'm trying to unmap the normal mode open cmdline-window bindings: nnoremap q: <NOP> nnoremap q? <NOP> nnoremap q/ <NOP> Do not have any effect, even though :verbose map q: shows it'...
theonlygusti's user avatar
  • 2,229
1 vote
1 answer
72 views

Map to for loop

How can I make a mapping that includes a for-loop? xnoremap <leader>y :for i in [1, 2, 3, 4] | echo i | endfor errors E121: Undefined variable: i and xnoremap <leader>y :for line in ...
theonlygusti's user avatar
  • 2,229
0 votes
1 answer
1k views

How to run current python file in floating terminal? Using neovim and NvChad

FYI noob here. I want to run current file in floating terminal. I'm using NvChad and when I execute ALT+i I get the following: I already played with some key binds, but I haven't achieved what I need....
indochina's user avatar
1 vote
1 answer
134 views

How to map a number followed by another key?

[I have read How to debug a mapping? and although that is a great starting point I am still clueless why this does not work.] I want 2* to search for the next occurence of the previous word in ...
jakun's user avatar
  • 155
-1 votes
2 answers
42 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. ...
Anton Wessel's user avatar
1 vote
1 answer
88 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]]) ...
theonlygusti's user avatar
  • 2,229
1 vote
1 answer
168 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 ...
MaxGyver's user avatar
  • 229
0 votes
1 answer
30 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
user2741831's user avatar
1 vote
2 answers
878 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 ...
pepperdreamteam's user avatar
1 vote
2 answers
168 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 ...
MaxGyver's user avatar
  • 229
0 votes
1 answer
83 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: ...
Paul Rougieux's user avatar
1 vote
1 answer
33 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 ...
anakimluke's user avatar
0 votes
1 answer
73 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 ...
mohamadi_arch's user avatar
0 votes
1 answer
137 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 ...
Luna's user avatar
  • 1
1 vote
1 answer
55 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 ...
COil's user avatar
  • 121
0 votes
0 answers
276 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 ...
user202729's user avatar
1 vote
1 answer
100 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 [* ...
Arber's user avatar
  • 113
0 votes
2 answers
32 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><...
Validus Oculus's user avatar
1 vote
2 answers
49 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 ...
IBM's user avatar
  • 13
0 votes
3 answers
29 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><...
CIsForCookies's user avatar
2 votes
1 answer
105 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 ...
Paul's user avatar
  • 23
1 vote
0 answers
32 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'...
NeoZoom.lua's user avatar
  • 1,322
3 votes
3 answers
407 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 ...
user45331's user avatar
1 vote
1 answer
602 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 ...
user4687531's user avatar
0 votes
1 answer
285 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>...
abbood's user avatar
  • 673
0 votes
1 answer
39 views

Go to directory in link (instead of opening the file)

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 ~/...
ranemirusG's user avatar
0 votes
2 answers
1k 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 ...
milintime's user avatar
0 votes
1 answer
78 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 ...
LostInHilbertSpace's user avatar
1 vote
1 answer
102 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" '...
gmtek's user avatar
  • 145
0 votes
0 answers
42 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 ...
e.ad's user avatar
  • 101
0 votes
1 answer
58 views

Jump to file containing mappings

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 ...
msmechanized's user avatar
0 votes
1 answer
84 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 ...
kraxli's user avatar
  • 1
0 votes
1 answer
37 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 --...
Enlico's user avatar
  • 2,172
0 votes
1 answer
17 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 ...
Enlico's user avatar
  • 2,172
1 vote
1 answer
31 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 ...
Zantier's user avatar
  • 111
0 votes
1 answer
119 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 ...
Dugesia7's user avatar
0 votes
1 answer
29 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 ...
Enlico's user avatar
  • 2,172
0 votes
0 answers
26 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. ...
Tropilio's user avatar
  • 109
0 votes
1 answer
74 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 = &...
evianpring's user avatar

1
2
3 4 5
31