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
4 answers
704 views

Is it possible to type a single quote/paren/etc. when you have Vim mapped to always print two?

Recently I have been experimenting with ways to improve Vim's efficiently with keyboard mappings, and I have these mapped in order to make Vim behave like a graphical IDE: inoremap " ""&...
0 votes
2 answers
1k views

How to navigate in auto completion menu, when arrows are disabled in .vimrc

Reason for my question: It's not the first time I have cancelled my arrow keys in vim, and the improvments in my typing is again tremendous. I wish to keep arrow keys non effective inside vim. ...
2 votes
2 answers
267 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 ...
0 votes
4 answers
52 views

Mapping: Automatic placement of cursor into (<>) when I press <space> twice

For my Latex setup in VIM I want to map different text modules where the cursor is automatic placed in between (<>), when I press twice <space> and when the cursor arrives there the (<&...
1 vote
1 answer
209 views

Whats the difference between k and C-p?

Is there any difference between the behaviour of C-p and k? The seam to be doing the same thing; moving up a line
0 votes
1 answer
29 views

Make operator that doesn't change gv

I'm trying to redefine my inner and outer line text objects so that they don't change gv. First I had onoremap <silent> il :<C-u>normal! $v^<CR> I changed it based on Using visual ...
1 vote
1 answer
91 views

Is there any difference in mapping commands with <Cmd> or with :?

As per title, is there any difference in mapping commands when using <Cmd> or : ? For example, is there any difference between the two following mappings? nnoremap <leader>c :close<cr&...
0 votes
1 answer
58 views

Opening files from vim-fugitive's :GcLog

When I'm in :GcLog how do I go to the source file? The documentation shows: <CR> Open the file or |fugitive-object| under the cursor. But, I've only been able to open up &...
2 votes
1 answer
216 views

Cannot remap Control Backspace and Control Shift Z in Windows

What's up with Control Backspace, and Control Shift Z for the Windows cmd terminal? I cannot seem to remap them. All the former does in Insert Mode is type Î, and then make the "z" letter ...
0 votes
0 answers
31 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 ...
132 votes
8 answers
179k views

How can I easily move a line?

What is the command (or shortcut) to move a line up or down in vim? My current workflow is to yank (copy) the line and than delete that line and than to put (paste) that line.
2 votes
0 answers
29 views

Consecutive pressing mapped function keys emits unwanted "^[[I" in input buffer in Ubuntu 22.04

OS: Ubuntu 22.04.2 (ubuntu-22.04.2-desktop-amd64.iso) Vim: vim-gtk3 (8.2.3995-1ubuntu2.7 amd64) vimrc: nnoremap <F7> : ! g++ % -o %< <CR> nnoremap <F8> : ! time ./%< <CR> ...
0 votes
1 answer
28 views

How to change the behaviour of <c-w>v?

Say that I have only one window on the screen. When I hit <c-w>v I got a vertical split and the cursor jumps in the window on the right. Instead, I want the cursor to stay in the left window ...
2 votes
1 answer
257 views

<s-f10> cannot be mapped in neovim

At least not on my mac. it works fine in vim. is this simply an error in nvim?
0 votes
1 answer
68 views

Shortcut to open definition of variable in a vertical split with Neovim mapping

This is a follow up question to this post where I would jump to the definition of a variable in a vertical split for ctags. I’m currently using an lsp language server like so: local bufopts = { ...
0 votes
1 answer
19 views

Change " to `` or '' depending on whether it's typed after a space or non-space

The usecase is LaTeX, which I write using VimTeX. To make double quoted words one would write ``words''. However, I'm much more used, from many other contexts (both prose and code), to type " for ...
4 votes
1 answer
64 views

Trouble defining <S-> function keys and mapping them within gnome terminal

Vim by default maps <F1> to bring up help. I'd like to map <S-F1> (shift + F1) to close the help using the :helpclose command. I'm having trouble with this simple task, running inside a ...
1 vote
1 answer
21 views

How to use tmap with <Plug>?

I am wondering how shall I use tmap along with <Plug>. Here is a snippet of the context where I am using it: vim9script import autoload "../lib/foo.vim" noremap <unique> <...
0 votes
1 answer
780 views

super key not working in neovim on linux

I'm trying to create a shortcut, but I can't get vim to recognize my super key. I tried the following combinations: lvim.keys.normal_mode["<A-h>"] = ":BufferLineCyclePrev<cr>...
-1 votes
1 answer
22 views

noremap not working in modeline

For a specific file I need some dedicate configurations. So, I put this in the top of the file: % vim: noremap a <ESC>l<ESC> I get the following error message: "test" 2L, 30B ...
0 votes
1 answer
31 views

Why doesn't my cmdwin remapping work?

I'm trying to unmap the normal mode open cmdline-window bindings: nnoremap q: <NOP> nnoremap q? <NOP> nnoremap q/ <NOP> Do not have any effect, even though :verbose map q: shows it'...
3 votes
2 answers
616 views

Why am I missing a quote in this remap?

nnoremap <leader><cr> :execute "normal! i\\\<cr>\<esc>" When I run that, it says: E114: Missing quote: "normal! i\\\ E15: Invalid expression: "normal! i\\\ What's wrong with ...
0 votes
2 answers
53 views

Set command-line local variable

How can I set a variable that only the current command line sees? So that :let s:one = 1 | echo s:one prints 1 but running two commands :let s:one = 1 :echo s:one errors E121: Undefined variable: s:...
0 votes
1 answer
220 views

Unable to map C-/ in visual mode with Neovim and kitty

I am unable to map <C-/> in Neovim. In particular, it does not work for visual mode. I have created the mappings below: vim.keymap.set('i', '<C-/>', '<Esc>:Commentary<CR>') ...
1 vote
1 answer
30 views

Remapping a Family of Shortcuts

I would like to remap/create the family of shortcuts starting with d into a version that does not yank it to any register. Is there a programmatic way of doing this or do I have to do it manually? For ...
1 vote
2 answers
62 views

Change level of manual fold?

How do you increase or decrease the level of the current, manual fold? And what is the keyboard shortcut to do it? I cannot see anything in the manual about this. Foldlevel seems to concern not the ...
26 votes
1 answer
3k views

What is the difference between "mapped key sequences" and "key codes"? (timeoutlen v ttimeoutlen)

The vim manual says we can use timeoutlen to specify the timeout length of mapped key sequences and can use ttimeoutlen to specify the timeout length of key codes: A useful setting would be :set ...
1 vote
2 answers
97 views

How do I remap `%` with `K` in visual and normal mode in `init.vim` (and vice-versa)?

I have the following in my init.vim: nnoremap K \% " Swap K with % in [n]ormal mode vnoremap K \% " Swap K with % in [v]isual mode xnoremap K \% " ...
1 vote
1 answer
99 views

Using VSCode key bindings inside Vim

Is there any way to use VS Code key bindings in Vim? I really like the VSCode linux key bindings, but would like to give a try to Vim without losing productivity.
8 votes
1 answer
4k views

Is it possible to map <C-S-Space> in neovim?

I usually use gvim and it understands the mapping similar to inoremap <C-Space> <C-n> inoremap <C-S-Space> <C-p> Now I'm testing nvim and I can use the Ctrl+Space. But Ctrl+...
6 votes
3 answers
682 views

Gvim <C-]> not working with azerty keyboard

I have a windows 7 machine with an azerty keyboard running gVim 7.4 My problem is that <C-]> simply does nothing: When I'm in an help page I can't follow the tags links. As I have an azerty ...
0 votes
1 answer
35 views

