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
11 votes
1 answer
398 views

Why does `<Bar>` behave like `|` in the `:command` command in Vim?

Here is the list of experiments I performed that shows that <Bar> is treated as literal <Bar> in some commands but it is treated as | in the :command command. I am trying to understand why ...
Lone Learner's user avatar
10 votes
2 answers
326 views

Context sensitive insert mode mapping or abbreviation

I'm planning to implement some utility mappings for my LaTeX plugin to simplify typing of mathematics. For instance, I want to create abbreviations similar to `a : \alpha `b : \beta -> : \to => ...
Karl Yngve Lervåg's user avatar
9 votes
3 answers
3k views

Why do I get a missing quote error when using the following in a mapping using execute and normal?

The command is nnoremap <leader>; :execute "normal! mqA;\<esc>`q" If you then press <leader>;, you will E114: Missing quote: "normal! mqA;\ followed by E15: Invalid expression: "...
Alice Ryhl's user avatar
9 votes
1 answer
17k views

How to enter tilde (~), back tick (`) and special chars with a non-US keyboard?

I usually use Vim with an Italian keyboard (I'm from Italy), (mainly in an Ubuntu Linux Virtualbox guest from a Windows host). I have problems when I have to enter some frequently used characters (...
Giorgio Robino's user avatar
9 votes
1 answer
479 views

Ctrl-A and Ctrl-X seemed to be switched sometimes!

Occasionally, I will press Ctrl-x and Ctrl-a to increment/decrement the highlighted number, and the opposite operation will happen. This usually happens when I'm working with with registers (q). ...
user1717828's user avatar
9 votes
2 answers
709 views

How can I create a pseudo insert mode with a different keymap?

I am in the slightly unusual position of using two different keyboard layouts on a regular basis (Programmers-Dvorak and Turkish-F). These layouts are quite different from each-other and I am only ...
Caleb's user avatar
  • 2,235
9 votes
1 answer
664 views

Is it possible to execute a :normal command ignoring user-defined maps?

Let us suppose that a user maps - to <nop>. How can I, as a script writer, execute a :normal command that correctly uses the default behaviour of -?
ninrod's user avatar
  • 219
8 votes
1 answer
3k views

Percent key ( % ) matching behavior for angle brackets ( < > )

In vi it's very helpful to be able to place the cursor on a '(' or '{' or '[' character, press the '%' key, and move to the matching ')', '}', or ']'. But this does not work for me with angle ...
Clovis_Sangrail's user avatar
8 votes
1 answer
256 views

Why is the previously inserted text reset after using an arrow key?

From help :help i_ctrl-a: CTRL-A Insert previously inserted text. {not in Vi} Let's say I have an empty buffer and I'm in normal mode. I type i to go in insert mode. I type (), then move the ...
saginaw's user avatar
  • 6,706
7 votes
1 answer
1k views

How can I prevent plugins from overwriting my key mappings?

In my vimrc I have: nnoremap <F4> :SyntasticToggleMode<CR> And this works. But I also have the unicode.vim plugin installed, which overrides this mapping: if !hasmapto('<Plug>(...
Martin Tournoij's user avatar
7 votes
1 answer
998 views

why can't I map <Space> to <C>?

I found that it's really hard for me to hit Control and other keys simultaneously, and I discovered that the space key is rarely used, so I decided to map it to Control . Thus, when I want to hit ...
Alex's user avatar
  • 1,175
7 votes
1 answer
592 views

Create mappings/macros with keydown?

Is it possible to create mappings or macros based on keydown and keyup events? For example, if you press i you enter insert mode, and if you press esc you leave insert mode and enter normal mode. ...
Tyler Durden's user avatar
  • 2,083
7 votes
4 answers
1k views

Prevent the cursor from moving to the start of the yanked text?

Vim help's change.txt states that Note that after a characterwise yank command, Vim leaves the cursor on the first yanked character that is closest to the start of the buffer. This means that "...
Vitor Eiji's user avatar
7 votes
2 answers
4k views

How to remap "i" in netrw?

I remapped my hjkl keys to ijkl, but in netrw, "i" switches view styles. How to change this? Is it possible to change this?
Peret Finctor's user avatar
7 votes
1 answer
2k views

Mapping Ctrl-Z in insert mode?

I often Ctrl-Z to the command line. Is there a way to do that in response to hitting Ctrl-Z in insert mode? The iabbrev command does not seem to work.
Yossi Gil's user avatar
  • 755
6 votes
1 answer
2k 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 ...
Silence and I's user avatar
6 votes
2 answers
624 views

Sticky shift - or getting <shift> with letter combinations

I use the shift keys a lot and it is an unnecessary strain on the pinky. The enter and backspace functionalities are conveniently located under a dominant finger (ctrl-m and ctrl-h). Similarly: Is ...
Emre's user avatar
  • 217
6 votes
2 answers
5k views

What is the difference between unmap and mapping to <Nop>?

My version is : NVIM v0.3.0-dev I'm trying to replace mappings with w mappings. Initially I came up with nnoremap <leader>w <c-w> nnoremap <leader>wb <c-w>s nnoremap <...
3N4N's user avatar
  • 5,544
6 votes
1 answer
2k views

Pressing Shift-Backspace in insert mode types '^?' instead of backspacing

When I mess up typing an uppercase letter, I usually hold Shift while pressing the Backspace. Instead of backspacing, it types ^? (to my frustration). Google tells me that ^? is the "delete" ...
PoorProgrammer's user avatar
6 votes
1 answer
3k views

How to use <Leader> in a normal command?

In the command-line mode or in a vimscript I can use the following to duplicate a line: normal! Yp Now let's says that I map my leader key to do that: nnoremap <Leader>a Yp. If I use this key ...
statox's user avatar
  • 49.4k
6 votes
1 answer
220 views

Swap two keys in such a way that works with both `f` and macros

I have swapped my number keys with their symbols, because the symbols occur much more frequently than numbers in many programming languages, like C or Haskell. You can see my key-swap function in my ....
Shahbaz's user avatar
  • 549
6 votes
1 answer
401 views

How to move the cursor to the next reference, option, heading in man pages?

If we load the built-in man.vim filetype plugin by writing in our vimrc: runtime ftplugin/man.vim We can read a man page inside a Vim buffer, using the :Man command described in :h :Man: MAN ...
user9433424's user avatar
  • 6,118
6 votes
1 answer
752 views

Insert a newline after punctuations

I'm writing a report in LaTeX that I keep in a Git repository. In order to make the most out of Git, I would like to keep each sentence on its own line. I.e. for each dot, exclamation mark and ...
lklun's user avatar
  • 63
6 votes
1 answer
2k views

Map 'Jump to mark line' to 'Jump to mark position'

Let's say I've set a mark a via ma. Then 'a will bring me to the first non whitespace character of the line. However `a will bring me to the exact position of the mark a. I prefer the second ...
user avatar
5 votes
1 answer
3k views

How can I map Alt-< or Alt->?

I try to create a mapping for Alt < and Alt >: inoremap <M-<> foo-bar-baz inoremap <M->> baz-bar-foo This doesn't work, most probably because < and > are themselves ...
René Nyffenegger's user avatar
5 votes
1 answer
87 views

Yanking results displayed in status line

After pressing <C-g> in normal mode, prints useful information in the status line. How can I yank this text?
Zach Wiebesiek's user avatar
5 votes
5 answers
1k views

Delete text between two $ symbols in gvim

I understand that we can use da{ to delete a whole {} block in vim. I am wondering if there is a corresponding version with { replaced by $ (similarly for di{) as this would be very useful for people ...
weirdo's user avatar
  • 153
5 votes
1 answer
1k views

Visual block editing: map i

How to map i to start editing on visual block mode? I want the same behavior for <shift>-i and i.
adelarsq's user avatar
  • 594
5 votes
2 answers
2k views

How to add accent to letters in normal mode?

I want to edit words that need accents (á) were they are missing. It's no problem to write down accents in insert mode: it is just "' + letter", so I can easily write á, é, í, ó, ú. How do get ...
nilon's user avatar
  • 217
5 votes
1 answer
309 views

Changing -- INSERT (lang) --

When keymap is set and iminsert is 1, it says -- INSERT (lang) -- at the bottom of the screen. Is there an easy way to change this string (or just the lang string)?
Toothrot's user avatar
  • 3,119
5 votes
1 answer
819 views

Understanding :help set-termcap

I would like to define some mappings involving key combinations like <S-F1> or <A-d>. For example something like this: nnoremap <A-d> :echo "hello world!"<cr> However, on my ...
saginaw's user avatar
  • 6,706
4 votes
2 answers
2k views

How to add a [count] to a binding

How do you create a binding that behaves like yy but doesn't yank the leading white spaces? nnoremap <leader>f ^v$y Yanks one line and the ^J. Which is what I want but how do I add a [count] ...
nunmap's user avatar
  • 55
4 votes
0 answers
448 views

How to remap <C-[> on linux [duplicate]

I have the same vimrc file for both Windows and Ubuntu environments. It works fine on both platforms, except for one difference. The line: nmap <C-[> <C-t> is working fine on Windows, ...
user avatar
4 votes
1 answer
371 views

Modify `iskeyword` for keyword-local completion only

Context Some time ago, I added the following line to ~/.vim/after/ftplugin/sh.vim to make working with parameter expansions easier: setlocal iskeyword+=$ This is nice to be able to e.g. ysiw" via ...
D. Ben Knoble's user avatar
  • 25.4k
4 votes
3 answers
2k views

Caps Lock in insert mode only

Sometimes, such as when transcribing FORTRAN code, I find it useful to enter uppercase letters without holding down the Shift key. However, enabling Caps Lock is a problem in command mode. Here is my ...
Nathaniel M. Beaver's user avatar
4 votes
2 answers
1k views

mapping to map <return>

I'm trying to create a mapping to create a mapping such that pressing <C-return> presents me with :nnoremap <return> : to which I can then add a custom command. The following does not work ...
Octaviour's user avatar
  • 942
4 votes
1 answer
1k views

remap not working; <NL> in appears in other binding

I'm trying to remap Control + [hjkl] to navigate among splits, by setting this in my rc file: " splits navigation nnoremap <C-h> <C-w>h nnoremap <C-j> <C-w>j nnoremap <C-k&...
alxndr's user avatar
  • 1,356
4 votes
1 answer
119 views

How to map "q" to "<cr>" for the hit-enter prompt?

I regularly press q to exit the -- more -- prompt in Vim. I often mistakenly use this same key to exit the hit-enter prompt, which then starts recording a macro after a subsequent key is typed. I'd ...
dannyadam's user avatar
  • 482
4 votes
3 answers
4k views

How to map Ctrl-(? [duplicate]

I am trying to map Ctrl( in insert mode. However, Vim does not recognize the key binding. This is what I currently have: " Insert a pair of brackets using Ctrl-( inoremap <C-(> ()<left> ...
Flux's user avatar
  • 1,021
4 votes
1 answer
2k views

Having issues maping <C-j> and <C-h> in vim [duplicate]

I tried to remap my split navigation like explained here. Moving to the top or right split works but ther other two just do nothing. I tried the same without a .vimrc which led to the same result. ...
Benjamin Zinschitz's user avatar
4 votes
1 answer
1k views

How to remove the mapping from Ctrl-[ to Escape? [duplicate]

If you have an American English keyboard, pressing Ctrl-[ (control plus left square bracket) is equivalent to pressing Esc. This provides an easy way to exit from insert mode. source: https://vim....
Steven Roose's user avatar
4 votes
3 answers
1k views

Unmap all combinations starting with certain key

I am experimenting with default key mappings and am considering remapping the g key entirely. But first I would like to turn off all the existing mappings that g has. For now I am using this kind of ...
Karolis Koncevičius's user avatar
4 votes
2 answers
11k views

Mapping with the meta key

I'd like to bind some combinations to Alt-_some-key_, but not quite sure about how to do it correctly. Here is one of my current setup (example): vnoremap <ESC>c "+y This is because my ...
Dmitrii Bundin's user avatar
4 votes
2 answers
628 views

How to trigger <tab> auto completion in a key mapping?

I'd like to map Leader+e in normal mode to showing the auto completions of files to edit. I tried nnoremap <leader>e :e<space><tab>, but it shows :e ^I, where the tab gets rendered ...
danijar's user avatar
  • 391
4 votes
1 answer
180 views

Beep upon using a mapping

Well, I try to use the following convention. ± (as unused key) is used for increase search where / is used for regular search. The implementation: set noincsearch nmap ± <esc>:set ...
eyal karni's user avatar
  • 1,058
4 votes
2 answers
836 views

Open markdown filename under cursor like gf, and jump to the section?

I have the file /path/a.md which has many sections as follows: # abc this this the content of section abc # def this this the content of section abc ## defg this this the content of subsection defg ...
Lerner Zhang's user avatar
4 votes
1 answer
9k 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.
WickedJargon's user avatar
4 votes
1 answer
2k views

How can I map Ctrl-Alt-<letter> mappings in vim?

My keybindings are consistent and work across different operating systems, terminal emulators, browsers, tmux, etc. There are no clashes, but this sometimes means remapping things in some instances. ...
paradroid's user avatar
  • 365
3 votes
1 answer
319 views

How to jump to a next or previous specific character ignoring linebreaks and not destroying highlight or overwriting my registry?

I have not found much use for ()[]{}, and so I want to map them so it does a find command, jumping to the previous instance of that particular character. Thus, ) will jump forward to the next ), ...
Anon's user avatar
  • 875
3 votes
1 answer
403 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 ...
SergioAraujo's user avatar
  • 1,167