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
2answers
44 views

Completely expand `<plug>` mappings before execution into insert mode

Consider the following mappings: nmap <plug>test a123 nmap M <plug>test<plug>test If both <plug>test were expanded, vim would type out in the buffer "123a123". ...
0
votes
2answers
41 views

Reduce lag in mappings that frequently switch between normal and insert mode

As a concrete (although hyperbolic) example: nnoremap , a<esc>a<esc>a<esc>a<esc>a<esc>a<esc>a<esc>a<esc>a<esc>a<esc>a<esc>a<esc>...
0
votes
1answer
70 views

How can you create a vim mapping with a description

Context: I am using NeoVim on mac with a plugin called SpaceVim that I really like. SpaceVim basically loads a ton of mappings all mapped to the space bar. I also have added a ton of my own personal ...
3
votes
1answer
90 views

Inserting strings with `<plug>` inside `<cmd>`

When using <cmd>...<cr>, there are some special keys such as <plug> or <cmd> that are not allowed to be contained inside the block. Trying to execute the command will result in:...
1
vote
2answers
40 views

How to have a new keymap not block an existing one?

There is a built-in mapping Ctrl-g which presents the current filename immediately in the command area. I would like to augment this by tapping Ctrl-g again to copy the filename to my system clipboard ...
0
votes
0answers
13 views

Scroll mouse down triggers a mapping

