Skip to main content

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
1 answer
402 views

Remap keys conflicting with plugin

I want to remap Ctrl+y(scroll up) to up. However, I also have yankring mapped to Ctrl+y, and I wish to keep yankring's mapping. Now if I have this in .vimrc: map <Up> <C-y>, pressing up ...
noobcat's user avatar
  • 55
3 votes
1 answer
109 views

custom mapping to make dge consistent with dw, de, and db?

Situation Recently I was investigating the behaviour of word motions in vim and to me it seems like ge is grossly inconsistent with the other 3. Here is an example with ^ showing the cursor: word1 ...
Karolis Koncevičius's user avatar
3 votes
1 answer
1k views

Why is `vmap` for both Visual *and* Select mode?

Vim has both Visual and Select modes. Select mode is similar to Visual mode in some senses, but different in that when a printable character is typed, Vim will replace the selection with that ...
filbranden's user avatar
  • 29k
3 votes
1 answer
450 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,175
3 votes
1 answer
164 views

Setting to prevent <c-h> to erase text

I have a map which allows me to navigate with hjkl in insert mode: " In insert or command mode, move normally by using Ctrl inoremap <C-h> <Left> inoremap <C-j> <Down> ...
Diego Somar's user avatar
3 votes
3 answers
279 views

Substitute an insert-mode input immediately

I would like to type begin! in insert mode and having it immediately replaced by: begin [cursor here] end I considered mappings: :inoremap begin! begin end<Left><Left><Left><...
Maëlan's user avatar
  • 263
3 votes
2 answers
233 views

How to automatically break down the description of a command?

I found the following description of a command which sets up which items must appear in the status line, here: set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v] " | | | | | | ...
user9433424's user avatar
  • 6,148
3 votes
3 answers
545 views

How do I swap key bindings without breaking plugins?

I'm thinking about exchanging some keys while in non insert-mode so that the bindings that I use most are easier to reach (i.e. on the home row). How can I swap two keys without breaking the ...
Julien__'s user avatar
  • 139
3 votes
1 answer
4k views

Vim tool to show keyboard shortcuts for typed commands?

I am learning Vim by typing some commands in full rather than using keyboard shortcuts. Is there a tool or plugin that can show me the equivalent shortcuts if they exist, whether they are built in ...
vfclists's user avatar
  • 897
3 votes
3 answers
180 views

How to map CMD+Alt alone to the command?

I am trying to map Cmd+Alt to start searching in vim (/). The only question is: how would I do this? I know to map Alt in vimscript is by typing <A> but I do not know how to do Cmd. I also want ...
iProgram's user avatar
  • 1,599
3 votes
2 answers
4k views

Getting Shift-Tab to work in VIM Insert mode

