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
0
votes
0answers
6 views

how to map <C-,> and <C-.> in neovim

I want to use <C-,> and <C-.> to switch between multiple tables, how to do it? I found that setting it like this doesn't have any effect
0
votes
2answers
25 views

Toggle Vim Terminal with Mapping like VS Code

I am trying to implement toggling of the Vim terminal like VS Code by doing <C-~>. But am not sure how to go about it. I find executing :term to open and to close tedious. I figured having a ...
1
vote
2answers
35 views

<cmd> key code?

An article on key-mapping uses <Cmd> where I would expect : nnoremap [q <Cmd>cprev<CR> nnoremap ]q <Cmd>cnext<CR> nnoremap [t <Cmd>tprev<CR> nnoremap ]t <...
1
vote
1answer
15 views

unbind all keybindings starting with [ and ]

I put this: noremap [ { noremap ] } in my .vimrc. However, since there are other keybindings starting with [ and ], vim waits for the next keybinding before executing my desired command. After ...
1
vote
1answer
14 views

Buffer specific remap of a global map to a plugin command

I have this in my .vimrc as global for gf: map gf :edit <cfile><cr> from the help on gf, but I want to remap gf in markdown files for a plugin command with the following: autocmd FileType ...
0
votes
1answer
17 views

Command to go to Normal-mode and Visual-mode (or exiting insert-mode) - pressing ESC without the escape-key

I'm working on a server, that I can only SSH into via a browser. In there, I have to edit some files. The problem is, that let's say I go to INSERT MODE and write some text. If I then want to go back ...
0
votes
0answers
15 views

How to map a key to toggle keymap function?

I would like to map a function key to turn on a specific keyboard layout, like set keymap=x, and toggle it on second keypress as in CTRL+Shift+^. How to achieve this?
1
vote
0answers
15 views

Trouble remapping netrw

I'm using a bépo keyboard, kind of like a dvorak keyboard but for french. One of the most important aspect of using a bépo layout with vim is that I have to hjkl <-> ctsr. To do so I have this ...
2
votes
0answers
28 views

Why do <S-Left> and some other keys not work in vim under tmux?

I know at least about <S-Left>, <S-Right>, <C-Left>, <C-Rigth>. But I guess there are others. I'm mostly interested in the why. Because knowing a reason often makes finding a ...
0
votes
2answers
24 views

How to execute arbitrary key sequence {count} times

The problem I wish to solve, first of all, is when you want do do the same editing on multiple lines, but they are not aligned so you can't use Ctrl + V, maybe the lines are not even adjacent. In ...
1
vote
1answer
63 views

How to move the word under the cursor to the left or right in insert mode without plugins

I'm really new to vim and I was searching for moving my single word or a line to move 'up' 'down' 'left' 'right' in insert mode I was able to achieve the up a line or block in visual mode and down a ...
1
vote
1answer
61 views

Mapping arbitrary unicode characters?

I want to create a mapping that is ctrl+[some obscure unicode character], how can I do this for terminal vim using the actual unicode code? Backstory: I'm trying to work around i3wm, where ctrl+hjkl ...
0
votes
1answer
20 views

'd$' or 'd^' does not work when '$' or '^' is mapped to '<C-l>' or '<C-h>'

I'm trying to change the key mappings: $ => <C-l> ^ => <C-h> d$ or d^ does what they have to do (e.g., d^ deletes from the current cursor to the beginning of the first char in the ...
0
votes
1answer
28 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 ...
2
votes
1answer
59 views

better copy-paste multiple lines in visual mode where vim pastes after that visual chunk of code

I want to select multiple lines in vim, copy them, and paste after that chunk of code (with cursor at the beginning). yp doesn't work because in visual chunk of code, vim pastes after the 1st line of ...
3
votes
0answers
141 views

iTerm2 and VI key mappings

I am trying to use a few keys and key combinations with VI (VIM - Vi IMproved 8.2) running in iTerm2 3.4.15 with zsh on macOS Monterey 12.1 on the Apple M1 Max chip. So far, I tried to set ...
1
vote
1answer
13 views

how to overwrite netwr default file handler keybinding and still use it?

I'd like to overwrite netrw plugin's default file handler keybinding gx but still be able to use it: " should remap netrw's gx to gX xnoremap gX gx " map gx to something else xmap gx :...
0
votes
1answer
22 views

