Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 1311

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.

3 votes
Accepted

imap <expr> call multiple functions

Try this: imap <CR> <C-O>:call Func1() \| call Func2() \| call Func3()<CR> The <expr> argument for mappings is if you want the mapping to execute the return value of the expression, which doesn't mak …
Heptite's user avatar
  • 1,219
2 votes

In command-line mode, how to avoid delete key erasing last character?

Try this: :cnoremap <expr> <del> strlen(getcmdline()) == getcmdpos() - 1 ? '' : "\<del>" This binds the delete key on the :-command line to running an expression and executing the keystrokes the expr …
Heptite's user avatar
  • 1,219
1 vote

Reduce lag in mappings that frequently switch between normal and insert mode

It would help if you would give a more concrete example of what you need to do that takes a long time. For me your example is instantaneous, even if I make it several times as long. However, to answer …
Heptite's user avatar
  • 1,219
1 vote
Accepted

How to set a keybinding in Insert mode

To my knowledge nobody says this is "best practice," and I would advise against it. If you really want to do this, though, try this mapping: :inoremap <CR> <Esc>o There's a wealth of information in " …
Heptite's user avatar
  • 1,219
1 vote

How to use function argument in a mapping?

Mappings always execute in the global context. That is, they don't "remember" that they were defined inside a function, so they can't access a: variables directly. As for the E730: Using a List as a S …
Heptite's user avatar
  • 1,219
0 votes

Toggle Vim Terminal with Mapping like VS Code

Since Vim doesn't actually recognize the <C-~> key sequence, you will have to choose another sequence. For example, if you wanted it to be <M-~> you could do: nnoremap <M-~> :terminal<CR> vnoremap <M- …
Heptite's user avatar
  • 1,219