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
3
votes
2answers
27 views

Ctrl-W at :terminal (default terminal behavior expected)

I am very found of Vim's :terminal, though whenever I use Ctrl-W expecting to erase the last typed word at prompt, Vim captures the key press and enters pane navigation mode. So I end up having to (...
1
vote
1answer
21 views

VIM 8.2 Backspace Delete behavior [duplicate]

I uninstalled vim 8.1 which is the available version through my package manager and installed 8.2 from source. But Backspace and Delete buttons behave in a different way in this version. If you are ...
2
votes
1answer
49 views

How to toggle syntax with a single key

To turn on syntax we normally use: :syntax on and to turn it off we do: :syntax off. I would like to define a single key, maybe using <expr> to toggle syntax. My problem is how to get the ...
1
vote
0answers
21 views

Save & recall favourite vim :commands

I often find myself using the up arrow at the vim command prompt : Is there a way to 'favourite' some? Or at least an easy way to search through previous commands? For example, I couldn't remember ...
2
votes
1answer
46 views

Is there a way to resize a split such that it exactly fits its content (plus/minus N lines of buffer-space.)

I often find myself doing something like this with a tiny header file with only a few lines: Ctrl-W, ^ Ctrl-W, j 50, Ctrl-W, - 50, Ctrl-W, - 30, Ctrl-W, - 10, Ctrl-W, - … or similar, to slowly "zero ...
0
votes
1answer
11 views

Map hex character

If I want the output 𐐀g, I can create a map like this: imap <F2> <C-V>U10400g However for output 𐐀f, it causes a problem: imap <F2> <C-V>U10400f as the f is confused as ...
1
vote
1answer
20 views

Why do mappings abort on errors?

According to this answer, if a error occurs during the execution of a mapping, its execution is aborted. Why is it like that and: 1) Is there a way to prevent this from happening? 2) In the case of ...
1
vote
1answer
23 views

Mapping behaves differently than manually typing

