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
2 answers
839 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). ...
  • 1
0 votes
1 answer
49 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
1 answer
84 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
0 answers
102 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
1 answer
26 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
1 answer
27 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 ...
  • 163
1 vote
1 answer
182 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
1 answer
41 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
0 answers
44 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&...
  • 165
0 votes
1 answer
29 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
1 answer
51 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 ...
  • 101
0 votes
1 answer
585 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 ...
  • 193
0 votes
0 answers
31 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 ...
  • 131
1 vote
0 answers
30 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
0 answers
24 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
1 answer
97 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-...
  • 1,163
0 votes
1 answer
47 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
2 answers
190 views

How to apply alternating caps?

Fast way to type or change to AlTeRnAtInG CaPs?
  • 391
0 votes
1 answer
166 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
1 answer
199 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()<...
  • 175
-1 votes
1 answer
83 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
1 answer
57 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
0 answers
28 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 ...
  • 279
2 votes
1 answer
667 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 ...
  • 21
2 votes
1 answer
189 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 ...
  • 23
1 vote
2 answers
150 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 = ... ...
  • 113
0 votes
1 answer
122 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> ...
  • 125
0 votes
0 answers
22 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 ...
  • 265
0 votes
1 answer
43 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 ...
  • 1,115
0 votes
1 answer
92 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 ...
0 votes
1 answer
31 views

"auto-complete" normal mode command?

Once I press g (or anything that enters operator pending mode), is there a way to see what keys could follow (e.g. gf, ga etc)? Alternatively, is there a way to search builtin + mapped keys by regex? ...
  • 335
1 vote
2 answers
119 views

How to prevent cnoremap taking effect for "/" searching?

I have created the following mapping for Ex mode to prevent having to enter :FZF capitalized to invoke FZF: cnoremap fzf FZF The problem is that this key mapping also affects "/" searching, ...
  • 1,115
0 votes
1 answer
92 views

Get path to parent directory and use it in a nnoremap command?

Say I have a nnoremap and I want to pass the path of parent directory of current file to it, so the command can use this information. I have read this answer: How can I see the full path of the ...
  • 951
0 votes
1 answer
797 views

Map to a key to do nothing?

I'm tuning :sp, :vsp things, and for example I have: nnoremap <nowait> <C-L> <C-W><C-L> nnoremap <nowait> <C-W><C-L> :vsp<CR><C-W><C-L> ...
  • 951
0 votes
0 answers
385 views

Creating shortcut for vim command

I created following shortcut for vim command in .vimrc: :nnoremap <Leader>1 :set foldexpr=getline(v:lnum)=~'^\\s*$'" But the shortcut doesn't work. The shortcut doesn't work if I change 1 ...
  • 131
0 votes
1 answer
53 views

Why does the cursor end up on the wrong line when <Esc><Esc> is mapped to something?

In vim --clean, I insert these lines: One Two Three Four Five Six Then I do: :set mouse=a :nnoremap <Esc><Esc> <Nop> (From my observations, the mapping could be to anything. :...
  • 891
2 votes
1 answer
148 views

Function keys and <Home>, <PageUp> etc are dead in neovim TUI

I decided to give neovim a try and things mostly work with my vim8 configuration. However, function keys are dead in the text user interface (ok in nvim-qt), i.e. with :map <F1> iFoo!<esc> ...
  • 353
1 vote
0 answers
30 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 ...
  • 219
0 votes
0 answers
237 views

Map left command key to left control key in terminal only?

I've asked this question over on AskDifferent without any luck. I'm using neovim to edit code and am needing to create a mapping to bind to <cmd-w> to <C-w>. How would I go about this on ...
  • 101
0 votes
1 answer
97 views

What is the <80><f5>X keycode?

I created the following mapping. vmap <leftmouse> <cmd>echom getchar()<cr> I then enter visual mode, switch to select mode by pressing <c-g>, and then drag the mouse. After ...
  • 462
1 vote
1 answer
55 views

What exactly Ctrl + Shift + Right arrow does? How can I remap it or find help on this key combination?

I've noticed that pressing Ctrl+ Shift+ Right deletes text until some criteria are met but I can't figure out exactly what that is. I'm also unsure how to find help when a character doesn't have a ...
0 votes
1 answer
23 views

Map a custom command so as to be able to execute it n times

I am using this mapping: " Class: transform init arg to variable assignment " <Esc> is input as Ctrl + v <Esc> and shows as ^[ nnoremap » :norm 0wiself.<Esc>w"byiwEDa =...
1 vote
0 answers
35 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 ...
  • 11
1 vote
1 answer
594 views

VIM: How to call a vimscript function after press a shortcut or execute a command?

I want to know how to call a function after a normal or Ex command. Examples: bind a function to search command. When I input /xxxx to search xxxx, also call the function. press * to highlight ...
0 votes
1 answer
138 views

How to jump to specific line of a file when file path and line number is given?

I have a filename and its line provided in this format, e.g.: ./my_dir/my_filename.py:20: When I move on the filename and press gf I jump to that file, however the cursor stands on line number 1, ...
  • 1,265
1 vote
1 answer
206 views

How do I enable mouse in netrw only (terminal vim)?

I would like to be able to use my mouse to scroll and click on directories to expand them in netrw. I don't want the mouse to be on for any other filetype/buffertype, so that I can still highlight/...
  • 131
1 vote
1 answer
46 views

How to map UTF-8 symbols to numbers in command-line mode?

Sometimes I change input source (keyboard language) and my number buttons get mapped to rarely used UTF-8 symbols, e.g. 1 gets changed to ą, 2 to č, 3 to ę, etc. I have managed to map them in normal ...
  • 1,265
0 votes
2 answers
136 views

Mapping with motion ip

I'm trying to create my own mapping with motion in Vim after reading this stackexchange question. I'm using the plugin vimtux to send code to specific tmux instances and I now want to be able to do ...
  • 3
2 votes
2 answers
79 views

Sending two keys in series during autocompletion confirmation

I have the following mapping: inoremap <expr><CR> pumvisible() && complete_info().selected != -1? "\<C-y>" : "\<CR>" inoremap <expr><Space&...
  • 153
0 votes
1 answer
3k views

Neovim: Select an autocomplete option with <tab> instead of <return>

In the example below, how do I use <tab> to select HttpResponse the item instead of <enter>? I'd like to make this change permanent. This is using Kite within vim in case it matters.

1
3 4
5
6 7
29