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
0 votes
1 answer
15 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" ...
user avatar
1 vote
0 answers
10 views

How to change copy content of one register to another in vscode vim?

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 ...
user avatar
1 vote
0 answers
22 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 ...
user avatar
  • 111
3 votes
1 answer
64 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 ....
user avatar
1 vote
2 answers
21 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 ...
user avatar
  • 1,648
2 votes
1 answer
70 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.
user avatar
1 vote
1 answer
23 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 ...
user avatar
1 vote
0 answers
18 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 ...
user avatar
  • 1,648
1 vote
1 answer
53 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 ...
user avatar
-1 votes
1 answer
22 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,...
user avatar
1 vote
1 answer
35 views

Odd behaviour when pressing Tab with this mapping

I am trying to map ctrl+shift+i to insert an italics command in LaTeX files, and here's my attempt: autocmd BufNewFile,BufRead,BufWrite *.tex inoremap <buffer> <c-I> \textit{}^[i I am ...
user avatar
2 votes
1 answer
81 views

The right way of mapping 0, j, k, ^, $ to g0, gj, gk, g^, g$ when wrap is set

First, I'm not sure just mapping j to gj always is a good idea, because, for instance, I don't want j to behave as gj when wrap is off and the line is longer than the screen. How can I make 0, j, k, ^,...
user avatar
  • 1,648
3 votes
0 answers
47 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 ...
user avatar
-1 votes
0 answers
15 views

<C-m> not working after upgrading vim

I upgraded vim and neovim and now the key binding nmap <C-m> :NERDTreeToggle<CR> no longer works on nvim, but it does work on vim. My vim version is 8.2 and my nvim version is 0.8. I'm ...
user avatar
2 votes
1 answer
50 views

How to delete backwards till whitespace in Insert mode?

Hope you're doing well. Input: let firstDate = src[0][0]|.toString(); ^ cursor in Insert mode Desired output: let firstDate = |.toString(); ...
user avatar
  • 131
1 vote
0 answers
23 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&...
user avatar
1 vote
2 answers
56 views

Execute the line pipping its STDOUT to a new tab

I have a lot of plaintext documentation of many different programming languages I like to browse with vim. My documents look like w3m -dump https://nodejs.org/dist/latest-v16.x/docs/api/events.html ...
user avatar
0 votes
0 answers
36 views

Why is my vim key mapping not working?

The map noremap <silent> <C-i> :call CocActionAsync('doHover')<cr> doesnot work but doing same mapping for other key combination like <leader>h works. What might be the ...
user avatar
5 votes
1 answer
59 views

Yanking results displayed in status line

After pressing <C-g> in normal mode, prints useful information in the status line. How can I yank this text?
user avatar
0 votes
1 answer
36 views

How to map a sequence of vim commands to a shortcut?

I have the following sequence of vim commands I use to copy a function va{Vy, how can I map this to a shortcut key like F1? I'd also like to persist this.
user avatar
2 votes
0 answers
28 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 ...
user avatar
  • 133
1 vote
1 answer
33 views

Ctrl+Arrows work differently in normal mode and in insert mode

For some reason, in my VIM there is a difference in behaviour of Ctrl+Arrow keys in normal mode and in insert mode. To demonstrate this, I edit the file which contents are: aaa.aaa,aaa/aaa!aaa@aaa#aaa$...
user avatar
  • 21
2 votes
1 answer
26 views

Use leader key mapping in another mapping - not working

I'm trying to use a leader mapping in another mapping. But nothing happens when I attempt to use the second mapping. I'm quite sure I've done this before. What's going wrong? This mapping finds the ...
user avatar
  • 211
0 votes
1 answer
54 views

How can I close vim's parent terminal from within vim?

I am trying to close the terminal window directly from vim. The final purpose of this is to have a command (shortcut) that opens VSCode in the current directory from vim (when I need a GUI editor) and ...
user avatar
  • 101
0 votes
0 answers
17 views

Use inoremap in a more generalised way

I am creating shortcuts for editing LaTeX documents. I can add the following shortcut: inoremap ;b<Space> \begin{}<Enter><Enter>\end{}<Up> I would like a shortcut where I can ...
user avatar
0 votes
1 answer
52 views

How to remap <C-cc>?

I want to map to close quickfixlist, but when I do it will just send a message Type :qa and press <Enter> to exit vim. I just do this nnoremap <silent><C-cc> :cclose<CR>
user avatar
  • 149
2 votes
0 answers
48 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 ...
user avatar
  • 1,648
0 votes
1 answer
286 views

CTRL-SHIFT-P is not working on `neovim`

Below lines are part of my .vimrc. map <C-S-p> :CtrlPCmdPalette<CR> let g:ctrlp_cmdpalette_execute = 1 It's working fine on normal vim, but not working with neovim. My neovim init file ...
user avatar
  • 103
1 vote
3 answers
91 views

jump out of parenthesis, bracket, brace, quotes etc

Looking for simple and straightforward solution. I'd like to jump out of parenthesis, bracket, brace, quotes etc while typing in "insert" mode. Obviously following mapping settings in ~/....
user avatar
  • 13
1 vote
1 answer
35 views

Unexpected behavior in edited vimrc: dropped out of insert mode when hitting empty line

sorry for the bad title. I could not think of how to better summarise the problem. I should also state, that I am fairly new to vim, so please be a bit considerate :). I made the following changes in ...
user avatar
  • 13
