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
23 views

How can I create a shortcut that saves the file and executes a sequence of shell commands?

I know that I can create shortcuts on a vimrc file like the following: :map <C-W> :w<CR> However, let's say I have some different commands that I can execute on my shell: notify-send &...
0
votes
1answer
7 views

How can I leave completion mode keeping the completion result in a binding when there's no popup?

Currently: I have some key binding A → ^X^O (in insert mode) to omni-complete something I have some key binding B → ^Ogj to temporarily do something in normal mode (in this case, move down a display ...
0
votes
0answers
27 views

Mapping Esc makes vim open in REPLACE mode [duplicate]

I've enabled hlsearch to highlight text after searching, $ grep hlsearch ~/.vimrc set hlsearch and now I want to clear the highlight, which I can do with :noh. I saw that I can assign this to esc key ...
1
vote
1answer
37 views

To toggle statusline colors when switching modes. Problem with C-C

I use the following code to have different statusline colors for Normal and Insert modes: highlight statusLine ctermfg=black ctermbg=red guifg=red guibg=black autocmd ...
0
votes
1answer
36 views

Is there a way to navigate windows without CTRL-W + ... ie. from the command prompt?

I want to reclaim CTRL-W for closing my terminal tab to get the same behaviour as in Firefox and other programs. Is there a command I can run to avoid having to press CTRL-W to navigate windows in vim ...
0
votes
1answer
25 views

Dump output with command line in vim with placeholder

I use :enew|pu=execute('scriptnames') for dumping output into a buffer. How do I write a mapping with this command line? For example, I press <F6> and it auto write the command line and jump to ...
1
vote
2answers
43 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 ...
0
votes
2answers
30 views

Stop waiting for the rest of a normal mode command and accept the command typed so far

I have a mapping for m and a mapping for m/ in the same buffer, in Normal mode. If I type m, is there a way to tell Vim to stop waiting for the 2nd character, and to just submit the current command as-...
0
votes
1answer
19 views

Spaces in mappings: where to put them and where not?

The question is actually rather short, don't be afraid. :-) I'm Russian, and so to tweak Vim in a way it will understand its commands even if a Russian language is currently active, I have the ...
0
votes
2answers
38 views

how to make a word turn into certain commands in vim command line?

I want :cup in vim command line to turn into :tabdo call MapRunCmd()<CR> Hope that somebody can help me out PS: I've tried this nnoremap :cup :tabdo call MapRunCmd()<CR> but didn't like ...
2
votes
1answer
40 views

What is the purpose to use "==#" with empty string?

The following is from vim-sensible plugin: set incsearch " Use <C-L> to clear the highlighting of :set hlsearch. if maparg('<C-L>', 'n') ==# '' nnoremap <silent> <C-L> :...
0
votes
1answer
55 views

How to make a toggle function in .vimrc that toggles multiple configs of almost same type?

My .vimrc code autocmd FileType cpp nnoremap <F4> :RunWithFile autocmd FileType cpp nnoremap <F4> :RunWithFile ~/Downloads/ > output.txt && cat output.txt<s-left><s-...
0
votes
2answers
36 views

How to move `n` number char <left> in vim command line?

My init.vim code autocmd FileType cpp nnoremap <F4> :RunWithFile ~/Downloads/ > output.txt && cat output.txt I want my cursor position to be exact 31 times <left> in command ...
0
votes
1answer
39 views

Youcompleteme: shortcut key to format selection

According to this documentation :'<,'>YcmCompleter Format will format the selected text. I am struggling to map this to shortcut key <S-F2>. I have tried all of the following after having ...
0
votes
1answer
25 views

how to delete character which inserted automatically

I have the following mapping in my vimrc inoremap < <><left> but this statement conflicts with iabbrev cout cout<< and in insert mode I get cout<<>> how to delete &...
0
votes
1answer
26 views

How do I remap <c-x><c-k> to work with fzf.vim completion?

I'm trying to set up work completion with fzf.vim. Following the manual, I have: inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': ...
1
vote
2answers
36 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
37 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
52 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
67 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
39 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
35 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
1answer
33 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
22 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
15 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
27 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
48 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
78 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
134 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
17 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
37 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
28 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
25 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
1answer
53 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
24 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
27 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
43 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
77 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 ...

1
2 3 4 5
25