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
1answer
11 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
21 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
24 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
41 views

Cricle through brackets mapping

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
66 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
44 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
16 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
33 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
27 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
20 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
20 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
14 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
0answers
17 views

fzf.vim floating terminal buffer in vi-compatible 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
23 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
30 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
23 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
37 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
21 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
19 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
22 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
49 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
22 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
54 views

How to apply alternating caps?

Fast way to type or change to AlTeRnAtInG CaPs?
0
votes
1answer
37 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
33 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
65 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
49 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
21 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
43 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
46 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
44 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
64 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
19 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
24 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
28 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
1answer
15 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? ...
1
vote
2answers
50 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, ...
0
votes
1answer
23 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 ...
0
votes
1answer
71 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> ...
0
votes
0answers
40 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 ...
0
votes
1answer
40 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. :...
2
votes
1answer
52 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> ...
0
votes
0answers
11 views

Is there a way to use dvorak in both command mode and insert mode at the same time using keymap settings

I was trying to use dvorak with vim So I tried the normal keymap in the Edit settings, It works fine while in normal and insert mode But It goes back to qwerty when in command mode ( i.e. :command ) ...
1
vote
0answers
15 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 ...
0
votes
0answers
56 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 ...
0
votes
1answer
44 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 ...
1
vote
1answer
44 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
1answer
21 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
0answers
30 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 ...

1
2 3 4 5
25