As of May 31, 2023, we have updated our Code of Conduct.

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
1 answer
139 views

Vim - edit last action before using (.)

Related to but not duplicate¹ of Bundling command sequences together for repeat (.). The point (.) command is really useful to redo the last action (insertion, replacement, etc.). Sometimes I find ...
Gabriel Devillers's user avatar
1 vote
1 answer
480 views

Is it possible to map one key to two commands, doing 2nd command only if first fails

I want to map the tab key to <c-w>w to switch windows when there is more than one window open. But if there is only one window but multiple tabs, I want it to detect that there is only one ...
domoremath's user avatar
1 vote
0 answers
48 views

mapleader & <Nop>: strange timeout behavior [duplicate]

I use <Space> as my leader key, with a short timeoutlen: let mapleader = ' ' set timeout timeoutlen=300 ttimeoutlen=5 Sometimes in normal mode, I hit <Space> then hesitate (maybe I ...
ivan's user avatar
  • 1,410
1 vote
1 answer
1k views

Vim mapping to auto-indent when entering inside braces, brackets etc

Which vim mapping/ plugin will help me in auto-indenting when entering inside braces, brackets or any similar characters. For example: Input {press enter} Output { cursor here } I want ...
Haris Muzaffar's user avatar
1 vote
1 answer
2k 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 ...
Shuzheng's user avatar
  • 1,175
0 votes
2 answers
493 views

Strangely slow key bindings

I defined these maps, to yank into system clipboard. noremap <leader>y "*y noremap <leader>Y "*Y noremap <leader>yy "*yy But when I use the first one (<leader>y), I find it ...
Violapterin's user avatar
0 votes
1 answer
54 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 = { ...
abbood's user avatar
  • 603
0 votes
2 answers
3k views

vim split horizontal resize shortcut

I can resize horizontal split windows by ctrl-w-shift-< and ctrl-w-shift->. I would like to have a shortcut for that. Close to the topic, recently I learned about the following maps: nnoremap &...
KcFnMi's user avatar
  • 133
0 votes
1 answer
42 views

How can I open MDN link in coc.css popup?

Sorry for my English. I installed coc-nvim plugin in my vim (gvim in windows) after that I insert CocInstall coc-css command for css snippets. In this picture I highlighted MDN Reference. How can I ...
mohamadi_arch's user avatar
0 votes
1 answer
215 views

search a pattern preceding cursor position, modify it and insert the modified string

I am writing a mapping to autocomplete tags Pattern: <.*?>, matches complete HTML tags only. The goal is to lookbehind and see if there exists a text like <html>. Mapping: inoremap <...
Haslo Vardos's user avatar
0 votes
1 answer
184 views

Automatically reindent lines filtered through formatprg

I have following xml file: <?xml version="1.0" encoding="UTF-8"?> <graph id="G" edgedefault="undirected"> <edge id="e6" source="n5" target="n4"> <data key="d1">1.1</...
Hotschke's user avatar
  • 4,510
0 votes
3 answers
166 views

Autocmd and key mapping with a conditional expression

I am currently running the following configuration for latex: NVim 0.9, Vmitex and Evince. I have been trying to map a key to open <current-file>.log, while the current-file is a name taken ...
Celdor's user avatar
  • 148
0 votes
1 answer
60 views

How can I detect which way vim is going into visual mode (from up to down or from down to up)?

This is related to better copy-paste multiple lines in visual mode where vim pastes after that visual chunk of code. I need to be able to detect which way vim is going into visual mode so that I can ...
Mega Bang's user avatar
  • 121
0 votes
1 answer
202 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 ...
AlpGlide3's user avatar
0 votes
1 answer
222 views

How to make a toggle function in .vimrc that toggles multiple configs of almost same type?

My .vimrc code autocmd FileType cpp nnoremap <F4> :RunWithFile autocmd FileType cpp nnoremap <F4> :RunWithFile ~/Downloads/ > output.txt && cat output.txt<s-left><s-...
Mega Bang's user avatar
  • 121
0 votes
0 answers
29 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 ...
abbood's user avatar
  • 603
0 votes
0 answers
54 views

Can I map a netrw command and its arguments to a key?

I have this map: nmap <buffer> <F3> mX So one I press <F3> it opens a prompt so I can type a command. Can I give the command also in the map above? something like: nmap <buffer&...
Ahmad's user avatar
  • 165
0 votes
2 answers
256 views

What's the best way to swap words?

I'm familiar with ddp to swap lines, but what if I want to swap words on the same line? I found a Reddit post that linked to this wiki page that suggests dawbP as a word swap method, but this seems ...
Yehuda's user avatar
  • 265
-1 votes
1 answer
204 views

How do I evenly distribute GVim windows started from a key-binding? [closed]

Code % http://vi.stackexchange.com/a/7627/2923 if has("win32") || has("win64") :vnoremap <Leader>gf :<C-U>'<,'>g/^/silent! exec "!START /B gnvim " . shellescape('<cfile>') &...
Léo Léopold Hertz 준영's user avatar

1 2 3 4
5