1 vote
1 answer
34 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 ...
user avatar
  • 1,648
0 votes
1 answer
110 views

super key not working in neovim on linux

I'm trying to create a shortcut, but I can't get vim to recognize my super key. I tried the following combinations: lvim.keys.normal_mode["<A-h>"] = ":BufferLineCyclePrev<cr>...
user avatar
  • 525
0 votes
2 answers
15 views

How to get nnoremap <buffer> to work in different buffers?

I have a hotkey that runs python of the first buffer when I press F8 and outputs the outputs to the bottom. However, this hotkey does not work when I switch buffers... it only works when I am on the ...
user avatar
  • 25
-1 votes
1 answer
70 views

How can I port nmap, map, and imap commands to Lua configuration?

How can I port map commands in my vimrc file to Neovim lua configuration? For example: nmap <silent> <F2> <Plug>(lcn-rename)
user avatar
2 votes
1 answer
41 views

How can I make Tab insert tabs at the start of the line only, and spaces after text?

What I want to achieve I would like to setup vim such that tabs are inserted on lines until another character is inserted, after which, further tabulation results in spaces (similarly to expantab). ...
user avatar
  • 23
0 votes
0 answers
29 views

Getting/Setting Terminal Keycode in Win32 gVim

I wanted a binding for <C-;> to <End>, but it looks like that key either doesn't exist or does, but falls outside of the range of keycodes that Vim handles internally, or something. So, on ...
user avatar
  • 101
1 vote
1 answer
49 views

How to map `""` to `ysiw"` from surround.vim?

I would like to map "" to ysiw" from surround.vim to reduce number of keystrokes needed to surround a word with double quotes. I have tried :noremap "" ysiw", however it ...
user avatar
  • 1,133
0 votes
2 answers
31 views

Keybinding for EasyAlign interactive prompt is not working

I'm trying to use junegunn/vim-easy-align to vertically align some text. EasyAlign has an interactive-mode which means you can invoke EasyAlign, it prompts for a key, and then aligns around whatever ...
user avatar
0 votes
1 answer
38 views

How to make a mapping to scroll splits together for only one line at a time?

I know about :scrollbind, but I only want to move the splits together one line at a time. I think what I have tried explains what I am trying to do, although it doesn't work: " Scroll splits ...
user avatar
  • 105
1 vote
1 answer
33 views

How to change "n" behavior without losing the count like [4/15] in the statusbar

My goal is mapping n to nzz and keep the count on the status bar. Based on maparg reference from here, I have tried this: :exe 'nnoremap n nzz' . maparg('n', 'n') It actually adds zz, changing the ...
user avatar
0 votes
1 answer
24 views

alt dot to insert the last word of previous line

In bash shell, alt + . inserts the last argument of the previous command. and there are alt + (number) + . and alt + , variations. I like to do the same while editing shell script in vim, i.e. I want ...
user avatar
  • 160
1 vote
1 answer
41 views

Directly using keymapping inside a function

So, I'm usually used to making (decently) complex mapping, and sometimes, I'd like to run mapping on very specific conditions. Let's take for example a simple premise: first line second ... long text ...
user avatar
3 votes
1 answer
84 views

How to reserve a dd into a register, so I can yank it immediately even after a couple more dd's in between

dd puts the text I want to yank, in some register. Before a yank, a couple more dd's, now the first dd register has changed. How do I yank so that it's the first dd I want. I can't keep track of ...
user avatar
  • 145
1 vote
0 answers
32 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 ...
user avatar
  • 133
2 votes
1 answer
72 views

use comma as leader but keep comma's original functionality as <leader>, (i.e., two commas)

I use a comma as my leader key. I would like to be able to press the comma twice rapidly (i.e., <leader>,) to achieve the native functionality of the comma (i.e., jump back after f/F and ;). To ...
user avatar
4 votes
2 answers
194 views

Use CTRL key from the variable in map-<expr>

I have a variable with a "key" in vim notation, <C-j>. How can I use it in <expr> mapping? let g:key = "<C-j>" inoremap <expr> <C-j> '\' .. g:key &...
user avatar
  • 10.3k
0 votes
0 answers
20 views

How to prevent Esc+Home from jumping to line 3?

I have Linux boxes running a mix of Gentoo and Arch Linux with VIM version 8.2, and one CentOS box with VIM 7.4. When I use VIM in a GUI terminal most of them jump to the third line from the top of ...
user avatar
0 votes
1 answer
53 views

How to check key state Down/Up/Hold in Gvim?

A while ago, I saw this answer, and thought if this was possible in Gvim somehow. I'm only curious in knowing how to know the key state of a particular key, or at least the 3 main ones: Down, Up, and ...
user avatar
0 votes
0 answers
24 views

Vim doesn't respect inoremap bind in insert mode for windows wsl config

I have these two configs :nnoremap <F5> "=strftime("%F %r")<CR>P :inoremap <F5> <C-R>=strftime("%F %r")<CR> In normal mode f5 inserts date-time,...
user avatar
  • 145
2 votes
1 answer
27 views

Vimscript - Prevent Column From Moving When Using a Count

When you use a count to a key mapping it goes down count number of times and resets to column 1. Actually it already resets to col 1 when entering the function if there is a count. So I can save the ...
user avatar

1
2 3 4 5
27