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
1
vote
1answer
42 views

Why can't I remap q [closed]

I have many key mappings in my vimrc but for some reason no matter what I do q remains mapped to recording macros. I will post my full vimrc below, but the relevant part is that even if the last line ...
3
votes
2answers
60 views

Move rest of line inside a closed pair?

This is what I'm trying to achieve: input (|)foo then pressing some key combination to get output (foo)| or (foo|) I know this can be done with the autopairs plugin. In the docs they write ...
2
votes
1answer
43 views

Map <C-J> to <Space> in all possible modes

My space bar no longer works unless I lean my weight on it. The chances of getting the laptop replaced in a timely manner is close no nil. I mostly use vim or vi, even from the bash command line. ...
1
vote
1answer
21 views

Completion pop-ups hijack arrow keys. Any way to disable that?

Regardless of which code completion plugin I use (I tried asyncomplete and YouCompleteMe), when there's a completion pop-up, up and down arrow keys select completion options in it instead of moving ...
4
votes
2answers
27 views

What does <SID>some_function() . '_' mean? in particular, . '_' part

While I was studying Tpope's vim-commentary, I was struck by a line that contains the topic of this question. I am referring to one of the lines in Tpope's vim-commentary: https://github.com/tpope/vim-...
1
vote
1answer
29 views

Repeat/copy a character sequence using commands

I tried the following in my .vimrc using the hints I found here: map <Tab> i4<Space><Esc> map <F2> /79*<CR>79*/<CR>PROGRAM<Space>NAME<Space><Space&...
3
votes
3answers
31 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> ...
7
votes
1answer
232 views

Which keys are free / unmapped by default?

Is there a list of keys which aren't mapped by default in vim?
1
vote
1answer
35 views

vimtex imap not working

