Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
2answers
53 views

Is there any functional difference between special named keys in literal-string and in expr-quote?

I stumbled recently upon a mapping in the Vim Tips Wiki that uses an expr-quote: nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR> and realized it still worked ...
2
votes
1answer
41 views

How to get insert mode map to work regardless of completion popup?

I have an insert mode mapping which calls a function to select some text and leave vim in select mode. inoremap <silent> <C-J> <C-\><C-O>:call MyFunction()<CR> This ...
4
votes
2answers
150 views

How to make insert mode mapping count as multiple undos?

I have the following mappings: nnoremap # /___<CR>ciw imap # <Esc>:w<CR><Esc># And the following file that I am editing: foo ___ goo ___ hoo ___ The idea is that I start at ...
1
vote
0answers
51 views

How does vim receive f1-f4?

Literal terminal code of <f4> is: ^[OS result of set <f4> is: t_k4 <F4> ^[[14;*~ They are totally different, unlike results of f5-f12 (which are the same except the ...
3
votes
2answers
176 views

Show mappings for all function keys

How can I show the mappings for all function keys <F1> to <F12> at once? I know that :map <F1> shows the mapping for <F1>, and I can repeat this 12 times for each key. But is ...
0
votes
0answers
56 views

How can I make Vim NOT remove lines below with Ctrl and Left Arrow?

How can I make Vim not remove lines below with Ctrl and Left Arrow? So I just found a dangerous setting with Vim on Linux. If I press Ctrl and Left Arrow then whole rows below start vanishing. With ...
1
vote
1answer
51 views

Custom Number Format for CTRL+A

The ctrl+A command to increment numbers is super handy, but it doesn't work in languages that don't use C-style 0x and 0 prefixes for hexadecimal and octal numbers. In SystemVerilog, hexadecimal ...
1
vote
1answer
20 views

mapping <leader>; and <leader>, to ; and , respectively

My <leader> key is , and for convenience I'm using for a few years now the ; normal-mapped as a :, to save me a key stroke to type :commands. Now, I know that , and ; are shortcuts themselves, ...
1
vote
1answer
17 views

How do I make the current tab's windows equal width but leave their heights?

I know <C-w> = equalises window sizes but I often want to keep the heights as they are. I have set noequalalways in my .vimrc as leaving it on ruins layouts when temporary windows open (like ...
1
vote
1answer
22 views

Alert sound when using <C-L> etc. mappings

I've got these mappings in my .vimrc: nnoremap <C-Tab> :tabn<cr> " cycle tabs nnoremap <C-S-Tab> :tabp<cr> " cycle tabs backward nnoremap <C-J> <C-W><C-J&...
0
votes
2answers
36 views

Is it possible to perform the original action of a mapped key without knowing the key a priori?

Consider the following function and mapping. function! DoMagic() if s:isActive echom "Performing magic!" else " Perform default action of whatever key was mapped to this ...
1
vote
0answers
25 views

Is it possible to obtain the key that triggered a function to be called if there was one?

Consider the following function and mapping. function! GetInvoker() echom "I was invokeed by the key " echom <This_should_echo_F_or_G> endfunction map F :call GetInvoker()<CR> ...
0
votes
0answers
17 views

Mapping to have completion attempt one mode and fall back to another if no completions found

I am attempting to map ,<tab> in insert mode to first attempt omnicompletion then fall back to <c-p> or <c-x><c-p> completion. I have used this reference to successfully send ...
1
vote
0answers
13 views

Evim: Typing to delete and replace selected text instead reformats the current line if the letter typed is Q (vim-gtk, debian)

In the vim-gtk version of evim, selecting text and then beginning typing produces the normal WYSIWYG result of the first character typed deleting the selection and replacing it with that character (...
0
votes
1answer
37 views

Repeating mapped text in insert mode

I am making my life easier by mapping shortcuts to long DocBook XML structures in insert mode, for example map! <unique> <localleader>ct <callout arearefs="">> is there a way to ...
0
votes
2answers
32 views

How do I map a sequence of letters in insert mode?

After trying to make this work: Map a sequence of letters in insert mode I can’t get the correct answer to work. Is it still working? Can anyone post a working .vimrc file? I want to get this: When ...
1
vote
1answer
21 views

Single key/keyword to invoke code formatter across all extensions?

Is there a way to bind a single in visual mode, or a small word in ex mode that will invoke the code formatter for the active filetype? For example "ESC : fmt" or CTRL ALT F in visual mode, to invoke "...
1
vote
0answers
10 views

How can I remap the arrow buttons in insert mode when Pencil is enabled

I use vim to write text, and that’s why I often use it in combination with the Pencil plugin. The plugin creates significant delay in the movement of the cursor when in insert mode. I have tried to ...
0
votes
1answer
65 views

tab trigger not working for ultisnips

I have tried other solutions proposed of this question but still none of them worked. Related config: Plugin 'SirVer/ultisnips' " Optional: Plugin 'honza/vim-snippets' let g:...
2
votes
1answer
61 views

How to read a from a file while executing code

Related config: noremap <F5> :make<CR> noremap <F6> :!./%<<CR> noremap <F7> :!./%< 2>/dev/null<CR> The problem is while running the program with F6 when ...
2
votes
2answers
128 views

How to remap repeating commands i.e. <number><command>?

By default, vim lets you type 5G (5 then shift + g) to go to line 5. Instead, I don't want to have to press the shift key. Pressing <S-g> does something different than just 5<S-g>. How can ...
0
votes
1answer
40 views

Problem with conditional mapping <expr>

I am trying to reproduce this vimscript code function! NormalRemap() :nnoremap <silent> <nowait> I I :nnoremap <silent> <nowait> a a :nnoremap <silent> <...
1
vote
1answer
34 views

Moving to first letter in a line [duplicate]

I've got a line like this: * [ ] Find a way to efficiently move a task from one area to another #8ab879 I want to create a map that selects just "Find a way to efficiently move a task from one ...
1
vote
1answer
57 views

How to use filename expansion in a mapping

I have this shorcut in my vimrc that I use all the time (admittedly, I just copied it over from the web): " bind K to grep word under cursor nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:...
-1
votes
1answer
42 views

E73: tag stack empty while creating a map<leader>

When I append map <leader>tn :tabnew<CR> to my .vimrc and while tried to run this with :,tn command it says E73: tag stack empty.
2
votes
1answer
66 views

Cycle through autocomplete menu using tab

I am activating my autocomplete menu in vim using: inoremap <C-@> <C-n> and after it opened and only when it opened I would like to use the "tab" key to cycle through the menu. But when ...
2
votes
1answer
46 views

NERDTreeMenu Remapping

I'm a Colemak keyboard layout user and I recently started to learn and use Vim. I was able to map the arrow keys in the normal mode by putting custom mappings such as noremap u k in .vimrc (because ...
0
votes
0answers
25 views

How do I fix <DEL> behavior on macOS in VIM 8.1?

I've recently installed "huge" VIM 8.1 with Lua support (on macOS via MacPorts). This installation is side-by-side with my "normal" VIM 8.0 which lacks Lua support, so I have access to both versions. ...
1
vote
1answer
40 views

Send current vim line to seperate tmux pane and move cursor down

I am trying to send the vim line that is under the cursor to another tmux pane and then move the cursor on vim down 1 line. For context, I have vim open on 1 pane, and python open on another. I want ...
2
votes
2answers
194 views

Detect existing key binding before creating one

A plugin I've recently started maintaining currently checks to see if any bindings exist to its functions before creating the default ones. This makes it easy to setup custom bindings and not have to ...
3
votes
1answer
22 views

remap “undo key” to no op

I have a keyboard with an undo key right next to the esc key. I often miss esc, hit undo, which causes the vim process to be stopped. How can I remap the undo key in vim such that it doesn't do ...
1
vote
2answers
38 views

Switch order of three “words”

When writing code, I often have code of the form variableA operator variableB and I would like to edit it to be variableB operator variableA. Right now, I do this by deleting/pasting variableB to ...
0
votes
1answer
71 views

Mapping (omap) to erase inside any of (), {}, [], <> or their embeddings

I want to map an operator-pending key combination to erase contents of any embedded combination of (text), [more text], <other text> or {misc text} by placing my cursor inside and issuing the c+&...
0
votes
0answers
33 views

Automatically inserting predefined strings to terminal buffer

When I compile any code file in vim, I use a specific mapping to open the terminal buffer and get into insert mode, but this requires me to be aware of the (potentially long and complicated) file name....
2
votes
1answer
35 views

How not to use <Space> as a hit-enter key in command output pager

According to :h hit-enter, a message is shown when there is something on the screen to read and the screen is about to be redrawn. For example, - After executing an external command (e.g., ":!ls" and ...
0
votes
1answer
115 views

Integrating autocomplete and snippets

I'm trying to set up an autocompletion/snippet workflow that's a bit complicated. This is stemming from needing a better workflow for latex. Right now I'm using coc.nvim and UltiSnippets but I am ...
0
votes
0answers
27 views

In Vim, how to enable Meta in all keybindings?

In case it's relevant, this is on MacOS and iTerm. How do I use key mappings that involve the Meta key, e.g. <M-e>? For example, the auto-pairs plugin has a keybinding that allows you to ...
1
vote
2answers
95 views

neovim key remap specific to terminal buffer

I have been using nvim terminal mode to learn python and I want to have Ctrl-C break the python script from the terminal window even when I am not in insert mode. However, I also want Ctrl-C in my ...
3
votes
1answer
43 views

How to map Alt key with M J K L U I O to make a numpad?

I would like to have the keys M, J, K, L, U, I, O to be mapped to 0, 1, 2, 3, 4, 5, 6 (combine with the keys 7, 8, 9 already being on top of those keys) to be a total numpad when I hold a modifier key,...
0
votes
1answer
18 views

Indent text to beginning of line

Sometimes I'll have some text with an arbitrary indentation. Sample text. If I want to bring this text back to the beginning of the line, I'll visually select the line and then ...
0
votes
1answer
36 views

Cannot map Ctrl+ number (except 6 or ^)

I am using macvim 8.1, the map command is :inoremap <C-$> <End> I also tried <C-4>, no working. tried other number, can't work too (however CTRL-6 could work). Also tried ...
2
votes
1answer
142 views

Unmap “delete file” in Explore mode

I just accidentally deleted an important file in :Ex (I thought I was still typing a search string and hit Shift+D and then Enter immediately). Can I unmap this entirely to avoid this (stupid and not ...
0
votes
1answer
24 views

nnoremap conflicts with i_CTRL-O

I added two normal mode mappings so that the cursor doesn't move when changing case nnoremap gUiw m0gUiw`0 nnoremap guiw m0guiw`0 Recently I had to uppercase a word and I tried like this: ...
0
votes
1answer
26 views

Prevent abbreviations from echoing on the command line

If I want to map a key to a certain command and I don't want the command to echo in the command line, I can do the following: :nnoremap <silent> <leader>N <... command ...> But can ...
1
vote
0answers
32 views

Why is <C-S> not remappable? [duplicate]

The vim version on my Mac is 8.1.1000, installed by homebrew: VIM - Vi IMproved 8.1 (2018 May 18, compiled Mar 11 2019 08:36:53) macOS version Included patches: 1-1000 Compiled by Homebrew Huge ...
0
votes
2answers
23 views

Syntax of keys on keyboard in documentation

What is the meaning of <S-x> or <C-x> in the documentation? Example: http://vimdoc.sourceforge.net/htmldoc/motion.html#%3CS-Right%3E I often see people using <C-x> to refer to Ctrl-...
1
vote
1answer
25 views

maparg returns empty string, but the mapping is effective

I have a mapping set by a plugin that I want to unmap, which is the sequence "cop". The mapping is defined in unimpaired plugin: nnoremap cop <Nop>. If I do :map cop n cop * <Nop&...
2
votes
1answer
34 views

How to make mapping for any mark

I want to make a mapping that jumps to the file of a mark but on the last visited line. Ideally I would write something like this: nnoremap z<mark> '<mark>`" Where z is some command ...
1
vote
1answer
42 views

<Alt> to enter normal mode on Windows

I'm new to vim, and I find using <Esc> to enter normal mode to be slow. I'm on Windows. I seldom use the <Alt> keys (left and right) when I'm editing text. It should be convenient to use &...
1
vote
1answer
31 views

How to see the active mapping of hjkl

I basically have the same problem as described here. In my vimrc I have nnoremap <buffer> <silent> k gk nnoremap <buffer> <silent> j gj nnoremap <buffer> <silent> ...