As of May 31, 2023, we have updated our Code of Conduct.

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
37 views

How to paste a string into specific line using nmap for key-binding?

Basically what I want to do is running this key-binding: nmap <Leader>= :[x digits]pu<CR> My mapleader Leader is a space. With the code above I want to paste the current string I have in ...
Edgar Magallon's user avatar
1 vote
2 answers
37 views

lnoremap doesn't seem to apply to insert mode when mapping an unwanted key combo to nop

This is a follow up to this question of mine. I found out that having :noremap ^[[29^ <Nop> in my vimrc is not enough to disable the unwanted effect of Ctrl+Menu in insert mode, so I looked at :...
Enlico's user avatar
  • 2,056
0 votes
0 answers
257 views

Add mapping to switch between keymaps

(Neo)VIM comes with a built in binding set in insert and command modes as CTRL-^ that can be used to toggle the use of :lmap mappings (see :help keymaps). I've been using this for years and it works ...
Caleb's user avatar
  • 2,215
0 votes
0 answers
23 views

From terminal to normal mode and run a command

I have the following mapping tnoremap <F8> <c-w>N :Vista!!<CR> but the command after <c-w>N (in my case :Vista!!) is not executed. How should I fix it?
Barzi2001's user avatar
  • 414
0 votes
1 answer
58 views

E488: Trailing characters in keymapping [duplicate]

Here is my command: nnoremap <Leader>pwd :!pwd | tr -d '\n' | xclip<CR> And I get error like this how to fix it? I havent found something useful to my issue Error detected while processing ...
lizhe's user avatar
  • 137
3 votes
1 answer
1k views

How can I map Ctrl-Alt-<letter> mappings in vim?

My keybindings are consistent and work across different operating systems, terminal emulators, browsers, tmux, etc. There are no clashes, but this sometimes means remapping things in some instances. ...
paradroid's user avatar
  • 239
0 votes
1 answer
29 views

Using the same key, move to the beginning of wrapped line, then to end of whitespace (soft BoL), then to beginning (hard BoL). And also for EoL

This is a feature that notepad++ has: when in a wrapped line, the first press of <Home> sends you to the beginning of the wrapped line. The second press sends you to the beginning of the text (...
ArcWand's user avatar
  • 11
0 votes
2 answers
89 views

How to use <c-i><c-o> in terminal mode to jump to/from next/previous cursor position?

When in terminal mode, I would like that <c-i> and <c-o> work like in insert mode, i.e. the cursor jumps to its next/previous position in accordance with the jumplist. How to make this to ...
Barzi2001's user avatar
  • 414
0 votes
1 answer
25 views

MacVim: <Delete> key does not work in a terminal window

I happened to find that we may open 'Terminal windows' in Vim and am happy to stop using terminal app. (It's available in v8 and v9) However, when I have a typing mistake, pressing Delete key does not ...
Charles Jie's user avatar
1 vote
1 answer
353 views

What's the reverse action of ctrl-y?

As title. Just like the case where <C-n> and <C-p> is a pair. I would like to know how to scroll down one line at a time.
NeoZoom.lua's user avatar
  • 1,200
0 votes
2 answers
145 views

Remap line completion to Ctrl-X

I am trying to remap the line-completion command (^X^L) to the simpler ^L (or Ctrl-L, or <C-L>). VIM's help (see :h ins-completion) suggests the following : :inoremap ^L ^X^L I tried adding ...
Feffe's user avatar
  • 1,739
0 votes
1 answer
31 views

How to make % motion work with quotes?

Is it possible to have % motion work with matching quote " or '? For example if we have text: "Lorem ipsum is placeholder text (commonly used in the graphic), 'print, and publishing ...
niekas's user avatar
  • 1,415
1 vote
1 answer
398 views

Change the keys for accepting coc dropdown?

When I type in Vim, I get autocomplete from coc. To accept one of the items on the list I need to press Ctrly. I would like to change this button to Enter but I cannot figure out how to do so. I do ...
Vinn's user avatar
  • 607
0 votes
1 answer
96 views

How to remap default vim text-object keys to different keys like ' to n

I use ci', va" pretty often, I would like to map text-object keys like " ' to more accessible keys like m, n since writing cin, vam is much easier than ci' va". I tried the following ...
Ytkimirti's user avatar
2 votes
1 answer
187 views

Mappings that work in nvim not working in vim [duplicate]

I have these key mappings that I use a lot in nvim, but they don't work in vim: " Move lines with Alt+Shift+j/k nnoremap <A-S-j> :m .+1<CR>== ...
paradroid's user avatar
  • 239
1 vote
1 answer
105 views

Small issue when running Python code straight from VIM

I want to be able to set up the hot key \\ to be able to write and run python script from VIM without each time having to type in :w :! python3 file.py What I have done so far is pasted the following ...
alpastor's user avatar
  • 115
1 vote
1 answer
118 views

Mapping snippet trigger in visual mode

I'm using the UltiSnips plugin. When selecting text, you can press the trigger key to enter Insert mode, and the deleted text can then be used in a subsequent snippet. The snippet I'm using is as ...
Alex867's user avatar
  • 33
2 votes
1 answer
109 views

How can I have <C-E> and <C-Y>'s normal mode functionalities also work in insert mode?

Once I've asked a general question about special characters, but I've not really pulled anything out of it. So now I'm asking a very specific question. I want to have Ctrl+e and Ctrl+y behave in ...
Enlico's user avatar
  • 2,056
0 votes
1 answer
34 views

Remap 'diffget' and disable the binding to 'do'

Since the keys o and p are close and sometimes I mistype them. I would like to remap diffget and disable do.
Arch Stanton's user avatar
0 votes
2 answers
35 views

How to put a text object under the cursor into an cmdline-mode command?

I'm using neovim v0.8.0 (nightly build) on Arch Linux. When in my plugins.lua where I have all my nvim plugins listed, I want to be able to use gX to open user/repo in my browser as https://github.com/...
ChocolateOverflow's user avatar
1 vote
1 answer
15 views

How can I deactivate CR only if its effect is to move to the next line?

I don't use arrow keys, but to avoid the cursor moving should I hit them by mistake, I have this in my vimrc: inoremap <Left> <NOP> inoremap <Right> <NOP> inoremap <...
Enlico's user avatar
  • 2,056
1 vote
1 answer
36 views

Can you use a different mapping within another mapping?

In my _vimrc, Say I have a keybinding like this: noremap gm f<Space>a{{c<Esc>0ylfcpa::<Esc>A}}<Esc>2F{ And another keybinding like this: noremap m3 mckmbkma2j I have tested ...
E'sW1111's user avatar
0 votes
0 answers
246 views

How to detect Ctrl+Enter in (neo)vim

My system is macOS. The terminal simulator I'm using is Alacritty. I run neovim inside a tmux session. In my case, both ↵ and control↵ send ^M(visually here, in fact it's a single char). So there is ...
NeoZoom.lua's user avatar
  • 1,200
2 votes
1 answer
165 views

Why does this mapping of g to gj give "'Undefined variable gj"?

E121: Undefined variable : gj E121: Undefined variable : gk local keymap = vim.keymap.set local default_opts = { noremap = true, silent = true } local expr_opts = { noremap = true, expr = true, ...
ZenVentzi's user avatar
  • 123
0 votes
0 answers
165 views

What is the Lua equivalent of an <expr> mapping with the ternary operator (?:)?

I was trying to set up a keybinding for vsnip in NeoVIM using Lua. The docs provide a vimscript snippet that I've been unable to translate. What would be the Lua equivalent of: imap <expr> <...
Matt Pfefferle's user avatar
3 votes
1 answer
131 views

Remap a key only when in final line of a file

I want to remap a key, but I want the mapping to be active only when I'm in the last line of my file. Is there a simple way to do this? I would also like to do a similar thing when I'm in the first ...
Ignacio's user avatar
  • 133
1 vote
1 answer
89 views

Accept hyphen when using `<C-R><C-W>`

I currently have this mapping: " bind K to grep word under cursor nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR><ENTER> My ag setting in vimrc: if ...
abbood's user avatar
  • 603
0 votes
1 answer
336 views

K does not show function signature

My full config is on GitHub. In my lsp-config.lua I have the following: buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) However, when I press K on the name of a ...
J86's user avatar
  • 205
1 vote
1 answer
63 views

Remap CTRL-x in insert mode

I want to remap <C-x> in insert mode (I do not use the completion commands via this key). This is what I tried: inoremap <C-x> <Esc> :x <Enter> inoremap <C-x> <C-o>...
Tom's user avatar
  • 43
-2 votes
2 answers
99 views

Custom Keybindings [closed]

I need a text editor for universal use and I decided that vim has the such potential. Vim is great software, but I as a new user find it difficult to get into, but I am determined to use it. The only ...
Pragmatic's user avatar
0 votes
2 answers
88 views

can I map multiple presses of <any key>?

I want to make more use of fF to navigate, but find the f to be clumsy. Eg. jump to "a" is fa. Instead, I'd like aaa to map to fa, bbbto map to fb etc. Is there an easy way to do this other ...
pinoyyid's user avatar
  • 133
0 votes
0 answers
107 views

What does <ctrl+w> <ctrl+z> do?

It seems like it exclusively kills preview windows, but I can't find any info on it? Any reason to use this over something else?
GameKyuubi's user avatar
2 votes
2 answers
31 views

Keymap or mark to jump to timestamped filename

I often need to access a machine-generated file. This file is always in the same folder, and is created each day with a timestamp, e.g. $HOME/foo/bar/target-2022-07-21.txt. Currently I use fzf to open ...
Aman's user avatar
  • 123
2 votes
2 answers
98 views

How to have both Ultisnips and Emmet-Vim depending of the filetype

I often use UltiSnips for other file types, but for HTML I'd like to use Emmet-vim. However, I'd like to use the same trigger for both. For this I have let g:user_emmet_expandabbr_key='<C-j>' ...
ElPC's user avatar
  • 31
0 votes
1 answer
47 views

Why is this mapping deleting text?

I'm using these two binding for indentation and dedentation of a visual selected block of text. " Indentation vmap <TAB> >gv " Dedentation vmap <S-TAB> <gv When I ...
hmaier's user avatar
  • 113
0 votes
1 answer
218 views

How to map a keybind to an already existing keybind provided by plugin

-- commenting single line keymap("n", "<C-/>", "gcc", opts) This is the line in my lua config for keybinds. I am using this plugin for commenting keybinds: use({ ...
Aryan Bansal's user avatar
1 vote
1 answer
56 views

bind/map a call to win_gotoid with script level argument

I'm trying to set a nmap bind to make the focus change from Window B back to Window A. Both Window IDs are store at the script level: s:win_id_a and s:win_id_b. The current snippet I've is the ...
Ramon Moraes's user avatar
0 votes
1 answer
74 views

Why does this key-mapping in vi not work correctly?

I'm just learning how to use the vi editor, and was trying to make use of the following map command in my .exrc file: map K 0I^I^[j0O^I^[j0 That is what appeared when I created the map in ex mode and ...
user1013210's user avatar
0 votes
0 answers
157 views

How to add another key to enter command mode?

In normal mode I have a a lot of <c-*> mappings. I end up typing <c-;> often when I intended to type :. I'd like to add a mapping for <c-;> to : but nothing I've done works. I've ...
jr_west's user avatar
0 votes
0 answers
475 views

Neovim how to rexecute vim.fn.expand() every time a keymap is called?

I would like to create a keymap to edit files by my current path, while showing the directory path of the current file For example, if I was editing file: /Users/[username]/projects/test.py Clicking &...
tommyp's user avatar
  • 111
0 votes
1 answer
462 views

how to accept tabnine suggestion?

I'm using tabnine and COC. I have a ~/.vimrc with the following lines: inoremap <expr> <C-j> pumvisible() ? "\<C-N>" : "j" ...
CIsForCookies's user avatar
0 votes
2 answers
522 views

How to replace text with clipboard content in VsCode using VsCodeVim?

I am using vscode + vim. Consider a common scenario where I have to yank/delete some text from one place and replace it with some text anywhere else. But as I need to replace I have to first delete ...
Maheer Ali's user avatar
1 vote
0 answers
119 views

How to map keybindings only for specific file type?

In vimwiki, <C-x><C-o> provides available tags in autocomplete dropdown. I am attempting to map that key mapping to something easier like (ctrl+alt+space) and only when I am in a markdown ...
haku's user avatar
  • 111
3 votes
1 answer
144 views

Why is my # mapping behaving oddly in TeX files?

I recently made the following key-map in my .vimrc file: inoremap # \ inoremap \ # since I just want to switch those two key on my keyboard, everything works just fine until I notice this: Only in ....
Jiang Yuanhao's user avatar
1 vote
2 answers
34 views

Where's the documentation for Ctrl-C while in [Command Line] buffer?

Long ago I discovered that q: opens a [Command Line] buffer where I can enter and edit an ex command line using all the power of Vim. Next, some time ago, I discovered that I can access that mode even ...
Enlico's user avatar
  • 2,056
2 votes
1 answer
157 views

What does underscore cursor (caret?) and half cursor (caret?) mean?

I noticed different styles. But I cannot relate to what I typed, maybe because I have many missed key strokes.
samuelnihoul's user avatar
1 vote
1 answer
130 views

How to make vim position the cursor with custom mapping for <C-LeftMouse>?

I am using vim 8.2 in terminal with mouse support (mouse=a) and trying to define a custom mapping for <C-LeftMouse>. The mapping itself works but the problem is that vim stops setting cursor ...
Maxim V.'s user avatar
3 votes
1 answer
70 views

Is it possible to scroll a popup via keyboard?

If I do :let id = popup_create(['hello', 'hello', ... a lot of these, 'hello'], {}), I can reproduce the case of a popup that contains more items that its height, thus having a scrollbar. How do I ...
Enlico's user avatar
  • 2,056
1 vote
1 answer
271 views

Asking for advice for fully committing to leader key keybinds

So, I recently tried switching my keybinds over to using the Leader key, which I've decided to make the space key, but that doesn't matter that much. I've adapted to it pretty much instantly and I ...
Andy3153's user avatar
-1 votes
1 answer
144 views

Vim is creating a .exe file when I run some C++ code. How do I save it to a specific directory?

I have some C++ source code that I am running. I have F9 and F10 mapped to the following in my vimrc file: autocmd filetype cpp nnoremap <F9> :w <bar> !g++ -std=c++14 % -o %:r -Wl,--stack,...
John Murthy's user avatar

1 2
3
4 5
30