If ddkP is typed in normal mode on the first line then nothing happens¹. If :nnoremap + ddkP is executed and then + is pressed, the line is deleted. Why? ¹(if file only has one line then a new empty ...
2
votes
2answers
22 views

In command mode make delete not act like backspace

In command mode there is no delete from cursor to the end of line (like CTRL-k in bash). So to delete a long line of trailing text, I press and hold delete, which works fine until it runs out of ...
1
vote
1answer
51 views

Configuring CoC — open suggestion-box with shortcut only

I successfully installed CoC in my Vim to have some code-suggestions/completions while coding in Rust. It works fine, but I want make the suggestion-box only show up when I press a key-shortcut (E.g ...
1
vote
1answer
30 views

How can I auto-complete a few letters then navigate to a fixed location within them?

I was wondering whether to autocomplete e.g. jj to print('') and then navigate within those ticks: is it better to have a macro, or a remap, or neither? Obviously a remap doesn't allow moving after ...
1
vote
1answer
35 views

How to create ctrl map in command directly?

I'm trying to toggle some ctrl maps in command directly, it didn't work as expected: com Test0 nnoremap <c-j> :echo "c-j"<cr> com Test1 nnoremap <c-h> :echo "c-h"<cr> com ...
1
vote
1answer
43 views

Ctrl-A/Ctrl-X for numbers with a decimal number

I have numbers 0.655 1.455 1.21 How do I increment/decrement these numbers by their thousandths digit such that 901<c-a> produces: 1.556 2.356 2.111 I saw this question, which may be ...
0
votes
1answer
21 views

Bind makeprg to a shell command

I want to make something like this: let &makerpg = '[ -f Makefile] && make || cd build && [ -f Makefile ] && make || cd ../build && [ -f Makefile ] && make ...
1
vote
1answer
21 views

vimrc command not working - vmap <F9> :'<,'>s/</\&lt;/g | '<,'>s/>/\&gt;/g

I want to replace in highlighted text the angle brackets < and > with &lt; and &gt;. The following line in my .vimrc doesn't seem to work: vmap <F9> :'<,'>s/</\&lt;/g ...
0
votes
1answer
41 views

Automatic insert mode and normal mode switching

Coming from emacs, jumping to the end of the line is easy: CTRL + E I have been recently trying out Vim, and I found out you need to first exit insert mode to then use commands. So, in Vim, I need ...
1
vote
2answers
21 views

How to close the netrw buffer/window from any other window

I would like to have the behavior where I can run :Vex<CR> when pressing <Tab> in normal mode: nnoremap <Tab> :Vex<CR> ... to open the netrw file tree window and then I would ...
1
vote
0answers
44 views

Can't figure out where this mapping comes from

For more than a year, I have unmap <C-X> in my .vimrc because I can't figure out where this mapping comes from. I used verbose map <C-X> as suggested in another topic, it returns v &...
0
votes
1answer
15 views

<buffer> mapping after opening file from Netrw

I have a line in my vimrc that enables me to save and run python program in a single click while it's opened: nnoremap <buffer> <F9> :w <bar> :exec '!python3' shellescape(@%, 1)<...
1
vote
3answers
48 views

Create a mapping for a “smart” Home key

With other text editors, if you press Home, it first takes you to the indent, then all the way to the left. Is this possible with Vim?
2
votes
1answer
23 views

escape, ctrl-w through citrix lite in browser

I need to be able to run vi on a machine that I access through Citrix lite in the browser. However I've come across a number of problems because of conflicts around esc and ctrl+w. Specifically, ...
1
vote
1answer
33 views

Mapping Shift-Up & Shift-Down, mintty keycodes

I am trying to create some keybinds (in my .vimrc) for vim, used from Cygwin's mintty. I have found and extended some code for the .vimrc that translates the keycodes used by mintty (https://github....
2
votes
1answer
48 views

Why do arrow keys behave differently in insert mode than in other modes?

Background I would like to disable arrow keys in all modes. This is what I tried: "EDIT: added remap for <esc> as per the comments inoremap <esc> <nop> inoremap <up> <nop&...
0
votes
1answer
23 views

Ctrl w +/- not working as expected

I'm trying to use Ctrl w + and - to change my split width and height, but it's changing the font size instead. Any ideas about what's going wrong?
1
vote
0answers
49 views

Change behavior of `gx` key

I used to use chromium before and then, I could press gx on an url and vim would open it in a new tab if a chromium instance was already running, otherwise create a new window. But in firefox, when I ...
0
votes
1answer
83 views

search a pattern preceding cursor position, modify it and insert the modified string

I am writing a mapping to autocomplete tags Pattern: <.*?>, matches complete HTML tags only. The goal is to lookbehind and see if there exists a text like <html>. Mapping: inoremap <...
1
vote
1answer
26 views

Vim keymapping for “gdi” will not work if the cursor is over the definition of a variable, but works in normal mode?

I'm getting some really weird behavior when trying to write a simple keybinding in my vimrc. the following key map: nnoremap <F2> gdi only works if the cursor is not over the first declaration ...
2
votes
2answers
53 views

Compile LaTeX source file in the background without any plugin

I am new to Vim and I would like to make a key binding to compile my LaTeX source. I have the following autocmd FileType tex :nnoremap <buffer> <F5> :!pdflatex %<CR> which is ...
1
vote
1answer
41 views

Mapping sometimes works but sometimes not

What I tried: :nnoremap <C-w>n <Enter> Expected result: When pressing Ctrl+w then n, just an Enter is simulated rather than horizontally splitting a window. Actual result: The ...
0
votes
2answers
42 views

Unmap accented characters

If I press Alto, it prints ï. I would prefer it not do anything. I tried these: :unmap <M-o> :iunmap <M-o> but it just says: E31: No such mapping From the comments, I have also tried ...
1
vote
1answer
33 views

Why are split and tab navigations distinct?

Known: <Ctrl>w then any of hjkl. Known: :tab_<CR> where _ is either rlpn. Why is there not a <Ctrl> navigation for tabs nor a : for splits? Why do the navigation commands differ ...
3
votes
1answer
486 views

Non-vim user mode

When I'm working in vim and someone comes over to help/write some code into the editor and they don't know vim, they get totally stuck and we have to switch to a different editor. Does anyone know ...
2
votes
2answers
110 views

How do I make the h key go to prev tab if at start of file?

And, to get back again: how do I make the l key go to next tab, if at end of file? I'd also like to make hh go to previous buffer, and ll go to next buffer. I know that'll add a delay to recognising ...
2
votes
1answer
30 views

Edit NERDTree text using normal mode vim keybindings

When using the "Add Childnode", "Move Node", "Copy Node", etc. options through the "m" menu, it opens up a text field to type in the name of the destination file. Unfortunately, I cannot figure out ...
1
vote
2answers
36 views

Exit visual selection mode with different shortcut / hotkey

I was reading here Other ways to exit Insert mode besides Escape and in various other places. The problem I have is if I enter visual select mode I cannot use jj or kj to exit that mode, because kj ...
3
votes
1answer
86 views

Problem remapping key bindings in command line mode

To make it easier to edit my ~/.vimrc file, I set up the following: :cnoremap ev :<C-u>vsplit $MYVIMRC<cr> So, to open ~/.vimrc in a split I just enter command mode and enter ev. However,...
3
votes
1answer
35 views

keystroke to move to end of whitespace

I often want to select the whitespace on the line I'm editing to remove it. For instance I have a couple of lines that I want to bring onto one. Example: Starting with: var kernel = new ...
2
votes
1answer
39 views

How to have two different makefile mapped to two different keys?

I am using F5 to compile my programs From my .vimrc set makeprg=make\ -f\ ~/makefile\ %< noremap <F5> :make<CR> But I want to add one other way to compile my programs which compiles a ...
2
votes
1answer
343 views

nowait doesn't seem to work

Well, I have had these cases before. I sometimes did unmap, but I don't want to do this for every case. I define nnoremap <nowait> <leader>h :wincmd h<CR> But it does wait for ...
1
vote
2answers
43 views

explicitly call netrw function in binding

I'm trying to bind the key ^ so that it runs ^ in normal mode by default, but calls the function bound to - in netrw. - is bound to NetrwBrowseUpDir in netrw.vim, definition here . Here's my first ...
1
vote
2answers
51 views

Can I make left Alt act the same as shift key using key map?

I would like to swap my left shift key with my left alt key, and I would like to know if it’s possible to achieve this with vim key mapping. Maybe not swapping but copy the whole shift key map to ...
2
votes
1answer
54 views

Switching arrow key mappings for wildmenu tab completion

When wanting to edit another file, I'm a big fan of typing :e then tab (or a few characters before) to see the wildmenu pop up. Problem is that the way it works, arrows keys up and down go 'down' ...
2
votes
2answers
66 views

Do not delay mapped keys with common prefix

What I want to do is have two mappings. One mapped to <s-k>, and one mapped to <s-k><s-k>. What happens right now is that if I press <s-k> vim delays for timeoutlenms, and if ...
1
vote
2answers
39 views

How to start search `/` from a mapping?

I'm trying to do the following mapping in my vimrc: nnoremap <silent> / :call <SID>FooFunction()<CR><BAR>norm! / But when I press /, instead of running the function and then ...
2
votes
1answer
100 views

How can I use a plugin mapping in my own mapping?

I often repeat the following commands when I edit code: yy - yank the line gcc - comment out the line (so that I can visually see all the changes later) p - paste back the copied version what I will ...
2
votes
1answer
63 views

Change <up>/<down> to gk/gj in insert mode

I want to replace the default behavior of the arrows in insert mode, so that they behave like gk and gj, I have used: inoremap <up> <Esc>gka inoremap <down> <Esc>gja But this ...
1
vote
0answers
16 views

How can I :map a key to something containing spaces? [duplicate]

I want to :map <C-t> :some-ex-command with a space at the end so I can continue typing the command and execute it with enter. I cannot find the syntax for how to do this. I tried :map <C-t&...
3
votes
1answer
20 views

Use mapped shortcut without timeout

I have these in my .vimrc: set notimeout nnoremap <leader>n :set rnu!<CR> nnoremap <leader>h :<C-u>call Toggle_colorcolumn()<CR> <leader>n works instantly; <...
3
votes
2answers
531 views

Shortcut for going to the trailing curly brace “}”

Is there a shortcut for going to the trailing curly brace in a long piece of code? In a few editors if I double click the { it takes me to the trailing brace }. While writing large pieces of code I ...
0
votes
0answers
40 views

How to map commands to key release events

When I press and hold j or k, they are repeated by the OS interface (I presume). Vim seems to scroll on each character produced by the keyboard. This makes the scroll pause shortly right after holding ...

1
2 3 4 5
19