I'm having a problem with using imaps with vimtex (i.e they don't work). To test the issue I went to .vim/plugged/vimtex/test/examples/minimal and started vim -u minivimrc. Typing `a (which is a ...
1
vote
1answer
50 views

Easiest way to go to the closest closing bracket?

When I'm choosing an option from the autocomplete suggestions, it automatically put my cursor in the following location: function(|) Then I type a value and I want, and in order to got out of the ...
1
vote
2answers
35 views

CTRL-V_CTRL-[key], instead of ^[key] gives ^[[27;5;[ASCII code of key]~ in xterm on Arch

For example, Ctrl-v_Ctrl-w gives ^[[27;5;119~ instead of usual ^W. It does behave in such way only on (u)xterm. I've tested it on st, lxterminal, xfce4-terminal and rxvt. I'm also 98% positive that ...
3
votes
1answer
19 views

Insert mode mapping to leave insert mode then invoke a plugin function

In Insert mode, I want a mapping which will return to Normal mode, then call a plugin function. I've tried this: inoremap <a-1> <ESC><Plug>AirlineSelectTab1 It exits Insert mode, ...
2
votes
2answers
34 views

Why do the \| characters in an :execute “normal …” mapping require extra escaping backslashes?

I'm struggling to understand a character escaping situation involving \|. First I'm running the following search which matches either the A character or B character. I'm using the default magic ...
4
votes
2answers
38 views

Map CTRL-& in vimrc

I'm trying to re-map tagbar toggling with <C-&> that I get used to when working with IDEs. But setting execute "nnoremap <C-&> :TagbarToggle<CR>" does not have the ...
8
votes
2answers
505 views

How to Insert a console.log for word under cursor in new line

Use case: In a JS file, I have an expression like: if (someVar === 'someValue') { statements; } and, for debugging purposes, I sometimes want to include a console.log in the line above: ...
0
votes
1answer
46 views

viw breaks when i is remapped

I have the following in my init.vim (neovim): nnoremap i k nnoremap j h nnoremap k j xnoremap i k xnoremap j h xnoremap k j nnoremap h i nnoremap H I I find this arrow key-like configuration much ...
1
vote
1answer
29 views

nmapping two commands works only sometimes

Due to working in an environment with no clipboard support I have the following line in my .vimrc: nmap <F12> :set invnumber<CR> <bar> :set invpaste<CR> Oddly enough, this ...
0
votes
1answer
31 views

Override longer mappings

Is there a way to trigger a certain short mapping i.e. \c without waiting to see if there is a longer one that starts with the same characters (effectively disabling all other overlapping mappings)?
0
votes
1answer
46 views

“Wait” key in :map

In my .vimrc i have :imap .. .<C-x><C-o> and it work as it should (double dot to open menu with fields). But I also want to be able type text like [1..MAX] as you can see here vim will ...
0
votes
1answer
58 views

How can one use jk to escape universally without causing hang?

Recently I was reading http://learnvimscriptthehardway.stevelosh.com, and he said a very fast way to improve your speed in vim is to do inoremap jk <esc>. Sure, that made sense. Then when I ...
3
votes
2answers
87 views

Could someone explain “rolling one's finger” when used in a Vim context?

From a recent reddit post I saw: https://old.reddit.com/r/vim/comments/bm0ihb/evolution_of_a_vim_user/emt4p4a/ I keep seeing jk, am I the only one who does kj? It feels more natural to roll from ...
0
votes
0answers
21 views

navigating dictionary completion

In my vimrc I have the following mappings: set completeopt=longest,menuone,preview inoremap <C-h> <C-n> inoremap <C-k> <C-p> inoremap <Leader>k <C-x><C-k&...
0
votes
1answer
35 views

Jump to nearest pair of brackets with %

I'm looking for a way to change the behaviour of the % key. I know by default it will move the cursor to the corresponding parenthesis or brace, but I'm wondering if I can have it jump to the nearest ...
1
vote
1answer
71 views

Make mapping that accepts count independent of line count

I have a mapping that looks like this: nnoremap <expr> <c-x>b ":call MyFunction(" . v:count . ")\<cr>" I also tried to instead define function with range, but the effect is the ...
0
votes
1answer
40 views

Bell ring on mapping <c-/>

This is the problem. I want to use in my mapping but it causes a bell to ring every time I press on it, no matter what I mapped it to. For example: nmap <c-/> y I am on nvim-qt. PS tried ...
1
vote
1answer
29 views

How to backspace with X at the end of a line

In vim I often use <S-x> to 'backspace' in normal mode (deleting the char behind the cursor). However if I position the cursor at the end of the line, the last character on the line is not ...
2
votes
1answer
131 views

Different mapping behavior for the different visual modes?

I want to have different behavior for the different visual modes. As an example if I wanted to vnoremap S{ so that it has the following behavior: surrounds the selection in v mode, (puts { at the ...
3
votes
1answer
50 views

How do I use a variable or return value in option, command, or mapping?

I have a variable foo with let foo='value', and a function F like function F() return 'value' endfunction and I want to use them in an option: :set option=foo, :set option=F(); or in a command: :...
1
vote
1answer
18 views

calling function from normal mode without *noremap

I realise this might be impossible, but thought it might be worth asking anyway. In vim, the typical way I map keys to functions is using *noremap commands. However the downside of this is the fact ...
1
vote
1answer
42 views

Vim feedkeys in operator pending mode

I'm trying to build a very simple plugin that allows for pressing a keymapping <Leader>, to call a function that prompts for a single keypress: function! ControlKey() echo "Key → <C-Key&...
1
vote
3answers
38 views

Control key bitmask

I find myself wanting to use vim one-handed now and again. Practicality aside, I want to define a function along the lines of: function! GetControlKey() echo "Control? " let key = nr2char(...
3
votes
1answer
63 views

Is ESC involved in any key combinations?

Just starting to get into Vim and facing the classic escape problem. I'm thinking binding CapsLock to be control when used with another key, and escape when released without pressing anything else ...
2
votes
1answer
52 views

How to remap ci$

I am using the plugin vimtex. It offers the functionality (from the introduction of its documentation) Text objects ic ac Commands id ad Delimiters ie ae LaTeX environments i$ a$ ...
0
votes
1answer
39 views

Using <space> as prefix key in normal mode, cursor will advance one character itself

I put key mapping like this nnoremap <space>d "_d in my .vimrc, so I can delete text more comfortable. But when I in visual mode or visual block mode, the cursor will advance one more column, ...
2
votes
1answer
40 views

Can't unmap key mapping to its default permenantly

I mapped <C-X> to "*d and now I can't revert it back. I want it to subtract number by 1 like default, but I can't unmap it permanently, it's set to <C-X> in every new session. I'm sure ....
1
vote
0answers
51 views

How do I securely remap the current split's width and height keys?

Iam trying to put nnoremap <C-Right> <C-w>3> in the ~/.vimrc But it's not working. Also, VIM has a PRETTY ANNOYING line erasing binding to ctrl+Right in the Normal Mode. I would like ...
1
vote
4answers
348 views

Converting multiple assignment statements to single comma separated assignment

A vim newbie here. Would like to know an efficient way of converting self.mat = material self.epsilon=epsilon self.x = x to self.mat, self.epsilon, self.x = material, epsilon, x
0
votes
1answer
57 views

Use line's 'folded state' in a mapping, so it's `zc` closing but `zv` opening?

When I'm opening a fold, I would say 100% of the time the behaviour I want is zv - open all folds covering the current line, so that I can actually see it. But zv won't close a fold. How can I use ...
0
votes
1answer
40 views

How to set a shortcut for multiple leader commands

I'm using the nerdcommenter to comment and uncomment my c++ code. Basically I use \cc to comment one line, \cu to uncomment, \ca to switch the delimiters (switch // to /**/ or switch back). Now I ...
1
vote
1answer
32 views

Can I disable insert-mode completion (ins-completion) key mapping (CTRL-X)?

Because the keys d and xare used in normal mode to delete letters, I map <ctrl-d> and <ctrl-x> in insert mode to delete and backspace. However, when I started to use completion plugin (I ...
2
votes
1answer
54 views

Reduce size of undo file

I had a very large (14 digit) decimal number in my (Windows) clipboard. I had vim open in normal mode on the command line at the time. Accidentally, I pressed some key/mouse combination that caused ...
2
votes
1answer
35 views

mapping to open existing file in a split window, creates a blank last line, then enters insert mode

I am trying to combine several commands into a single mapping - (i) open a split window with a height of 15 lines, (ii) open an existing file in that window, (iii) move to the last line and char of ...
1
vote
0answers
18 views

Pressing <Alt-3> (left alt key) suddenly maps to Esc (and not the character “#”) using iTerm2 [closed]

Characteristics: MacOS 10.14.6 I'm using VIM as text editor for a few weeks, with both Terminal and iTerm2 I could write character dependent on hitting key alt (left alt key in iTerm) without ...
5
votes
1answer
508 views

How do I remap “å” to type “å”?

I recently came over some use for letters like æ, ø, and å. For context, these are available on my keyboard, and work fine in other programs. It's also a Norwegian keyboard if that's relevant. With ...
2
votes
1answer
45 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. ...
1
vote
0answers
17 views

Mapping breaks built-in Vim command? [duplicate]

In Vim the commands <C-o> and <C-i> move backwards and forwards through the jump list. :h CTRL-I I noticed that <Tab> is the alternative command you can use instead of <C-i> ...
1
vote
0answers
26 views

How do I remap result navigation buttons after a search?

I search with /, press enter, and go a few results down using n. I realize that I have gone a few more results down than I meant to and want to go back a few. I press m because that is next to n just ...
1
vote
1answer
30 views

how to map # to , (when , is my leader) while using vim-sneak

I use ',' as leader, so when I f/t and I want to go to previous hit, I cannto use ',' I tried using #: nnoremap # , My mapping shows up (I think), :map # shows this n # * , but it does ...
2
votes
0answers
30 views

How to get this tab/autocompletion setup?

Basically what I want is a PyCharm-like completion: If there is only whitespace, insert <TAB>. If pum is visible and nothing is selected, complete with first, otherwise choose the selected word/...
3
votes
1answer
79 views

Remapping motion keys [duplicate]

I recently found the awesome plugin named CamelCaseMotion which is awesome. I used their suggested mappings in my .vimrc for the plugin like this: map <silent> w <Plug>CamelCaseMotion_w ...