Stack Exchange Network

Stack Exchange network consists of 175 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
1answer
37 views

Why does my function sometimes respect whitespace?

I have a few functions to help with adding PHP docblock tags. Suppose a block like this: /** * Does a thing * * | */ Where | is my cursor position. I have a mapping to <localleader>@p, for ...
1
vote
1answer
16 views

How to do a conditional key mapping dynamically?

I know that I can do a conditional key mapping by map-expression: map [key] [condition] ? [foo] : [bar] But now my situation is somehow awkward. I want to map <C-h> to <C-w>h if I have ...
1
vote
1answer
19 views

How to have vnoremap call function once?

I'm trying to write a function + map that works on a visual selection. My function just prints out the marks right now: let g:count = 0 function! s:plink(...) abort let g:count = g:count + 1 ...
1
vote
1answer
19 views

bind mouse scroll up and down [duplicate]

I am trying to make it so, in the normal mode : some modifier + scroll upward triggers revert u some modifier + scroll downward triggers redo <C-R> Edit : I do mean mouse scroll some modifier ...
0
votes
1answer
31 views

map <expr> <F2> Cannot Check Focus Pane

How can a keypress dynamically change its behavior, depending upon which split pane has focus? (Specifically, whether the pane containing the cursor has another split pane to the right, or not.) map ...
0
votes
0answers
22 views

How to bind command+s to save file on macOS?

I have a Macbook. I want to save files by pressing command + s (this should happen if it is in insert mode or not, and I want it to go to non-insert mode after it is saved). How do I do this? ...
0
votes
1answer
20 views

Loading UTF keymap file

I need to load a particular keymap file that enables me to write underscore, special characters by typing :set keymap=iast where iast.vim is my keymap file This no longer works. Where should this ...
6
votes
2answers
237 views

Why does xnoremap mapping make visual selection slow?

I have made a mapping xnoremap j; <Esc> where j; puts you into normal mode if you're in visual mode. Having this mapping in my vimrc slows down visual selection. I can't figure out why this is ...
5
votes
1answer
385 views

What is the meaning of 'g'?

Note: this question has two sort of answers on StackOverflow but I thought perhaps a better answer would come from here, and, if not, at least it will be documented where it should be: What are the ...
1
vote
1answer
48 views

Terminal-mode not working with Ctrl-W

I am trying to work more with the built-in terminal for vim 8.1 and reading through the docs noticed it has two keybindings for entering the normal Terminal-mode. CTRL+\ CTRL+N as well as CTRL+W CTRL+...
3
votes
1answer
54 views

Exiting and entering insert mode again with key-binding

I'd like to experiment one of the tip by Drew Neil in his Vimcast, that is to "escape" regularly, so that it gives more granularity to the "undo" command. For example, I write one short sentence. ...
0
votes
1answer
22 views

Mappings with counts at the end without using loops?

Suppose you are trying to create a set of mappings such that pressing <C-t> followed by a number # would alternate to the respective tab at index #. I know that using a loop, I can do: " Map ...
0
votes
1answer
29 views

inoremap inserts unwanted tabs

I recently made myself custom insert mode keybindings to type faster in LaTeX. However, When I use them, Vim adds tabs that weren't part of the original keybinding. Example: Here is my inoremap: ...
0
votes
0answers
18 views

How to limit a key binding to a single key