Usually I know how to debug mapping. But I am not sure about this. When I do scroll down using the mouse, it enters insert mode and adds a line. I believe it is a bad mapping that is triggered (on ...
0
votes
0answers
42 views

How to keybind vim to a shell script

I'm new to vim and apologize if the question seems redundant, but I couldn't find a suitable answer. I have a shell script compile.sh that I would like to run each time I press some key (say, F8) on ...
0
votes
2answers
26 views

send key presses before previous command finishes

When running :browse oldfiles, if the output goes longer than one screen then you have to hit <space> for the next screen or <esc> to go to the menu where you can type the number of the ...
0
votes
0answers
30 views

Mapping ´ to / not working

I'm trying to map ´ to / and ¨ to ? as follows: nnoremap ´ / nnoremap ¨ ? It works fine if the first letter behind de map key is not any of i, I, a, A, o, O... guessing is something wrong with the ...
0
votes
1answer
33 views

Mapping won't work when cursor is at the last character of the buffer

I have the following mapping set in vimrc that saves the file and copy its content to clipboard: :map <F3> :w<CR>gg<S-V>G"*y It does what I want, except when I have the cursor ...
1
vote
1answer
46 views

Delete from cursor position until end of line in command-line mode

I am trying to emulate readline keybindings in insert and command-line modes (for example, <C-u> for deleting from cursor position to beginning of the line, or <C-w> to delete previous ...
1
vote
2answers
46 views

Tab to align cursor with next non-whitespace character in the line above (in insert mode)

How can we do this with vim? set hlsearch " Highlight search matches set incsearch " Highlight search matches as you type set visualbell ...
0
votes
1answer
29 views

force close windows and last empty buffer

when i open multi windows like bellow: vim foo.txt bar.txt then , if i'm closing foo.txt by :bw then ,i'm closing bar.txt by :bw vim still open ! , i must close by :q i don't want vim open if last ...
0
votes
1answer
18 views

Pseudo command :[line number][eof]d

How could I execute the entitled command, as is (I give a pseudo version)? My current workaround is to G to get the eof line number itself, then execute the command.
0
votes
1answer
29 views

Run another command if first command fails on keypress

Is it possible to combine the two commands map <F5> :w<CR>:exec '!python' shellescape(@%, 1)<CR> map <F6> :w<CR>:exec '!poetry run'<CR> so that when I press F5, it ...
0
votes
1answer
50 views

How to set a keybinding in Insert mode

I'm new to Vim, and I've read that a best practice in Vim is to begin a new Append with each line. In other words, instead of pressing <Enter>, it is more advisable to leave Insert mode, and ...
0
votes
1answer
27 views

Why does the cursor advance to the next character?

I have nnoremap Y y$ in my .vimrc. If I type "*y$, my cursor stays in the same spot on a word. However if I type, "*Y, the cursor is advanced one character. Why is that?
1
vote
0answers
49 views

Cricle through brackets mapping [closed]

I'm using bracket a lot and I'm trying to quickly circle through the bracket in both back and forth with the following mapping: nnoremap 0 f) nnoremap 9 F( Unfortunately, it does not work. Any ...
2
votes
2answers
89 views

Shortcut to exit insert mode and switch window?

While doing TDD I switch back and forth between windows often. I would like to reduce the number of keystrokes for this. I have tried both: inoremap <C-w> <ESC><C-w> and imap <C-...
0
votes
2answers
258 views

How to remap vim-commentary commands?

I have downloaded the vim-commentary plugin for commenting in vim. I was trying to remap the default shortcuts for the plugin so as to use ctrl+/ for commenting and remove commenting (default is gc). ...
0
votes
0answers
19 views

vim highlights the same occurence of a string and :nohl does not clear it

I have accidently pressed something and the string "#def" now always shows a white (as opposed to my regular dark) background: This occured while trying to comment out a function in python. ...
0
votes
1answer
42 views

Inconsistent behavior of dj and other motion-delete operations

I'm running Neovim 0.5.0 locally. I'm going through Harvard's CS50 course and they have an IDE (accessible here: https://ide.cs50.io/) with a shell that's running this version of Vim: version 8....
0
votes
1answer
39 views

Key mapping I don't understand

I'm learning key mappings, I know that: :imap <c-d> <esc>ddi means "If you are in 'insert' mode and press ctrl+d, it performs first <esc> like you have been pressed the esc key ...
1
vote
0answers
30 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 ...
1
vote
1answer
23 views

In command-line mode, how to avoid delete key erasing last character?

On command-line mode, Delete key erases next character, but if cursor is at end of line, it acts as Backspace, erasing previous character. Can I disabled that?
0
votes
1answer
19 views

Trigger complete keybind mapping using <C-O> when in Insert mode

I know that when I am in insert mode I can enter Normal mode for one command only and automatically switch back to insert mode using <C-O>. For example to go to the end of the line when in ...
1
vote
1answer
76 views

Weird arrow key behaviour in fzf.vim terminal mode

My .vimrc contains junegunn's implementation of Most Recently Used FZF search: nmap <Leader><Leader> :FZFMru<CR> command! FZFMru call fzf#run({ \ 'source': v:oldfiles, \ 'sink': ...
1
vote
1answer
25 views

How to move backwards between windows?

Ctrl-w w moves to next window. Ctrl-w p is not the symmetrical of Ctrl-w w, it moves to last window at first, but then moves back to where it was.
0
votes
0answers
32 views

Can I map a netrw command and its arguments to a key?

I have this map: nmap <buffer> <F3> mX So one I press <F3> it opens a prompt so I can type a command. Can I give the command also in the map above? something like: nmap <buffer&...
0
votes
1answer
28 views

What does <special> do in a mapping?

While reading the code of some plugins, I found the key <special> being used. Typing :h <special>, :h <Special> or :h <SPECIAL> yields nothing. I tried to search for it (/\c<...
0
votes
1answer
45 views

Bind :w to ASCII bell?

I'm using the Visual Studio Code Vim plugin to write my master's thesis. VS Code has an 'autosave' setting, which I have enabled, which means I don't need to use :w to save my files. However, I can't ...
0
votes
1answer
228 views

Mapping Leader to a Ctrl combination not working/being ignored in NeoVim mappings?

I'm trying to map my leader to <C-s> and local leader to <C-q>, in my NeoVim (0.5.0) init.lua file. I know Ctrl-S and Ctrl-Q are software flow control, and I mainly use the terminal ...
0
votes
0answers
27 views

Make keypresses stay in the bottom-right until the next action

Say I type ciw then it will show c then ci then blank. Is it possible to keep it there until I start a new sequence of commands? I'm assuming that since a lot of videos I see use an overlay logging ...
1
vote
0answers
21 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 ...
0
votes
0answers
23 views

Fixing a mapping action, such that it is not affected by future remappings of its keys

This is best explained with an example: Suppose I want to remap G to go to the end of the line, as I find that convenient. I also want to be able to jump to the end of the file, maybe by pressing gG. ...
0
votes
1answer
62 views

How to set up an execute-once mapping

Autocommands support the ++once modifier. I am trying to achieve the same effect for a map. Instead of coming up with a general solution I have been trying to solve my particular case via a side-...
0
votes
1answer
32 views

Assign value based on filetype [duplicate]

I want to assign value based on filetype. I am using UltiSnips plugin and want to have one set of bindings for one filetype and another set for everything else. Something like if &ft='vimwiki' ...
1
vote
2answers
90 views

How to apply alternating caps?

Fast way to type or change to AlTeRnAtInG CaPs?
0
votes
1answer
73 views

Calling a function before autocmd event is triggered

In my vimrc I have a key mapping for switching buffers that also automatically resizes the splits by calling a function: nnoremap <silent> <M-h> <c-w>h:call Splitresize()<CR> ...
0
votes
1answer
40 views

Execution of mapping

I'm using the Vim REPL plugin, and I'm trying to use a key mapping to call the command REPLToggle. The command is declared here. My key mapping is: nnoremap <leader>r :call repl#REPLToggle()<...
-1
votes
1answer
74 views

vimrc, like exec but replaces current process (fork?)

Such as in the following code: let cpath = getcwd() let cfile = expand('%') function Run_file_hopper(cpath, cfile) silent exec "! . ~/path/somescript.sh" a:cpath a:cfile ...
2
votes
1answer
55 views

Why doesn't my Normal mode mapping work when it follows 'd' (delete)?

I use d/ a lot, so I decided to map / as follows: :nnoremap <leader>j / (where <leader> is my space bar) To my surprise, d<leader>j doesn't work. Why is that? I expect it to behave ...
1
vote
0answers
26 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 ...
1
vote
1answer
144 views

Remap enter Terminal-normal mode Neovim to something else than Esc

I have remaped enter terminal normal-mode to <Esc> with: tnoremap <Esc> <C-\><C-n> and it does work. But I am using zsh vi-mode, which also requires the use of <Esc> to ...
1
vote
1answer
101 views

How can I give a keyboard shortcut (c-tab, c-s-tab) back to the terminal?

I am a long time user of git bash and its included vim and mintty. I updated from an older package including vim 8.1 to one with 8.2, and I have a new problem with just two mintty shortcuts. I haven't ...
1
vote
2answers
83 views

How to call a plugin in a mapping?

I'm doing a project-wise refactor and I want to change variable names from camelCase to snake_case. I have YCM and vim-abolish installed. Let's say I have the following source file: dueDate = ... ...
0
votes
1answer
73 views

Mapping jj to Escape doesn‘t work over SSH connection

When I connect to a remote server via iterm2 and SSH and use vim on this server remapping to the Escape key doesn't work. Other key mappings in the .vimrc work as expected but inoremap jj <Esc> ...
0
votes
0answers
20 views

Map a key in "search mode" [duplicate]

"Search mode" is not a true mode, but is it possible to create mappings that only apply while typing a search after / or ?? I am wondering how one would go about mapping <C-f> to start ...
0
votes
1answer
26 views

How to group all `cscope` related configuration into `augroup`, so it's only applied for C/C++ files?

How can I group all cscope (:cs) related configuration into e.g. autocmd, so that this configuration is only applied to c or cpp files? I have been looking at e.g. this, but it only address a single ...
0
votes
1answer
41 views

Map jk to Esc and Ctrl-A to select all but they don't work

That's my .vimrc set noerrorbells set tabstop=4 softtabstop=0 noexpandtab shiftwidth=4 set smartindent set number relativenumber set nowrap set noswapfile set hlsearch set smartcase set incsearch set ...

1
2
3 4 5
26