Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
33 views

How to get all remapped keys

Is there a way to get all remappings (.vimrc, plugins, etc) that were made by user relative to bare bone vim?
1
vote
0answers
17 views

Why does `<C-k> {char1} {char2}` work for digraphs but `{char1} <BS> {char2}?

Based on the documentation of digraphs-use (:help digraphs-use) it should be possible to do both <C-k> {char1} {char2} and {char1} <BS> {char2}, but the second one does nothing and <BS&...
0
votes
1answer
14 views

vim how to page down/up in another window

Context: There are 2 and only windows in vim. I want when I press F2, cursor remain in the same window, the other window behave like PgDnpressed. How to achieve that behavior? P.S. motivation: ...
1
vote
0answers
23 views

Pressing CTRL-U combination gives invalid arguments for function timer_stop?

I am not precisely able to reproduce the exact conditions under which this occurs, but sometimes, when I press CTRL+u, I get the errors below. I cannot even exit vim with CTRL+c or suspend. I haven't ...
0
votes
1answer
25 views

Make conditional imap to text being enclosed in certain characters

How can I create mappings that work only if the cursor is enclosed by certain characters? As an example, I want to map ja to \alpha if the cursor is enclosed by $$ or by \[\] so as to make This jar ...
0
votes
1answer
17 views

How to combine 2 actions for different mode into one mapping

I wonder is there any pipeline style combination key mapping in vimrc. For example: The command to open the NERDTree is :NERDTree and press capital B will open the bookmark list. How can I combine ...
0
votes
1answer
30 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</...
1
vote
1answer
30 views

Operator pending mode remaps not working

I'm trying to build a vimscript can be used with the Dvorak Simplified Layout. I.e., given that the keys on the keyboard plugged into the computer are laid out in the Dovark Simplified Layout (and the ...
2
votes
1answer
44 views

How do I execute normal commands from an autocmd?

I am trying to do some window management in VIM where I create certain windows such as two or three vertical splits with different sizes. At the moment, I only know how to change panes with <C-w&...
0
votes
1answer
34 views

Remap / to a another search function?

I there a way to remap / that trigger builtin search function of vim to another search fuzzy function and how to achieve that?
0
votes
0answers
16 views

Alt+key mappings don't work in Vim [duplicate]

I added the following lines to my vimrc: " Easy window switching (Alt-h instead of Ctrl-w-h, etc..) nnoremap <a-h> <c-w>h nnoremap <a-j> <c-w>j nnoremap <a-k> <c-w>...
3
votes
1answer
300 views

Is there a shortcut like <C-W>o that ignores the E445

In many cases I have one spare window which contains garbage and when I am in my main window, I'd like to close all other (with <C-W>o), but I am getting E445 for those that are not saved. Is ...
2
votes
2answers
101 views

How to light the Caps Lock LED when in insert mode (on GNU/Linux)?

On Xubuntu LTS, I already managed to remap CapsLock to Esc. However, now I discovered some Vim users are lighting the Scroll Lock LED, Caps Lock LED or even the entire keyboard to indicate that (g)...
0
votes
1answer
19 views

Remap Enter in command history edit window only

I currently have <Enter> mapped to :nohlsearch in normal mode. This allows me to leave search highlighting on for all new searches, but easily turn it off when it (soon after usually) becomes a ...
0
votes
2answers
30 views

Cannot remap F2 in vim (vim.gtk)

I'm using this setting: noremap <F2> :tabnext<CR> inoremap <F2> :tabnext<CR> But it just moves cursor down one line like <C-j> does... How can I map F2 to moving to ...
1
vote
1answer
29 views

Beep upon using a mapping

Well, I try to use the following convention. ± (as unused key) is used for increase search where / is used for regular search. The implementation: set noincsearch nmap ± <esc>:set ...
0
votes
1answer
38 views

How to make this work in insert/edit mode too?

I want to switch between tabs, but this works only in command mode. Is it possible to make this work in edit (insert?) mode too? noremap <C-k> :tabprevious<CR> noremap <C-l> :...
0
votes
1answer
50 views

vim: mapping several commands to one shortcut

This does NOT work with files opened in several tabs (put in ~/.vimrc obviously): noremap <F5> :wa<CR> <bar> :!global_stack_build_run.sh<CR> Neither it works when I use | ...
0
votes
0answers
29 views

Mapping ESC key to toggle command/insert modes

I want to do wht is asked here: https://stackoverflow.com/questions/43693204/making-esc-key-toggle-command-insert-modes-in-vim However, if I follow the answer there, every time I run vim it starts ...
2
votes
2answers
55 views

Create a custom keybind for a notes file on vim

I want to create a simple notes file and manager it with vim. The system is really easy (plain text rules): - [ ] new entry - [x] done entry Well, in my .vimrc I only have the keybind for add new ...
8
votes
3answers
829 views

Open man section 3

I'm using Vim to develop C on Linux. When I press K in order to open man page for the underlying word, I don't have control on which man section is opened. Is there a way to specify that somewhere ?
0
votes
0answers
35 views

gvim and Linux - <C-c> not mapped, yet acts

gVim under Linux Ubuntu 18.04 LTS Bionic Beaver seams to have <C-c> (Ctrl-C) mapped to cancel the visual selection, despite not being mapped at all. :map <C-c> No mapping found To ...
1
vote
1answer
40 views

Check if key is already bound in vimscript / Map key only if not mapped already

I'm wondering if it is possible to check in vimscript if a key (or key combination) is already bound? I know about the :map command which lets me see visually which keys are bound to what actions, ...
0
votes
1answer
44 views

Mapping backspace to delete previous word

I would think this would work to make backspace delete the entire previous word in insert mode: imap <BS> <C-W> but it doesn't. Tried in vim 8.0 and neovim 0.2.2 iterm2 if that matters. ...
2
votes
1answer
136 views

Using Pandoc with vim keybindings

I am trying to define a keymapping in vimrc to compile my markdown file with Pandoc. So I am using this: autocmd FileType markdown nmap <F9> :!pandoc % -o %:r.pdf <cr> But, in markdown ...
0
votes
1answer
42 views

What's the Vim equivalent of Emacs's other-window command?

What's the Vim equivalent of Emacs's other-window command?
1
vote
0answers
29 views

Odd langmap behavior with multi-key bindings

I'm getting some odd behavior from langmap. With set langmap=hjki;ihjk inoremap k u works as expected, inoremap jk u maps to ji, inoremap kik u maps to khi. When I say 'maps' I mean that's ...
0
votes
2answers
52 views

How to disable insert-mode popup-menu mappings?

I'd like to disable the popup menu scroll mappings <C-n> and <C-p>, so that I can use <C-j> and <C-k> instead. However, when I enter imap <C-p> <Nop> imap <C-n&...
0
votes
1answer
24 views

How to map a call to a system function using the current filename?

I've been using vim for a little while and I'm doing some LaTeX with it, using Tectonic as the engine. What I was doing to generate the pdf (without leaving the editor) :call system("tectonic main....
0
votes
1answer
17 views

How to map <A-h> without opening gvim help?

I would like to create a custom mapping for the <A-h>, i.e. Alt+h key combination. nnoremap <silent> <A-h> … However unlike <A-l>, this particular key combination opens the ...
2
votes
1answer
32 views

Remaping leader with :execute cannot run two commands at once

I have following command: map <Leader>ntd :execute ":tabe! ". g:path ."l_todo.txt"<CR><ESC> :execute ":vsplit! ".g:path ."u_todo.txt"<CR> Both tabe! and vsplit! commands ...
2
votes
1answer
150 views

How to find why esc doesn't work right away in visual mode?

When I press <Esc> in visual mode, I don't immediately return to normal mode (the selection persists). I think that is because I have a mapping defined in visual mode shat starts from <Esc>...
1
vote
0answers
23 views

How could I map Alt on linux [duplicate]

I am trying to map the key Alt+j in vimrc to adjust the height of the window: tnoremap <A-j> <C-\><C-n>5<C-w>-i nnoremap <A-j> <C-\><C-n>5<C-w>- But ...
1
vote
0answers
31 views

Cannot map <C-j> sequence in vim [duplicate]

I used to be able to navigate vim splits using nnoremap <C-j> <C-w>j nnoremap <C-k> <C-w>k nnoremap <C-l> <C-w>l nnoremap <C-h> <C-w>h but now I ...
5
votes
1answer
107 views

How to break a long mapping line into several short lines in vimrc mapping

I have a very long vimrc mapping to deal with for example nnoremap <space>e :exe "!tmux send-keys -t.- 'cd $TEST' Enter"<Cr> :exe "!tmux send-keys -t.- 'source $TEST_NT/bin/activate' ...
0
votes
1answer
29 views

How to get the number used before a command as an argument?

How can I write a function that can be invoked in normal mode with regular keystrokes like {myNumber}<Leader>p, and prints {myNumber} into the current buffer. For example: here's a command to ...
1
vote
1answer
19 views

custom mapping not working with yank command

This can be super simple stuff but i am not able to figure it out, i have to mappings in my config file nnoremap gh ^ nnoremap gl g_ These mappings work just fine and behave as expected when i use ...
3
votes
1answer
74 views

Some function keys switch cases of letters under and after the cursor

Foreword I use UltiSnips and have the following definitions in my .vimrc file let g:UltiSnipsExpandTrigger="<F8>" let g:UltiSnipsJumpForwardTrigger="<F8>" let g:...
2
votes
2answers
50 views

Can I substitute the value of enter/return?

I am looking to insert list items to-buy > apple > milk > but I would like to insert a constant string (" > ") on each newline is there a way to do this?
1
vote
0answers
19 views

inoremap ctrl h to move left in insert mode not work (it delete the left character exactly) [duplicate]

my mapping is .vimrc inoremap <C-h> <left> inoremap <c-l> <right> inoremap <c-j> <up> inoremap <c-k> <down> But, if I press ctrl+h in insert mode, ...
0
votes
0answers
24 views

Map r without entering replace after command is executed

I am using IdeaVim to remap the following, the Run command is a built in command in IntelliJ IDEs: map <leader>r :action Run<CR> However, this enters me into replace mode in the editor ...
1
vote
2answers
56 views

separating folds with constant amount of newlines

Is there a succinct way to separate folds, open or closed, by the same number of newlines throughout the buffer? I'm using fold by indent. The goal is two visible blank lines between each fold (...
1
vote
0answers
67 views

How to map <C-Space> to ESC

I am using nnoremap <C-Space> i inoremap <C-Space> <Esc> to map to Esc. It works for all file with any extension but it doesn't work for the files with ".tex" extension ( I am ...
1
vote
1answer
49 views

How to make abbrev ignore my custom keybindings?

For example, I've mapped inoremap ( (), and if I do iabbrev if if(then it will expand to if(then) instead of if()then (the inoremap is executed after the iabbrev). Is it possible to make iabbrev ...
1
vote
0answers
24 views

How can I prevent <CR> from moving the cursor downward? [duplicate]

In the vim help doc, it says: *CTRL-M* *<CR>* [count] lines downward, on the first non-blank character |linewise|. That is, in the normal mode, <CR> has the same ...
0
votes
1answer
81 views

Swap `j` and `gj` [duplicate]

I use vim a lot to edit tex files. When I have lines spanning multiple display lines, most of the time I want to navigate through them with gj not j (i.e. according to displayed lines, not physical ...
1
vote
1answer
49 views

how to skip commented lines when navigating?

When navigating in normal mode by j or k, I want to skip commented lines. Is it possible? Is there a vimscript snippet for that?
0
votes
1answer
33 views

Quick find and replace a fixed placeholder

I have a config file that have placeholder PKG, in workflow, I need to replace this PKG with a string but typing :%s/blah/blah/g cost time. I need a quick map key that asks for a string to replace ...
0
votes
0answers
34 views

what's wrong with this map?

:nnoremap 00 $ What I expected is to make the cursor to move to the end of the current line after a double hitting of "0". But actually, it will make the cursor go to the next line, why?
0
votes
1answer
23 views

Why doesn't the cursor return to its original position in this command to create a new line?

I added the following command to my .vimrc, which is designed to insert a blank line below the cursor nnoremap <leader>o mzo<esc>`z The sequence of this command is mark the cursor ...