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
0
votes
2answers
46 views

Bind a specific search to a map in normal mode

Specifically, I'm looking to bind the search /\(<<<<\|====\|>>>>\)/ (i.e. "find the next git merge boundary"). Ideally to <C-/> or <A-/>, but that part I'...
0
votes
1answer
58 views

When would I use append and when would I use insert?

I already know that a and i makes the cursor one space to the right and left respectively, but when would I use i to edit a file? Is there some special circumstance that makes insertion mode more ...
1
vote
1answer
29 views

How to type ê without pressing <C-k> e>

My keyboard layout is set to international american. And to obtain the character ê just press <sfhit+6> e. However, within the vim I need to press <C-k> e>. Is it possible to map <...
1
vote
0answers
28 views

Conditional mapping for two plugins (UltiSnips and Vimwiki)

Vimwiki table default mappings include <tab> for moving to the next table column in insert mode. Also UltiSnips default mappings include <tab> for expanding snippets in insert mode. Here ...
1
vote
3answers
41 views

Easy way to get character before cursor character in insert mode?

I am trying to write a function for insert mode mapping in which I want to get the character before the cursor character. For texts that are purely ASCII, this is easy, since its byte index is the ...
0
votes
0answers
32 views

Why pressing Esc and then O from insert mode has this behavior? [duplicate]

When I'm in insert mode, for instance just between the two ls in hello, and press EscapeO (i.e. EscapeShift+o), the opening of the line above is not instantaneous. Specifically I see all this in ...
0
votes
2answers
35 views

How to grow/shrink a selection per tab?

How to have a selection grow/shrink as we tabulate, regardless of cursor position ? The selection can span more than one line. Kind of like this: For the tabbing I've got this part so far: xnoremap &...
0
votes
0answers
34 views

Confused why A-f keybinding does not work in neovim

I'm trying to add some readline keybindings into insert mode, like below, inoremap <C-B> <Left> inoremap <C-F> <Right> inoremap <A-B> <C-Left> inoremap <A-F> &...
0
votes
0answers
43 views

How do you represent “/” character in .vim?

Trying to map the NERDCommenter's toggle comment action (mapped to <leader>c<space>) to alt+/, something a bit more familiar. I tried: nnoremap <A-/> <leader>c<space> ......
1
vote
1answer
23 views

how to map the Y key (shift + y) to copy from the current cursor position instead of copying the entire line?

I would like to map the shift+y key to move the cursor one position to the right, press the y key and wait for the move command. Similar to the operation of the p key. When used without the shift, the ...
0
votes
0answers
19 views

Key combination to delete without copying to clipboard/register ? (General) [duplicate]

What's the command/option/keys/function that performs a delete on a selection (in visual mode) without copying the selection to clipboard/register? I.e I don't want to use d or x as they will delete ...
2
votes
1answer
36 views

Create a mapping that works whilst searching

I have jk remapped to <Esc> in insert mode and for some reason my brain always want's to exit a search by typing jk. I would like to remap jk to <CR> when performing a search. I.e typing /...
0
votes
2answers
27 views

How can I make a mapping to toggle cursorbind?

I know that adding a ! to the end of an option works for some commands, but it doesn't work for cursorbind. How can I toggle between cursorbind and nocursorbind with a keybinding?
0
votes
1answer
27 views

Line numbers relative to the screen

Is it possible to make Vim show line numbers relative to the screen? Not to the beginning of the file, and not to the current position of the cursor, but relative to the first line that is currently ...
1
vote
1answer
37 views

Map a key with a condition

LanguageToolCheck and LanguageToolClean are 2 commands used in vim-languageTool plugin. LanguageToolCheck command check and list out spelling errors of your text. And LanguageToolClear will clean the ...
1
vote
1answer
19 views

How to prevent cursor shift when using <C-O>{delete cmd} at the end of a line?

<C-w> deletes a (small-)word in insert mode, but I often want to delete the Word (to last whitespace) I've most recently typed. I tried inoremap <C-_> <C-o>dB which kind-of works -- ...
2
votes
1answer
47 views

Print bound autocmds to a file

I would like to print all of my current autocmds to a file so that I can grep through and do further analysis. From within vim, the list of autocmds can be found with :autocmd, but this prints to a ...
0
votes
1answer
21 views

Conversion of Ex command to mapping not always working