Passing arguments to function in remapping

I have the following solution in my .vimrc that allows me to wrap text with certain delimiters that works function! Wrap(action, delim) let l:delims = {'(': ')', '[': ']', '{': '}', '"': '&...
1 vote
1 answer
981 views

Mapping doesn't work for tabs

I have several files opened in tabs in Vim. I want to switch between tabs, so I use Ctrl+left to move left (previous) and for next also. But my mapping doesn't work. :map <C-Left> :tabprevious&...
0 votes
1 answer
74 views

Why does this key-mapping in vi not work correctly?

I'm just learning how to use the vi editor, and was trying to make use of the following map command in my .exrc file: map K 0I^I^[j0O^I^[j0 That is what appeared when I created the map in ex mode and ...
1 vote
1 answer
25 views

verbose map shows the mapping but not the source file it is defined

I use Neovim 0.8.3 with LazyVim setup. In my setup, line movement commands such as j and k move cursor from one displayed line to another displayed line. I checked the mapping of these letters with ...
0 votes
1 answer
26 views

How to map <C-z> to act like <C-y> in completion menu?

My keyboard has z and y switched compared to US keyboards, which makes pressing C-y for completions pretty awkward. I tried adding imap <expr> <C-z> pumvisible() ? "<C-y>" :...
109 votes
9 answers
238k views

What is the command for "Select All" in Vim and VsVim?

How do I select all the content of a file in Vim and VsVim? Like in other editors Ctrl-A does the job for select all.
1 vote
1 answer
58 views

change behaviour of > / < and >> / << to insert / remove only leading tabs

i want > / < and >> / << to simply insert and remove tab characters at the beginning of the line. variant: i would even prefer to have> / < and >>/ << insert / ...
0 votes
0 answers
18 views

Shortcut keys sometimes type commands into the buffer for the file I am editing

I'm using gvim with the included mswin.vim keybindings, so Ctrl+S AKA C-S will save the buffer. It provides these mappings. " Use CTRL-S for saving, also in Insert mode (<C-O> doesn't work ...
1 vote
1 answer
46 views

Map to for loop

How can I make a mapping that includes a for-loop? xnoremap <leader>y :for i in [1, 2, 3, 4] | echo i | endfor errors E121: Undefined variable: i and xnoremap <leader>y :for line in ...
0 votes
1 answer
222 views

How to run current python file in floating terminal? Using neovim and NvChad

FYI noob here. I want to run current file in floating terminal. I'm using NvChad and when I execute ALT+i I get the following: I already played with some key binds, but I haven't achieved what I need....
3 votes
1 answer
2k views

Make YouCompleteMe open definition in vertical split even if buffer is not saved

There is something I cannot do with YouCompleteMe that I could do when just using tags to navigate to a definition or declaration. The desired behaviour is (taking into account that , is my leader ...
1 vote
1 answer
28 views

How to remap F16 to F19 on macOS?

So far I managed to remap F1 to F15, but I can't remap F16 to F19. When I am in insert mode, nothing happens. What is weird is that in the terminal, I can see something is intercepted, for example, if ...
1 vote
1 answer
95 views

How to map a number followed by another key?

[I have read How to debug a mapping? and although that is a great starting point I am still clueless why this does not work.] I want 2* to search for the next occurence of the previous word in ...
-1 votes
2 answers
36 views

Mapping key sequence begining with underscore (e.g. _x) cannot be used, why?

For a special application I am invoking vim with following mapping: vim -u /root/.vimrc ... -c "nnoremap _z \"zyyq:" If I map to another key sequence, e.g. <F5>, all works fine. ...
1 vote
1 answer
296 views

Jump from tag-to-tag in xml?

I'm using emmet-vim which says that it can work in xml files but I can't seem to navigate between tags. Say I have this structure: <dependency> <groupId>com.google</groupId> &...
0 votes
1 answer
52 views

How to map Vim command and CTRL-W R together?

Problem I am trying to map the F10 key with theterminal bash % command so I can execute the current open file with bash in a split pane setup (this functions works). The problem is when I try to add ...
0 votes
1 answer
31 views

Remap p if no register is specified

To stop pasting over a selection from yanking that selection, I would like to remap p so that it doesn't yank the just-rewritten selection: vim.keymap.set("x", "p", [["_dP]]) ...
1 vote
1 answer
76 views

Find git root directory in key mapping

I would like to find the git root directory and use it as argument for :FZF in a key mapping like this: nnoremap <Leader>eg :FZF `git rev-parse --show-toplevel`<CR> Unfortunately, this ...
0 votes
1 answer
45 views

vnoremap to sort highlighted lines by length not working as expected

I found a command that would sort highlighted lines by their length and wanted to make a mapping for it so that I could avoid typing it every time. vnoremap ,s :<C-U>'<,'> ! awk '{ print ...

1
2 3 4 5
30