I'm having trouble putting to words what I'm looking for, please mark as duplicate if appropriate I have a key binding that launches a search based on a fuzzy finder (specifically bindings to fzf and ...
1
vote
1answer
94 views

Visual feedback after executing mapping

I have the following mapping in my ~/.vimrc file: map <F3> my0v$"+y`y It works correctly, but I'd like some visual feedback or some other indication to show that I've pressed the key. Any ...
0
votes
1answer
45 views

Making Numpad numerical keys work in Vim using Ubuntu 18's terminal

In my current machine, I use Vim 8.1 in a Ubuntu 18's default terminal (Vim is running with TERM=xterm256-color, which is a requirement for me). Everything works perfectly, with the exception of the ...
1
vote
2answers
47 views

Disable filetype-specific `[`/`]` bindings like `[[` and `[m` [duplicate]

The default vim filetype commands create new bindings beginning with [ and ]. Is there a way to prevent them from doing so or control which bindings are created? I like using [ and ] to scroll up and ...
2
votes
1answer
65 views

Numpad characters don't work in keybindings mappings (but work in general)

For my terminal Vim 8.0, I have downloaded this plugin that makes changing font size on the fly easy: https://github.com/drmikehenry/vim-fontsize Following the instructions, here is how I decided to ...
2
votes
1answer
54 views

Unmapping the global mappings on a per-buffer basis

I have the following mapping in tnoremap <Esc> <C-\><C-n> init.conf to exit insert mode while in the terminal. In certain terminal buffers I would like to not have that global ...
0
votes
1answer
25 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. ...
0
votes
1answer
17 views

cmap macros not working as expected

I have been trying to make a macro to allow me to check in/out files via the vim command line. Currently what I have which "sort of" works is this: nmap :checkout :! cleartool checkout -nc % As you ...
0
votes
0answers
26 views

How do I make Ctrl+Shift+C to work with xnoremap?

I want to copy selected in Visual mode text with Ctrl+Shift+C key combination. I've added xnoremap <C-S-C> "+y to the end of my .vimrc file and it didn't work. I can confirm that it works ...
0
votes
1answer
50 views

How to enter insert mode on the next line without creating a new line?

If my cursor is at position * below, how can I enter insert mode at the beginning of the next line without creating a newline? o does what I want, except that it adds an additional unwanted line into ...
-2
votes
1answer
34 views

VIM and Carrot L (^L)?

I know when you see ^M you can insert it with Control+Enter; and ^I with Control+Tab. How do you generate a Form Feed ^L for use in :s and /?
1
vote
2answers
30 views

Why won't my mapping work <C-W><Right> z;

I'm going nuts trying to get this mapping to work. It's so simple yet doesn't work. with the mapping removed moves me off of nerd tree to the main window to it's right. Great. When I added the ...
0
votes
1answer
46 views

How can I enter visual mode in Ubuntu?

I know how to and I have used it for a long time on Mac. But in Ubuntu whenever I press Alt+V, it goes to the system calendar instead of entering visual mode I don't see it as a shortcut in Ubuntu ...
1
vote
2answers
35 views

How to copy all non-alphanumeric characters at the begining of the line to the next line?

I want to implement something similar to Org mode M-RET into neovim. In Org mode it creates new list item or heading depending on what line the point is on. I'm thinking of a mapping in neovim that ...
0
votes
1answer
60 views

set shortcut depending on filetype [duplicate]

For some markup and programming languages I use VIM and the usual procedure for me checking if my code works is :w and !<compile>. Depending on the filetype <compile> can be very different ...
0
votes
1answer
20 views

Why does `nnoremap K ko` not work on first line

Run vim --clean, :nnoremap K ko, and press K -> Nothing happens. Run vim --clean and press ko -> Vim enters insert mode on second line. Why? (I know about big-O, this is just out of curiousity, it ...
1
vote
0answers
19 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
22 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
28 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 ...
1
vote
1answer
21 views

Modify `iskeyword` for keyword-local completion only

Context Some time ago, I added the following line to ~/.vim/after/ftplugin/sh.vim to make working with parameter expansions easier: setlocal iskeyword+=$ This is nice to be able to e.g. ysiw" via ...
0
votes
1answer
31 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
21 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
57 views

mapping does not work even if I have set it up in config file

I am using Neovim on Windows using Cmder console emulator. I find that using [NUM]<Ctrl-6> to change to buffer [NUM] does not work on Windows. Following discussions here. I have set up a mapping:...
0
votes
1answer
38 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
36 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
90 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
43 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?
3
votes
1answer
304 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
122 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
25 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
48 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
34 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
39 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
55 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
35 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
59 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
842 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 ?