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

How to enable disabled movement keys in netrw?

Recently I started using and learning Vim. I turned off movement keys in my .vimrc file like this: noremap <Up> <NOP> noremap <Down> <NOP> noremap <Left> <NOP> ...
Igor R.'s user avatar
  • 113
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,195
1 vote
1 answer
396 views

Why does Vim interpret â as Alt-b in a mapping?

I have the following code in my vimrc: function! s:WordPos(dir) abort return a:dir ==# 'right' \ ? searchpos('\<', 'nz', line('.'))[1] \ : searchpos('\<', 'bn', line('.'))[1] ...
saginaw's user avatar
  • 6,706
1 vote
0 answers
236 views

Re-mapping Swedish letters

On a Swedish keyboard to the right of the keyboard one has: O, P, Å L, Ö, Ä [ and ] are extensively used by Vim, and hard to reach on my keyboard, so therefore I've mapped these to Ö and Ä in my ....
Max's user avatar
  • 153
0 votes
1 answer
201 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,640
0 votes
0 answers
38 views

How to use <Leader> in a normal command today?

The answer to the question with the same title doesn't seem to work for me. Not sure if the behavior has just changed overtime. To reproduce the issue, open Vim via vim -Nu filebelow.vim, where the ...
Enlico's user avatar
  • 2,172
0 votes
0 answers
71 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
  • 673
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
29 views

Why inoremapping <c-e> shadows <c-e> completion functionality?

Foreword Open a new file with vim -Nu NONE and insert the following text (| is to indicate the position of the cursor, in insert mode) longline lo| longerline Now hit Ctrl-XCtrl-N and the ...
Enlico's user avatar
  • 2,172
0 votes
3 answers
284 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
  • 138
0 votes
1 answer
387 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
  • 673
0 votes
1 answer
73 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
249 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
251 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
2 answers
399 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
  • 275
0 votes
2 answers
538 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
74 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
  • 199
0 votes
0 answers
82 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
1 answer
259 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
  • 199
-1 votes
1 answer
212 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