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.

162 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
0 answers
226 views

Issue when moving Vim9script plugin's functions to autoload

I've read :help write-plugin to understand a bit more about how to write a plugin in Vim9script, but there aspects of that that puzzle me. Here's a very simplified, working version of the example ...
Enlico's user avatar
  • 2,184
5 votes
0 answers
3k views

Unable to map ctrl-l

My _vimrc contains the following lines: set nocompatible source $VIMRUNTIME/vimrc_example.vim source $VIMRUNTIME/mswin.vim behave mswin nmap <c-l> :w<CR> nmap <c-m> :w<CR> ...
Gqqnbig's user avatar
  • 151
5 votes
0 answers
321 views

Remapping home row keys hjkl when using repmo plugin

I am new to Vim and I am trying to remap the four (arrow) navigation keys hjkl one step to the right on the keyboard to get j down k up l left ; right I am following the recommendations given in ...
Håkon Hægland's user avatar
5 votes
0 answers
583 views

Is it possible to remap the character following CTRL+R in INSERT mode?

While in INSERT mode, I'd like to make <c-r>* behave as <c-r>+. Is that possible? I tried both of the following, but no luck: inoremap <c-r>* <c-r>+ onoremap * + Is it ...
trusktr's user avatar
  • 231
4 votes
0 answers
235 views

Mapping that works in Vim does not work in Neovim

I use Tim Pope's plugin vim-unimpaired, and one of the shortcuts that it enables is "bubbling" text (moving a line or a set of lines up/down). In normal mode, the shortcut for bubbling text ...
Michael P. Geraci's user avatar
4 votes
0 answers
1k views

iTerm2 and VI key mappings

I am trying to use a few keys and key combinations with VI (VIM - Vi IMproved 8.2) running in iTerm2 3.4.15 with zsh on macOS Monterey 12.1 on the Apple M1 Max chip. So far, I tried to set ...
slybloty's user avatar
  • 143
3 votes
0 answers
154 views

How to remap deleting a word in insert mode?

My terminal emulator in which I use vim is alacritty, and I want the key combination control + backspace to do the same that control + w does when in insert mode (i.e. delete the entire last word). So ...
Richard's user avatar
  • 155
3 votes
0 answers
261 views

Why do <S-Left> and some other keys not work in vim under tmux?

I know at least about <S-Left>, <S-Right>, <C-Left>, <C-Rigth>. But I guess there are others. I'm mostly interested in the why. Because knowing a reason often makes finding a ...
x-yuri's user avatar
  • 349
3 votes
0 answers
165 views

Function keys: won't work with macros (I tried a lot)

Specs: Vim 8.0 patch 500 gnome-terminal 3.18.3 on Ubuntu 16.04 running Unity Function keys in my vim slightly misbehave, however, in an annoying way: I can't completely use them in my macros. After ...
simlei's user avatar
  • 113
3 votes
0 answers
247 views

^O (Ctrl+O) works slowly

In my system, <C-o> works really slowly compared to <C-i> or <C-p>. Is it just my experience or is there a subtle reason behind it? Is this in any way related to ttimeoutlen? I saw ...
Cyriac Antony's user avatar
3 votes
1 answer
2k views

Make YouCompleteMe open definition in vertical split even if buffer is not saved

