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
2answers
30 views

How to call a plugin in a mapping?

I'm doing a project-wise refactor and I want to change variable names from camelCase to snake_case. I have YCM and vim-abolish installed. Let's say I have the following source file: dueDate = ... ...
0
votes
1answer
58 views

Mapping jj to Escape doesn‘t work over SSH connection

When I connect to a remote server via iterm2 and SSH and use vim on this server remapping to the Escape key doesn't work. Other key mappings in the .vimrc work as expected but inoremap jj <Esc> ...
0
votes
0answers
19 views

Map a key in “search mode” [duplicate]

"Search mode" is not a true mode, but is it possible to create mappings that only apply while typing a search after / or ?? I am wondering how one would go about mapping <C-f> to start ...
0
votes
1answer
19 views

How to group all `cscope` related configuration into `augroup`, so it's only applied for C/C++ files?

How can I group all cscope (:cs) related configuration into e.g. autocmd, so that this configuration is only applied to c or cpp files? I have been looking at e.g. this, but it only address a single ...
0
votes
1answer
27 views

Map jk to Esc and Ctrl-A to select all but they don't work

That's my .vimrc set noerrorbells set tabstop=4 softtabstop=0 noexpandtab shiftwidth=4 set smartindent set number relativenumber set nowrap set noswapfile set hlsearch set smartcase set incsearch set ...
0
votes
1answer
12 views

“auto-complete” normal mode command?

Once I press g (or anything that enters operator pending mode), is there a way to see what keys could follow (e.g. gf, ga etc)? Alternatively, is there a way to search builtin + mapped keys by regex? ...
1
vote
2answers
43 views

How to prevent cnoremap taking effect for “/” searching?

I have created the following mapping for Ex mode to prevent having to enter :FZF capitalized to invoke FZF: cnoremap fzf FZF The problem is that this key mapping also affects "/" searching, ...
0
votes
1answer
16 views

Get path to parent directory and use it in a nnoremap command?

Say I have a nnoremap and I want to pass the path of parent directory of current file to it, so the command can use this information. I have read this answer: How can I see the full path of the ...
0
votes
1answer
28 views

Map to a key to do nothing?

I'm tuning :sp, :vsp things, and for example I have: nnoremap <nowait> <C-L> <C-W><C-L> nnoremap <nowait> <C-W><C-L> :vsp<CR><C-W><C-L> ...
0
votes
0answers
25 views

Creating shortcut for vim command

I created following shortcut for vim command in .vimrc: :nnoremap <Leader>1 :set foldexpr=getline(v:lnum)=~'^\\s*$'" But the shortcut doesn't work. The shortcut doesn't work if I change 1 ...
0
votes
1answer
38 views

Why does the cursor end up on the wrong line when <Esc><Esc> is mapped to something?