I've been trying to get Shift+Tab or <S-Tab> to work in VIM and I can't figure it out. I read this document, but the remap solution only works for normal mode (because if I press Shift+Tab, VIM ...
Luke Davis's user avatar
  • 1,397
3 votes
1 answer
341 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
  • 885
3 votes
1 answer
1k views

How to escape pipe (|) in mapped substitution?

I wanted to define a mapping for flipping the texts on both sides of a pipe (|) character. For example, substitute dům|Haus with Hause|dům The substitution command :s/\([^|]\+\)|\([^|]\+\)/\2|\1/ ...
Hermann Schachner's user avatar
3 votes
1 answer
119 views

Auto replace special programming characters

Programming in Javascript and similar syntax languages we use a lot of {} and (), more so than [] and the 90. Therefore we end up using SHIFT a lot. Is there a way to make it so that when I type [ ...
user1894919's user avatar
3 votes
3 answers
456 views

How to get tpope/vim-rails gf command to work with SpaceVim

I am using SpaceVim as Ruby on Rails IDE and installed the tpope/vim-rails plugin. Commands such as :Econtroller, :Emodel and :find are working just fine, but the gf command provided by this plugin ...
Bipin Manandhar's user avatar
3 votes
1 answer
111 views

Maps literally read < and > instead of the actual character

Situation Entire .vimrc: inoremap a <CR> Action: user types ia to enter insert mode and type a Expected result: a carriage return is entered into the document Actual result: the characters &...
ei2's user avatar
  • 59
3 votes
1 answer
38 views

How can I make $ in LaTeX insert \( and \) automatically? [duplicate]

I'm writing a lot of LaTeX recently, and am used to hitting the $ key for inline math, but have heard that \( and \) is better (apparently it confuses vim less, especially with $$, which I'm also not ...
D. Ben Knoble's user avatar
  • 26.6k
2 votes
1 answer
449 views

Mapping for expression register with langmap active

I am using Vim with a QWERTY/BÉPO langmap setting which allows me to use the French dvorak-like keymap for inputting text and the QWERTY commands for the normal and visual mode. Background: I am ...
Lionel Hamayon's user avatar
2 votes
1 answer
382 views

How do I enable mouse in netrw only (terminal vim)?

I would like to be able to use my mouse to scroll and click on directories to expand them in netrw. I don't want the mouse to be on for any other filetype/buffertype, so that I can still highlight/...
wxz's user avatar
  • 155
2 votes
1 answer
391 views

Conflict between system compose key and insert mode meta key mappings

I use the right alt key as a compose key on my system, to easily draw diacritics and accent characters. In Vim, I unlock alt key mappings with this (from stackoverflow): " Allow <alt> key ...
Biggybi's user avatar
  • 2,770
2 votes
1 answer
301 views

Why doesn't this macro work? (expression register)

According to this: nnoremap Q @='n.'<CR>: The @ key tells Vim to execute a macro. Rather than using a named register we use the expression register, which lets us specify the contents in ...
WalksB's user avatar
  • 517
2 votes
2 answers
185 views

Why would you use `nnoremap gf gf` as SpaceVim does?

While writing this answer about vim-rails on SpaceVim, I found out these mappings set by SpaceVim, such as this one: nnoremap gf gf SpaceVim also creates similar mappings for all of the other gX ...
filbranden's user avatar
  • 29k
2 votes
1 answer
393 views

Mappings that work in nvim not working in vim [duplicate]

I have these key mappings that I use a lot in nvim, but they don't work in vim: " Move lines with Alt+Shift+j/k nnoremap <A-S-j> :m .+1<CR>== ...
paradroid's user avatar
  • 377
2 votes
1 answer
154 views

Where to find the time interval for a key combination to work?

the key combination dw is to delete a word. I've also defined my own key combination, e.g. <leader>j to move to a window below. My question is how much time is left between the first and second ...
Aaron Shen's user avatar
  • 2,529
2 votes
2 answers
202 views

How to disable auto insertion of comment header when pressing enter, but keep auto insertion of header when auto wrapping comment?

When editing c and cpp files, this is the behavior I want to achieve: When typing a comment line of the form // Line..., pressing <CR> should not add the comment header // in the next line. ...
Diggs's user avatar
  • 75
2 votes
1 answer
420 views

better copy-paste multiple lines in visual mode where vim pastes after that visual chunk of code

I want to select multiple lines in vim, copy them, and paste after that chunk of code (with cursor at the beginning). yp doesn't work because in visual chunk of code, vim pastes after the 1st line of ...
Mega Bang's user avatar
  • 309
2 votes
1 answer
337 views

Mapping specific for diff mode and vimdiff

My idea is that whenever &diff is true for a buffer, I would like some mappings to be active when that buffer is the current buffer. The following attempt works for when I open a session in diff ...
Enlico's user avatar
  • 2,224
2 votes
1 answer
347 views

Is it possible to supply arguments to inoremap?

Currently, I have the following map for cpp files: inoremap ;;f for<Space>()<Space>{<Enter>}<Esc>kkf)i Which essentially allows me to quickly setup a c-style for loop. ...
Yadeses's user avatar
  • 123
2 votes
1 answer
1k views

Is there Vim plugin that can show keystroke maps or abbreviations for command after it is used?

Is there a tool or plugin for a learner which can display the keyboard shortcuts or abbreviated versions for commands after they are typed in? If for instance I use : to get the command line and ...
vfclists's user avatar
  • 897
2 votes
2 answers
1k views

inoremap only works after source

So I want to disable the arrow keys in insert mode. So I added the following lines at the end of ~/.vimrc: inoremap <up> <nop> inoremap <down> <nop> inoremap <left> <...
Jakube's user avatar
  • 435
2 votes
1 answer
494 views

Operator pending mode remaps not working

I'm trying to build a vimscript can be used with the Dvorak Simplified Layout. I.e., given that the keys on the keyboard plugged into the computer are laid out in the Dovark Simplified Layout (and the ...
Sergey Nikolayvich's user avatar
2 votes
1 answer
439 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 ...
jtst's user avatar
  • 23
2 votes
1 answer
56 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 ...
user avatar
2 votes
1 answer
1k views

Map <C-/> on linux and windows [duplicate]

I knew that map / is _ on linux, but it not work on windows. What should I do to map it?
Dark.Hades's user avatar
2 votes
1 answer
76 views

Why does g+ sometimes skip a leaf of the undo tree?

I'm trying to understand how to move in the undo tree with the following default mappings: u, <C-R>, g- and g+ Here's my understanding of things, which is probably wrong or incomplete. Each ...
saginaw's user avatar
  • 6,826
2 votes
1 answer
201 views

Tabbing between files

I am trying to add the following lines to my .vimrc nnoremap <C-Tab> <C-w>w nnoremap <C-S-Tab> <C-w>W As per Vim Tutorial However I can't seem to get these to work. Other ...
avrono's user avatar
  • 121
2 votes
0 answers
878 views

How do you map the back tick character (`) with a modifier key like ctrl? [duplicate]

Is there a way I can map a digraph like ` , with modifier key like ctrl together in vim like this NERDTree bind. map <C-n> :NERDTreeToggle<CR> It seems to be a tad bit more ...
PrimRock's user avatar
  • 363
2 votes
1 answer
306 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&...
Attilio's user avatar
  • 369
1 vote
0 answers
231 views

Can I map contrl and hyphen <C-->? [duplicate]

How can I map Ctrl and hyphen key? Usually when mapping Ctrl key with other keys there is a hypen key in the middle. But I would like to use this hypen key as my mapping, can I do that? When I tap ...
SLN's user avatar
  • 547
1 vote
1 answer
926 views

How can I change the cursor moving on ctrlp?

I want to change the key mapping when I run CtrlP. For example, if I press ctrl+p to run CtrlP, type in something, and try to move the cursor to choose a file, I want to use ctrl+j to move down, and ...
Blaszard's user avatar
  • 555
1 vote
0 answers
137 views

How to load method definition in a popup?

This is a followup to this question, where I would like to load the method definition in a pop-up rather than a split screen (or the whole screen for that matter). Attempt 1: using nui.vim I’m using ...
abbood's user avatar
  • 743
1 vote
1 answer
706 views

Display human readable meta/alt-(key) mappings

In :imap, I see mappings like: i © *@<C-R>=AutoPairsMoveCharacter(')')<CR> i ¨ *@<C-R>=AutoPairsMoveCharacter('(')<CR> i î *@<Esc>:call ...
Tom Hale's user avatar
  • 2,711
1 vote
1 answer
742 views

Special characters, escaped special characters, escape sequences, and terminal codes

I refer to those 4 terms using terminology picked up by various sources: Steve Losh, in his Learn Vimscript the Hard Way's chapter 16 refers to things like <cr> (these 4 characters typed in a ...
Enlico's user avatar
  • 2,224
1 vote
0 answers
50 views

mapleader & <Nop>: strange timeout behavior [duplicate]

I use <Space> as my leader key, with a short timeoutlen: let mapleader = ' ' set timeout timeoutlen=300 ttimeoutlen=5 Sometimes in normal mode, I hit <Space> then hesitate (maybe I ...
ivan's user avatar
  • 1,470
1 vote
2 answers
406 views

How to enable disabled movement keys in netrw?

Recently I started using and learning Vim. I turned off movement keys in my .vimrc file like this: noremap <Up> <NOP> noremap <Down> <NOP> noremap <Left> <NOP> ...
Igor R.'s user avatar
  • 113
1 vote
1 answer
150 views

Vim - edit last action before using (.)

Related to but not duplicate¹ of Bundling command sequences together for repeat (.). The point (.) command is really useful to redo the last action (insertion, replacement, etc.). Sometimes I find ...
Gabriel Devillers's user avatar
1 vote
1 answer
514 views

Is it possible to map one key to two commands, doing 2nd command only if first fails

I want to map the tab key to <c-w>w to switch windows when there is more than one window open. But if there is only one window but multiple tabs, I want it to detect that there is only one ...
domoremath's user avatar
1 vote
1 answer
583 views

How to read/get the number of lines of code in the buffer or a directory?

We can read some information about the current buffer, by hitting g C-g; for example: Col 3 of 2; Line 28 of 106; Word 144 of 474; Byte 916 of 3396 And we can capture the same information in a ...
user9433424's user avatar
  • 6,148
1 vote
0 answers
2k views

How to map the slash key "/"

I am trying to map the NERDCommenterToggle command from the nerdcommenter plugin. I want to use "Ctrl+/" for this: vmap <C-/> <plug>NERDCommenterToggle nmap <C-/> <plug&...
rsaavedra's user avatar
  • 121
1 vote
1 answer
1k views

Vim mapping to auto-indent when entering inside braces, brackets etc

Which vim mapping/ plugin will help me in auto-indenting when entering inside braces, brackets or any similar characters. For example: Input {press enter} Output { cursor here } I want ...
Haris Muzaffar's user avatar