There is something I cannot do with YouCompleteMe that I could do when just using tags to navigate to a definition or declaration. The desired behaviour is (taking into account that , is my leader ...
user2891462's user avatar
3 votes
0 answers
629 views

Using text objects with IJKL navigation keys

Like many people, I prefer a triangular or inverse-T navigation key format like IJKL instead of HJKL for ergonomic reasons. There's a pretty simple way to set this up in vim that I've used for years: ...
Kyle Barbour's user avatar
2 votes
1 answer
54 views

Behaviour of Neovim when in insert mode is different from expected

I recently switched from vim to neovim. I have the following keybindings in neovim: vim.keymap.set("i", "0", "<Esc>la", { noremap = true }) vim.keymap.set("i&...
caffeinemachine's user avatar
2 votes
0 answers
32 views

Consecutive pressing mapped function keys emits unwanted "^[[I" in input buffer in Ubuntu 22.04

OS: Ubuntu 22.04.2 (ubuntu-22.04.2-desktop-amd64.iso) Vim: vim-gtk3 (8.2.3995-1ubuntu2.7 amd64) vimrc: nnoremap <F7> : ! g++ % -o %< <CR> nnoremap <F8> : ! time ./%< <CR> ...
fstqwq's user avatar
  • 21
2 votes
0 answers
182 views

CTRL-^ work in Vim but not in Neovim

I'm reading Neovim's usr_07.txt. When I start Neovim like neovim t1.txt t2.txt t3.txt, and then issue :next, the shortcut CTRL+^ is supposed to bring me to the previous file (i.e., the alternate file)....
robertspierre's user avatar
2 votes
1 answer
1k views

Why don’t these mappings to enter Terminal-normal mode work?

I have remapped "enter terminal normal-mode" to <Esc> with: tnoremap <Esc> <C-\><C-n> and it works. I also use zsh vi-mode, which requires <Esc> to enter normal ...
flbk's user avatar
  • 21
2 votes
0 answers
139 views

Conditional mapping for two plugins (UltiSnips and Vimwiki)

Vimwiki table default mappings include <tab> for moving to the next table column in insert mode. Also UltiSnips default mappings include <tab> for expanding snippets in insert mode. Here ...
mahbubweb's user avatar
  • 602
2 votes
1 answer
275 views

Cannot remap Control Backspace and Control Shift Z in Windows

What's up with Control Backspace, and Control Shift Z for the Windows cmd terminal? I cannot seem to remap them. All the former does in Insert Mode is type Î, and then make the "z" letter ...
Unknow0059's user avatar
2 votes
0 answers
82 views

How to delete the previous buffer when loading new result from quick-fix window?

In the quick-fix window, if I'm loading new results, the previous buffers stay which I don't want. I want only those buffers to stay which I open intentionally (e.g. to write new code, do diff of ...
Haris Muzaffar's user avatar
2 votes
0 answers
58 views

How to get this tab/autocompletion setup?

Basically what I want is a PyCharm-like completion: If there is only whitespace, insert <TAB>. If pum is visible and nothing is selected, complete with first, otherwise choose the selected word/...
chom's user avatar
  • 21
2 votes
0 answers
90 views

How do I delete a block a text using the mouse cursor?

Yes, I know this is unconventional, but I just want to know. When I right click on a chunk of higlighted text, the dropdown doesn't show any option for deleting - just copy, copy as html...show ...
nz_21's user avatar
  • 121
2 votes
0 answers
173 views

Why are the vim line wise movement commands inconsistent?

While browsing index.txt looking for space to fit some custom keymappings, I noticed something. ^ - First CHAR of current line N- - First CHAR N lines higher N_ - First CHAR N-1 lines ...
aktivb's user avatar
  • 133
2 votes
1 answer
377 views

<s-f10> cannot be mapped in neovim

At least not on my mac. it works fine in vim. is this simply an error in nvim?
Toothrot's user avatar
  • 3,119
2 votes
0 answers
23 views

greek_polytonic keymap file not working

Is anyone using this keymap file with success? https://github.com/vim-scripts/greek_polytonic.vim I get only Latin output after following the instructions.
Toothrot's user avatar
  • 3,119
1 vote
1 answer
30 views

Vim keybinding case-insensitive

I would like to have a key bindings on <C-l> and on <C-L>. But it seems that Vim is case-insensitive regarding this. For example, if I have a Vim script like this: imap <C-l> <C-W&...
john's user avatar
  • 58
1 vote
0 answers
33 views

How to prevent cursor shift when using `<cmd>` (like `<c-\><c-o>`)?

I currently have inoremap <M-j> <C-\><C-o>gj in my config but I would like to avoid triggering all InsertLeave autocommand when doing this. inoremap <M-j> <cmd>normal! gj&...
0x539's user avatar
  • 197
1 vote
1 answer
408 views

vim.keymap.set issue

I've tried to make a key map as follows: vim.keymap.set('x', '<leader>n', function() -- Here <leader> is <Space> line1r, line1c = unpack(vim.api.nvim_buf_get_mark(0, "<&...
HRC's user avatar
  • 21
1 vote
0 answers
31 views

How to programmatically input a motion in operator-pending mode without switching to normal mode?

I need to programmatically input a motion in operation-pending mode, kinda like using :normal!, but without switching modes, so the operator still takes effect. Context I'm writing a script that ...
Tae's user avatar
  • 2,115
1 vote
0 answers
102 views

How to load method definition in a popup?

This is a followup to this question, where I would like to load the method definition in a pop-up rather than a split screen (or the whole screen for that matter). Attempt 1: using nui.vim I’m using ...
abbood's user avatar
  • 713
1 vote
1 answer
47 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 ...
minseong's user avatar
  • 2,303
1 vote
0 answers
36 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,412
1 vote
1 answer
777 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
1 vote
0 answers
33 views

Is there a way to map remap 0<C-d> in insert mode

I'm doing a plugin which modify how shift works and remap <C-d> in insert mode. Every thing works well but I have a problem with 0<C-d>. It is a built-in mapping which reset the ...
mb14's user avatar
  • 156
1 vote
0 answers
158 views

Is there a way to map the uppercase Z key alone?

I was trying to map the Z and X keys like this: nnoremap Z v"-yjv"-pkv"-pj nnoremap X v"-ykv"-pjv"-pk But, of course, the Z mapping didn't work because Z is a key that ...
Alvaro9366's user avatar
1 vote
2 answers
156 views

Change level of manual fold?

How do you increase or decrease the level of the current, manual fold? And what is the keyboard shortcut to do it? I cannot see anything in the manual about this. Foldlevel seems to concern not the ...
markling's user avatar
  • 349
1 vote
0 answers
281 views

`gx` on visual selection in keymap in NeoVim

I would like to map gp to open the file name inside the current set of parentheses. I have: vim.api.nvim_set_keymap('n', 'gp', 'vi(gx', {noremap=true}) However, this just selects the text inside ...
samuelstevens's user avatar
1 vote
0 answers
306 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
1 vote
0 answers
978 views

How do I cycle through autocomplete items with tab while also filling in the current selection in buffer?

I have the following in my init.vim "If PUM (complete menu) is visible, then execute <C-y> (which selects an item), otherwise, do a normal tab inoremap <silent><expr> <TAB&...
Jay Pillai's user avatar
1 vote
1 answer
570 views

Special characters, escaped special characters, escape sequences, and terminal codes

I refer to those 4 terms using terminology picked up by various sources: Steve Losh, in his Learn Vimscript the Hard Way's chapter 16 refers to things like <cr> (these 4 characters typed in a ...
Enlico's user avatar
  • 2,184
1 vote
0 answers
45 views

How do I make <leader>keys do nothing if they aren't mapped?

Right now by default, when I do <leader>keys, if keys is not mapped to anything it will run those keys as if I did not map them (i.e, doing <leader>o would just do o if I don't map it to ...
joshpetit's user avatar
  • 133
1 vote
0 answers
2k views

How do I map <C-,> and <C-.> in neovim?

How do I use <C-,> and <C-.> to switch between multiple tabs?
YunYaJun's user avatar
1 vote
4 answers
2k views

Toggle Vim Terminal with Mapping like VS Code

I am trying to implement toggling of the Vim terminal like VS Code by doing <C-~>. But am not sure how to go about it. I find executing :term to open and to close tedious. I figured having a ...
TheGreatZab's user avatar
1 vote
0 answers
121 views

Trouble remapping netrw

I'm using a bépo keyboard, kind of like a dvorak keyboard but for french. One of the most important aspect of using a bépo layout with vim is that I have to hjkl <-> ctsr. To do so I have this ...
BluePyro's user avatar
1 vote
2 answers
124 views

jedi-vim prevents mapping [[ to * and ]] to #

jedi-vim appears to prevent mapping [[ to # and ]] to * mapping does not alter behaviour produced by [[ or ]] in .py files when jedi-vim in bundle folder (and does alter behaviour in .py files ...
Surprised's user avatar
1 vote
0 answers
353 views

Mac + vim : character ASCII 160 instead 32 as space

This is a problem that is making me crazy so any help is welcomed :-) That happens to me mainly when typing scripts with Vim in Mac but I think I got the problem somethimes when typing some commands ...
islegmar's user avatar
1 vote
0 answers
31 views

cannot run `:normal s<CR>` just for nerdtree (opens file vertically splitted)

what im trying to achieve: use <C-V> to paste text in normal mode in current buffer use same <C-V> to vertically split a file from nerdtree what i know: when you are with your cursor in ...
alexzander's user avatar
1 vote
0 answers
33 views

IM's keyboard shortcut is ignored only in vim

I'm Japanese so I'm using IM. In my IM settings, Ctrl+Backspace is assigned to the "undo the last conversion" functionality. This shortcut usually works on normal programs (e.g. on Mozilla ...
ynn's user avatar
  • 279
1 vote
0 answers
39 views

Can I use Mac keybindings in insert mode?

I use Vim on a Mac book, and I am wondering if it is possible for me to use Mac keybindings when I am in insert mode. For example, option + delete to remove the word before the cursor, command + ← to ...
zyy's user avatar
  • 239
1 vote
0 answers
43 views

Any ideas on how to jump back and forth between a file and its corresponding unit test?

Here's an example of a typical project structure for me: components/a.js components/common/b.js tests/unit/components/a.test.js tests/unit/components/common/b.test.js Notice that inside the /unit ...
jose's user avatar
  • 11
1 vote
0 answers
54 views

Can't remap to <C-)>

I'm using a French keyboard, and <C-]> to access to a tag definition is cumbersome. You need AltGr+] to access the ] character, so the whole thing is 3 keys pressed at the same time: Ctrl+AltGr+]...
liberforce's user avatar