Here, I'm using a mapping from this post. Edited it to my liking like so: nnoremap <F3> :execute 'help' expand('<cWORD>')<CR> that works. Problem is, i wanted to add | only so that ...
1
vote
1answer
49 views

c-w suddenly not working to switch panes

sorry, I don’t know if this is a problem at the VIM level, terminal emulator or with KDE. I'm running vim-gtk3 in Debian Netrunner 20.01 which is KDE, and normally using Konsole, but also Terminator ...
1
vote
1answer
27 views

How can I have the delete key remove newline characters in normal mode (like delete in insert mode)?

My question is similar to this one but for the i_<Del>. In insert mode, if I type <Del> it removes the next character, including newlines. In normal mode, I have to type x if the cursor is ...
0
votes
1answer
27 views

switch toggle function - background

I'm trying to assign a key toggle to switch between dark or light background. I wrote this function: function ToggleBG() let l:bg='set background?' if l:bg==dark :set background=light ...
0
votes
1answer
39 views

Inside a mapping check if a variable is empty in vim

So i'm new to vim, and specially new to vimscript, and messing around i made the following code to get the name for a file and then create said file in a new buffer. I want a way to check if FileName_ ...
0
votes
1answer
38 views

how to map <C-q> to :q!

I'm trying to make Ctrl+Q quit vim automatically without saving. I thought this would be a very simple task but am stumped on why it's not working... I have the two following mappings at the end of ...
0
votes
1answer
42 views

How to map NerdTree commands?

I am used the vifm's hjkl key maps to navigate and open files. After installing NERDTree , I find it difficult as now the l key wont open file but will just move the pointer to the left( unlike in ...
1
vote
2answers
34 views

How to trigger rhs of a map?

Let's say I have a function like this: function! Foo() echom 'foo' endfunction And a map like this: nmap gf :<C-U>call Foo()<CR>0v$ When I type gf I see foo echoed and the current line ...
0
votes
0answers
22 views

How do plugins work when providing several custom keys in a plugin-specific window?

I'm referring to plugins like gundo and nerdtree, which offer a whole lot of key bindings only when the cursor is their window. Therefore, I was wandering if there's a common or preferred way to ...
0
votes
3answers
68 views

Does a plugin exist which allows moving (across) the windows and split them without having to press Ctrl+w before each action?

I'm kind of fine with moving across windows using Ctrl+w followed by (sometimes a counter and) h, j, k, l, p, t, b, and I'm also fine with the similar key combinations to split the windows or to move ...
0
votes
0answers
24 views

Disable mapping of `Man`

