We’re rewarding the question askers & reputations are being recalculated! Read more.

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
6
votes
2answers
259 views

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

Disclaimer: I tried to find a generic title for this question but I was overcomplicating the whole thing... Use case: In a JS file, I have an expression like: if (someVar === 'someValue') { ...
0
votes
1answer
45 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
27 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
29 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
40 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
50 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
83 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
32 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
65 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
38 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
26 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
126 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
45 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
16 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
30 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
36 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
47 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
38 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
38 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
341 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
38 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
32 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
31 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
34 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
33 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
16 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
477 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
39 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
25 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
29 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
66 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 ...
0
votes
2answers
22 views

how can i remap <C-w>{number}h to <C-w>{number}j

I am trying to remap my hjkl keys to jklö. this is not a problem in most simple cases, but with commands like <C-w>h where you can specify an amount in the form of <C-w>{count}h or {count}&...
3
votes
1answer
30 views

Match <Esc> only for the ESC key, not escape sequences

In a normal mode key mapping I'd like to match the ESC and only this key, not key sequences like caused by the arrow keys. Background: I thought I'd torture myself in the process of avoiding excess ...
1
vote
1answer
32 views

Is it possible to `lmap` a key to multiple characters?

I want to use f and t command for Unicode characters, so lmap is the way to go. I can map a letter to a Japanese kanji: :lmap k 中 then after i_CTRL-^, I can press fk to locate 中。 However, there is ...
2
votes
1answer
44 views

Write text under the cursor to new file and delete it form current file

I have this in my vimrc: " Export text under the cursor noremap <leader>e :w! >><Space> This allows me to select text using visual mode, press leader e, type a file name, and ...
3
votes
2answers
54 views

How do I disable a a key in Tagbar

I've mapped 'L' and 'H' to change buffers in vim. I often end up hitting these keys in NERDTree and Tagbar. I'm able to use NERDTreeAddKeyMap to make NERDTree ignore keys. Tagbar only allows the use ...
1
vote
1answer
46 views

is it possible to map numpad differently?

Currently, the numpad does the usual things(input numbers and so on). numlock does nothing. I wonder if you can differentiate numbers/char entered on the numpad from those typed on the main section ...
3
votes
1answer
39 views

How to map number keys within motions typed during the operator-pending mode?

Typing source code is easier for me when the numbers row above the letters (the numrow) is permanently shifted, giving me access to the symbols at a single keypress, without pressing Shift. The ...
-1
votes
1answer
34 views

How would one remap >> and << to in/decrease the level of headings in org/dotoo files?

I've tried the Emacs land and when using evil-org >> and << are remapped to in/decrease the level of headings, how could I do the same with vim and vim-dotoo?
2
votes
2answers
117 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] ...
1
vote
1answer
54 views

Mapping using <Esc> writes “<Esc>” in insert mode rather than switching to normal mode

I have the following line in my .vimrc: inoremap kj <Esc> It had been working fine, ie it returned me to normal mode. But now it inserts the string "< Esc>" (I use the initial space here ...
1
vote
4answers
255 views

How to change word under cursor to upper case in command mode with shortcut?

I want to set up a shortcut to make word under the cursor upper case in the command mode. I know that you can get the word under the cursor with expand("<cword>"). But I am not sure how do I ...
0
votes
1answer
52 views

How to fix Leader Key Beep in Vim?

I cannot get the leader key working in vim. I have been troubleshooting for quite some time. Stuff I did already: Mapping leader key to another key :PlugInstall --> Already Installed x Plugin ...
3
votes
0answers
49 views

Maps literally read < and > instead of the actual character

Here's the 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 ...
1
vote
1answer
24 views

How do I map multiple replace commands in visual mode

I'm trying to edit my init.vim to allow quick, custom retabbing with one key. My current attempt is as follows (the replace text in the last command is a tab character inputted in insert mode): ...