Does Vim (NeoVim) remove mappings when sourcing vimrc?

I was editing my vimrc, and decided to remove a mapping based on some information I found on <cr>. So I deleted the mapping and called my :SourceVimrc command (command SourceVimrc source $...
1
vote
1answer
38 views

Mapping repeat last command

Apologies I am probably expressing myself very badly, that's also why 1 hour searching hasn't yielded the result I wanted yet... Assume I want to replace true with false in a buffer. :s/true/false Now,...
1
vote
3answers
166 views

How supply range to normal mode key-binding?

I've created a mapping to a function that accepts a range. Like this: command! -range Test call TestFunc(<range>,<line1>,<line2>) nnoremap <leader>t :Test<CR> How do I ...
0
votes
1answer
34 views

Mapping a key to escape moves to the next line

I have recently started using neovim and am having a problem. I have mapped <leader>m to <esc>. It seems to be working fine but has a small problem. It moves to the next line after getting ...
0
votes
1answer
29 views

Meta-Model: Shrinking In Correct Direction

This questions sounds ridicolous, but is there any (mental?!) aid for my struggle when resizing windows? Since the earliest days of my vi/m usage, I have struggle shrinking windows in the correct ...
3
votes
1answer
38 views

Trouble defining <S-> function keys and mapping them within gnome terminal

Vim by default maps <F1> to bring up help. I'd like to map <S-F1> (shift + F1) to close the help using the :helpclose command. I'm having trouble with this simple task, running inside a ...
1
vote
1answer
21 views

`:verbose map` doesn't list origin of some mappings

I'm trying to debug a mapping of the key Y. :verbose map gives the following snippet: ... noxW * repmo#SelfKey('W', 'B') Last set from ~/.dotfiles/vim/.config/vim/vimrc line 446 n Y ...
0
votes
1answer
20 views

How to prevent inoremap mapping from being "run" inside iabbrev? [duplicate]

I have the following abbreviation: iabbrev .d. [[2021-12-02]] I also have the following remap: inoremap [[ [[]]<Left><Left> The problem is, whenever I type .d. to get the date string, I ...
1
vote
1answer
76 views

Silently run two commands mapped by nnoremap in vim

I have this sort of command in my vim settings which read the output of some external command (here is date) and then run another external app. My problem is I want to run it without leaving current ...
4
votes
2answers
178 views

Double Press Override for 0 Key

My .vimrc remaps 0 to ^ in normal and visual+search modes. :nmap 0 ^ :vmap 0 ^ Ideally, I would like 00 to go to the true beginning of the line (i.e., what 0 does by default). Is this possible in a ....
0
votes
1answer
23 views

How to expand a value to place it in the ex command?

The goal is to create a mapping that will: create a mapping for the user --> remap does the trick that gets the current expression under the cursor --> expand('<cexpr>') will do the trick ...
6
votes
2answers
2k views

Ctrl-A and Ctrl-X doing the opposite of what they should

I had the following piece of Markdown text that I wanted to edit: * 2-6 for a moka pot * 7-10 for a drip machine * 5-12 for a pour-over When I had the cursor over the number 6 in the first bullet ...
0
votes
1answer
44 views

Can I make old Vim treat Alt key mappings <M-..> as Esc-prefixed, like Neovim and other CLI software(e.g. bash) do?

Do Vim users use Alt key for mappings? If yes, how exactly? As it is known, there are 2 common ways of handling Alt key in CLI software: either <Esc>-prefix or 8-bit. It seems like Vim chooses ...
0
votes
1answer
48 views

Key mapping for converting `((` to `\left( | \right)`

I would like to have something in .vimrc where when I type (( in insert mode, it automatically converts that into \left( | \right) with the cursor position at | in insert mode. Any ideas? I also would ...
1
vote
2answers
25 views

Insert mode remap to insert an underscore

I am starting to have issues with my pinky finger. I tend to write variables and functions using underscores as in my_variable. I would like to find a way to avoid having to press "shift + -"...
0
votes
0answers
24 views

Is is possible to include other behaviour in a keymapping which would normally invoke a <Plug>?

I am working with a plugin which exposes mappings via <Plug>. For example, let's say it has a mapping for <Plug>XYZCommand. Then, I can put the following in my ~/.vimrc: nmap a <Plug>...
0
votes
1answer
38 views

How to map a surround command?

I'm trying to map commands that are used with the vim surround plugin. Using vim surround you can type ysiW], for example, while in normal mode and it will surround the word at the cursor with ...
1
vote
3answers
69 views

How to deal with two vim plugins having the same mapping?

I have two plugins (todo.txt-vim and vim-buffergator) that both map the <localleader>b command (for .txt files at least). One plugin ended up dominating the other. I solved this by removing the ...
1
vote
1answer
42 views

How can I create a shortcut that saves the file and executes a sequence of shell commands?

I know that I can create shortcuts on a vimrc file like the following: :map <C-W> :w<CR> However, let's say I have some different commands that I can execute on my shell: notify-send &...
0
votes
1answer
13 views

How can I leave completion mode keeping the completion result in a binding when there's no popup?

Currently: I have some key binding A → ^X^O (in insert mode) to omni-complete something I have some key binding B → ^Ogj to temporarily do something in normal mode (in this case, move down a display ...
0
votes
0answers
29 views

Mapping Esc makes vim open in REPLACE mode [duplicate]

I've enabled hlsearch to highlight text after searching, $ grep hlsearch ~/.vimrc set hlsearch and now I want to clear the highlight, which I can do with :noh. I saw that I can assign this to esc key ...
1
vote
1answer
41 views

To toggle statusline colors when switching modes. Problem with C-C

I use the following code to have different statusline colors for Normal and Insert modes: highlight statusLine ctermfg=black ctermbg=red guifg=red guibg=black autocmd ...
0
votes
1answer
40 views

Is there a way to navigate windows without CTRL-W + ... ie. from the command prompt?

I want to reclaim CTRL-W for closing my terminal tab to get the same behaviour as in Firefox and other programs. Is there a command I can run to avoid having to press CTRL-W to navigate windows in vim ...
0
votes
1answer
29 views

Dump output with command line in vim with placeholder

I use :enew|pu=execute('scriptnames') for dumping output into a buffer. How do I write a mapping with this command line? For example, I press <F6> and it auto write the command line and jump to ...
1
vote
2answers
48 views

jedi-vim prevents mapping [[ to * and ]] to #

jedi-vim appears to prevent mapping [[ to # and ]] to * mapping does not alter behaviour produced by [[ or ]] in .py files when jedi-vim in bundle folder (and does alter behaviour in .py files ...
0
votes
2answers
32 views

Stop waiting for the rest of a normal mode command and accept the command typed so far

I have a mapping for m and a mapping for m/ in the same buffer, in Normal mode. If I type m, is there a way to tell Vim to stop waiting for the 2nd character, and to just submit the current command as-...
0
votes
1answer
19 views

Spaces in mappings: where to put them and where not?

The question is actually rather short, don't be afraid. :-) I'm Russian, and so to tweak Vim in a way it will understand its commands even if a Russian language is currently active, I have the ...
0
votes
2answers
40 views

how to make a word turn into certain commands in vim command line?

I want :cup in vim command line to turn into :tabdo call MapRunCmd()<CR> Hope that somebody can help me out PS: I've tried this nnoremap :cup :tabdo call MapRunCmd()<CR> but didn't like ...
2
votes
1answer
44 views

What is the purpose to use "==#" with empty string?

The following is from vim-sensible plugin: set incsearch " Use <C-L> to clear the highlighting of :set hlsearch. if maparg('<C-L>', 'n') ==# '' nnoremap <silent> <C-L> :...
0
votes
1answer
73 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-...
0
votes
2answers
45 views

How to move `n` number char <left> in vim command line?

My init.vim code autocmd FileType cpp nnoremap <F4> :RunWithFile ~/Downloads/ > output.txt && cat output.txt I want my cursor position to be exact 31 times <left> in command ...
0
votes
1answer
61 views

Youcompleteme: shortcut key to format selection

According to this documentation :'<,'>YcmCompleter Format will format the selected text. I am struggling to map this to shortcut key <S-F2>. I have tried all of the following after having ...
0
votes
1answer
32 views

Rebinding i (enter insert mode) and Esc (enter normal mode) to Ctrl-Space

Esc doesn't work for me for obvious reasons. So I started using C-c but I'm told that's bad practice. In addition it isn't as convenient as I like it to be. So I looked into binding C-Space and found ...

1
2 3 4 5
26