I have this mapping in my ~/.config/nvim/mappings.vim (it's included with source from the init.vim file): noremap <S-k> 5gk vnoremap <S-k> 5gk I went through a part of the vim manuals and ...
0
votes
1answer
22 views

why does vim insert a range when we press a number before pressing colon to go to command line mode?

I was trying to make a mapping to run a command that takes a count, something like the following: nnoremap gb :execute('buffer ' . v:count)<CR> When I run the mapping, I see the following error:...
1
vote
2answers
68 views

Compilation keybinds for different filetypes in vimrc

I am trying to create some keybind "scripts" for specified file types in my .vimrc. Example : au BufNewFile,BufRead *.cpp \ nnoremap <C-P> :!g++ % -o %.exe <CR> Ideally I ...
1
vote
1answer
35 views

How to jump back to current location after using key-binding `noremap <Leader>bA gg"*yG` without appending `<C-o><C-o>`?

I have created the following key-binding for copying all text in the buffer to the system clipboard: nnoremap <Leader>bA gg"*yG However, it moves the cursor, so I need to append <C-o>&...
3
votes
1answer
56 views

Does “:norm! @q” use mapped keys inside the macro?

The documentation for :norm[al][!] states that "mappings will not be used" when the ! is written. Consider the following setup commands: :nnoremap \c Chello<esc> :let @q = '\cIthis is ...
1
vote
3answers
52 views

How to make a shortcut to activate and deactivate multiple maps?

I know there are questions/answers to execute commands with a single shortcut, but in my case I can't think how to do multiple maps with a single shortcut in Insert Mode. In other words, what I want: ...
1
vote
0answers
30 views

Typing colon character in Insert mode undoing changes?

I am really curious as to why this is happening. I have this line in my .vimrc file (I am using WSL2 on windows and this line helps support copying from vim to the system clipboard): set clipboard=...
0
votes
1answer
35 views

G+zz simultaneously : Move to bottom and then move text to center?

How do i remap G to do what G and zz do simultaneously ? In other words, I would like to move to the bottom of the page and then have the text moved to the middle of the screen. I tried something like ...
-1
votes
1answer
101 views

How to compile a program and open the output in a vertical terminal window?

How can I write a command that does the following? With one mapping, compile and/or run a program based on the filetype (*.c, *.cpp, *.js, *.py, etc.), and open a vertical terminal window with the ...
4
votes
1answer
44 views

Delete and change key sequences are slow

When I use mapped key sequences which cause an immediate change in the file (e.g. cw, dw, D, C), i have a wait time of roughly 1 second. Other mappings which are just movement (e.g. 3w) or movement ...
0
votes
1answer
40 views

Command not working when mapped

I've mapped CTRL+Meta+n to :split | resize 15 | term. This command works when run from Vim, but when I put the command in my .vimrc, on Vim startup, I get the following error: zsh:1: parse error near '...
1
vote
1answer
140 views

How to map a key for a specific file

We can use the FileType autocommand event to create a customized key mapping for a specific type of file. For example, Spaceb could call different build tools for a Java file compared to a C++ file. I ...
4
votes
1answer
93 views

How to map `/` to `/\v` in Normal mode without moving the cursor?

I've created the following simple mapping in Normal mode, since I don't want to enter \v for "very magic" regex parsing, every time I use the / search command: nnoremap / /\v However, after ...
2
votes
1answer
30 views

Automatically indent at the right level when moving to a completely empty line

I have this binding in my .vimrc to trick autointent into actually populating the next line with real characters, so that if I hit enter, leave the line, and click back to it, I can already be at the ...
2
votes
1answer
20 views

Substitute: previous match with confirm

If I do a replace like this: :%s/May/June/gc afterward I keep hitting y or n as needed. But sometimes it hit n on accident and need to go back. I read that you can use N for this purpose, but it ...
2
votes
1answer
25 views

Recursive map to <leader> not working

I have a german keyboard and \ is hard to reach, so I added the following line to my config: map ß \ This works fine for simple leader commands, and I did not have to change my leader command in case ...
3
votes
1answer
47 views

pressing keys in visual line mode will leave this mode?

I find that in visual line mode, if I press a shortcut to print the current mode, it will print n instead of V. Is this the expected behavior? My mapping: xnoremap <a-j> :<c-u>echo mode()&...
1
vote
1answer
30 views

Is there a way to disable custom mappings while plugin functions are being executed in vim?

In my vimrc file, I use the following few lines to swap backtick and single-quote for convenience when I'm using marks: for first in ['', 'g', '[', ']'] for mode in ['n', 'x', 'o'] exe ...
1
vote
0answers
38 views

Remapping caps tock to ctrl and backspace while in vim only

I'm pretty new to vim, and I'm starting to discover it, and seeing how important the ctrl key is. I've seen that many remap the caps lock key to ctrl and escape at the same which seems really useful, ...
1
vote
0answers
30 views

When Pop Up menu is visible, <M-Key> no longer works

I use Alt plus h/j/k/l/w/e/ etc... to escape insert mode and move. e.g. <M-h> to escape insert mode and move left. However whenever the pop up menu is visible (pumvisible), then <M-h> ...
1
vote
1answer
78 views

How to toggle relative number for all opened windows?

I have this in my .vimrc: nnoremap <C-a> :set relativenumber!<cr> This toggles the relative number feature only in the current window. Is it possible to toggle it in all opened windows ...
1
vote
1answer
112 views

Vim LSP: change keybindings only if there is a LS attached to buffer

I do maintain there mappings in mv $vimrc: augroup LSP | au! autocmd FileType go,json,yaml nnoremap <silent> <buffer> <c-]> <cmd>lua vim.lsp.buf.declaration()<CR> autocmd ...
-2
votes
1answer
26 views

How can I make a single mapping take effect for both Normal mode, Insert mode, and Visual mode?

I want to disable the arrow keys in Normal mode, Insert mode, and Visual mode. To achive this, I've created 12 mappings (see below) - 4 mappings for each mode. Is there a way to achieve the same using ...

1
2 3 4 5
23