In vim --clean, I insert these lines: One Two Three Four Five Six Then I do: :set mouse=a :nnoremap <Esc><Esc> <Nop> (From my observations, the mapping could be to anything. :...
2
votes
1answer
40 views

Function keys and <Home>, <PageUp> etc are dead in neovim TUI

I decided to give neovim a try and things mostly work with my vim8 configuration. However, function keys are dead in the text user interface (ok in nvim-qt), i.e. with :map <F1> iFoo!<esc> ...
0
votes
0answers
9 views

Is there a way to use dvorak in both command mode and insert mode at the same time using keymap settings

I was trying to use dvorak with vim So I tried the normal keymap in the Edit settings, It works fine while in normal and insert mode But It goes back to qwerty when in command mode ( i.e. :command ) ...
1
vote
0answers
12 views

Can I use Mac keybindings in insert mode?

I use Vim on a Mac book, and I am wondering if it is possible for me to use Mac keybindings when I am in insert mode. For example, option + delete to remove the word before the cursor, command + ← to ...
0
votes
0answers
31 views

Map left command key to left control key in terminal only?

I've asked this question over on AskDifferent without any luck. I'm using neovim to edit code and am needing to create a mapping to bind to <cmd-w> to <C-w>. How would I go about this on ...
0
votes
1answer
43 views

What is the <80><f5>X keycode?

I created the following mapping. vmap <leftmouse> <cmd>echom getchar()<cr> I then enter visual mode, switch to select mode by pressing <c-g>, and then drag the mouse. After ...
1
vote
1answer
42 views

What exactly Ctrl + Shift + Right arrow does? How can I remap it or find help on this key combination?

I've noticed that pressing Ctrl+ Shift+ Right deletes text until some criteria are met but I can't figure out exactly what that is. I'm also unsure how to find help when a character doesn't have a ...
0
votes
1answer
21 views

Map a custom command so as to be able to execute it n times

I am using this mapping: " Class: transform init arg to variable assignment " <Esc> is input as Ctrl + v <Esc> and shows as ^[ nnoremap » :norm 0wiself.<Esc>w"byiwEDa =...
1
vote
0answers
28 views

Any ideas on how to jump back and forth between a file and its corresponding unit test?

Here's an example of a typical project structure for me: components/a.js components/common/b.js tests/unit/components/a.test.js tests/unit/components/common/b.test.js Notice that inside the /unit ...
0
votes
1answer
40 views

VIM: How to call a vimscript function after press a shortcut or execute a command?

I want to know how to call a function after a normal or Ex command. Examples: bind a function to search command. When I input /xxxx to search xxxx, also call the function. press * to highlight ...
0
votes
1answer
23 views

How to jump to specific line of a file when file path and line number is given?

I have a filename and its line provided in this format, e.g.: ./my_dir/my_filename.py:20: When I move on the filename and press gf I jump to that file, however the cursor stands on line number 1, ...
0
votes
1answer
30 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/...
1
vote
1answer
22 views

How to map UTF-8 symbols to numbers in command-line mode?

Sometimes I change input source (keyboard language) and my number buttons get mapped to rarely used UTF-8 symbols, e.g. 1 gets changed to ą, 2 to č, 3 to ę, etc. I have managed to map them in normal ...
0
votes
2answers
53 views

Mapping with motion ip

I'm trying to create my own mapping with motion in Vim after reading this stackexchange question. I'm using the plugin vimtux to send code to specific tmux instances and I now want to be able to do ...
0
votes
1answer
23 views

Sending two keys in series during autocompletion confirmation

I have the following mapping: inoremap <expr><CR> pumvisible() && complete_info().selected != -1? "\<C-y>" : "\<CR>" inoremap <expr><Space&...
0
votes
0answers
23 views

Modifying 'showcmd' output

The documentation for g@ shows an example where <F4> is remapped to count spaces corresponding to the subsequent motion, using 'operatorfunc' and g@. The usage of g@ in the mapping results in ...
-1
votes
1answer
51 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.
1
vote
1answer
42 views

Mapping multiple commands to `inoremap`

I'm trying to map a function to <CR> but the problem is, that another plugin already mapped something to it. So that's the code from me: function Test() echom "Test succeeded!" ...
0
votes
1answer
48 views

Can I replace multiple lines with a single line break?

A common operation for me is V <movement commands> d k o ESC to delete a bunch of lines and add a newline. Is there a quicker vim way to do this?
0
votes
1answer
36 views

noremap in .vimrc for YouCompleteMe does not work

noremap <leader>gdf :YcmCompleter\ GoToDefinition<cr> noremap <leader>gdc :YcmCompleter\ GoToDeClaration<cr> noremap <leader>gi :YcmCompleter\ GoToInclude<cr> ...
0
votes
0answers
25 views

the meaning: 'termwinkey' CTRL-\ send a CTRL-\ to the job in the terminal

In the manual: 'termwinkey' CTRL-\ send a CTRL-\ to the job in the terminal It don't explain what CTRL-\ mean for the job in the terminal,it means stop the job or something else?
0
votes
1answer
39 views

How to delete a WORD in insert mode?

I know that I can press Ctrl-W to delete a word in insert mode, but how would I delete a WORD? For example, with this text foo.bar.baz ^ (cursor position) the command should delete all the ...
0
votes
1answer
37 views

What keys on my keyboard is <M-n>?

Stupid I know, but I can't find for the life of me what keycombination the <M-n> mapping is. :bn<CR> is mapped to <C-n> wich is ctrl+n :bp<CR> is mapped to <M-n> wich is ...
1
vote
1answer
43 views

Running pdflatex using a key mapping

I have a latex file which includes multiple figures. These figures are kept in different directories whose path is given in the latex file using the graphicx package: \usepackage{graphicx} \...
0
votes
1answer
35 views

Determine if there is a matching character on the current line past the cursor

I am trying to make a mapping that performs what f would normally do if there is a character match on the line, and to do something else if no such character exists. For example, suppose if I had the ...
1
vote
1answer
46 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/ ...
-1
votes
1answer
27 views

mapping to delete and yank multiple lines e.g. d4y instead of d4d

In my vimrc I have nnoremap d "_d nnoremap yd dd to not save lines when I delete. Is it possible to create a mapping that when I press e.g. d4y it will cut 4 lines and save them into buffers? I ...
1
vote
0answers
28 views

Can't remap to <C-)>

I'm using a French keyboard, and <C-]> to access to a tag definition is cumbersome. You need AltGr+] to access the ] character, so the whole thing is 3 keys pressed at the same time: Ctrl+AltGr+]...
1
vote
1answer
16 views

Synchronize the scroll offset of a vertical split

Set up Left (L) and right (R) are two vertically split windows displaying the same file. No other windows exist in the tab. The uppermost displayed line in L is x (Lx) and the uppermost line in R is ...
0
votes
0answers
15 views

placeholder after every & in tex.snippets

This is a snippet from tex.snippet of honza/vim-snippets/Ultisnips. As per the number of items inserted in $2, I will get & in 2nd line. But, I am looking for & $i so that I can jump to that ...
0
votes
1answer
16 views

Make j and k act character-wise when used with operators

When I use j or k with operators, they make the operator act line-wise - acting over two whole lines, as if I had used Vj/Vk. I want them to act character-wise so that they act until the current ...
0
votes
0answers
44 views

inoremap doesn't work

Question summary Currently I'm writing a pull request for this vim plugin which should set commas and semicolons automatically. At the moment it looks if it should set a comma/semicolon/double point ...
0
votes
0answers
49 views

Why C-0(zero) in insert mode is not working?

I have mapped some shortcuts to help me in insert mode and one of them is not working. " Go to end of line on insert mode inoremap <C-e> <C-o>$ " Go to beggining of line on ...
1
vote
1answer
42 views

imap <expr> call multiple functions

I want to map <CR> to call multiple functions e.g. Func1() Func2() Func3() I tried: imap <expr> <CR> Func1() Func2() Func3() But I got "E15:Invalid expression" How can I ...
0
votes
1answer
77 views

Listen to specifique key pressing

I'd like to call a (vimscript-) function, if I'm pressing the return key. Is it possible to do that in vim? Because currently this doesn't work: function Test() echom "test" endfunction ...
2
votes
1answer
56 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 ...
1
vote
1answer
25 views

Create mapping that works both with a motion and a count

I'd like to have a mapping that separates words, like this: noremap RJ :s/\>\s*\</\r/g<CR>='' I can do 3RJ with that. I can also create opfunc, so I can do RJ}: noremap RJ :set opfunc=...
0
votes
1answer
50 views

Run a command every time any key is pressed

I want to run a function every time the user presses any key. I have already looked through the autocommand documentation and there does not seem to be one for this. Is there any function I do not ...
0
votes
2answers
41 views

Inserting a future time

I would like to create a simple pomodoro timer I can insert into text files. Something like: Current Time - 10:15 End Time - 10:40 However I have not been able to find a good way to insert a future ...
0
votes
0answers
17 views

How to open terminal in split in vimrc with keybinding [duplicate]

I am trying to open a new terminal (size of 10) inside of neovim. I use the command, :split|resize20|term. It works well, but I want to make a hotkey to do this in my init.vim nnoremap <C-P> :...

1
2 3 4 5
24