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
1answer
45 views

Why does this mapping require hitting enter?

I've written a "script" to highlight all lines that begin with n (for a todo list): syn region dash start=/^n/ end=/$/ oneline | highlight link dash String And mapped it to ; in my init.vim:...
1
vote
1answer
57 views

Vim keymappings with repeat keys

I have been a QtCreator user for long now. Just switching to JS & Go. With FZF, I have created these mappings nnoremap <C-k> :Files! <CR> nnoremap <C-k>. :BTags! <CR> ...
1
vote
2answers
188 views

Check if :make fails

I just setup this mapping for my latex development: nnoremap <buffer> <LocalLeader>o :make %:r.pdf <Bar> !open %:r.pdf<CR><CR><CR> But I wondered about checking if ...
2
votes
2answers
86 views

Perform action after invoking a <Plug> command

I use the following mapping to send code to a REPL using vim-slime and tmux: nmap <buffer> <S-CR> <Plug>SlimeLineSend How can I perform an action after I invoque this mapping?. For ...
1
vote
1answer
71 views

Setting cursor position within a line mode command?

I'm trying to make some simple mappings that expand to more complex line mode commands, just to speed up some tasks. I would like to set where the cursor appears within the expanded command. Take this ...
0
votes
1answer
302 views

How to remap command abort (Ctrl-c)

When you run a command such as :! sleep 5, then you can normally cancel it using Ctrl-c. How do I remap that combination to something else, for example Ctrl-x? The context is that I use urxvt with ...
1
vote
1answer
27 views

Removed Plugin still has active keybindings from view/ files

I installed the plugin vimtex. Then I installed the plugin tex-vim (aka Latex suite). The compilation keybinding (<Leader>ll) from vimtex stopped working, since tex-vim takes over it. So I ...
0
votes
0answers
13 views

How to remap copy and pasting to keyboard [duplicate]

I'm trying to remap the current keybindings to make it simpler for yanking and pasting but it doesn't work. Some of my ~/.vimrc noremap <Leader>Y "*y noremap <Leader>P "*p ...
9
votes
1answer
167 views

Why does `<Bar>` behave like `|` in the `:command` command in Vim?

Here is the list of experiments I performed that shows that <Bar> is treated as literal <Bar> in some commands but it is treated as | in the :command command. I am trying to understand why ...
1
vote
0answers
25 views

Clear the current line but stay in normal mode [duplicate]

I'd like to delete the contents of the line I'm on without entering insert mode. Right now I have to do cc then Escape to go back to normal mode, is there a shorter key sequence if I'm in the middle ...
0
votes
1answer
258 views

Navigation in insert mode with soft wrap and showbreak

I’m having trouble with hjkl movement in insert mode. The issue is that I have changed hjkl movement to move by display line. I have 'wrap' on. The cursor should normally move line by line, not move ...
1
vote
1answer
51 views

How would I make this into a keybinding?

When I want to find out what might be causing lag within vim, I use the following commands :profile start ~/profile.log | :profile func * | :profile file * <do actions that cause lag> :profile ...
1
vote
1answer
509 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 ...
2
votes
1answer
35 views

The mapping works, but a key can be ignored (unwantedly)

I've added this to my .vimrc: nnoremap <C-S-w> :tabclose<CR>, and it works! But my problem is that CTLR+w closes the terminal tab as well, ignoring the shift key specified in the above ...
5
votes
1answer
2k views

Is it possible to map control forward-slash with vim

I'm wondering if it is possible to map control + forward-slash in vim. The mapping would be for normal mode if that makes a difference. I have tried <c-/> but that didn't work. I also tried ...
2
votes
1answer
91 views

How to map a keybinding to a command which includes <C-U> (scroll-up) in my .vimrc?

I want to map a keybinding to a command which includes <C-U> not for clearing the command line but for scrolling the page up. Executing a command like this in my vim session works totally fine: :...
2
votes
0answers
41 views

How to delete the previous buffer when loading new result from quick-fix window?

In the quick-fix window, if I'm loading new results, the previous buffers stay which I don't want. I want only those buffers to stay which I open intentionally (e.g. to write new code, do diff of ...
1
vote
1answer
35 views

Use variable in vim mapping async task [duplicate]

I am trying to use a variable in this mapping: let board_ip = "192.168.100.18" │ nnoremap <F6> :AsyncRun echo . ...
1
vote
1answer
39 views

<Cmd> doesn't seem to work in visual mode

The following command copies the selected text into the PRIMARY selection: vnoremap <Leader>c :'<,'>!xsel<CR>u But this way it doesn't work: vnoremap <Leader>c <Cmd>'<...
0
votes
0answers
24 views

gVim on Windows not distinguishing Numpad Enter

Using gVim on Windows, I'm trying to add a mapping to <kEnter>, but it seems that it's not being treated seperately from <CR>. New to Windows, so I thought this may just be an OS thing, ...
0
votes
1answer
90 views

Map C-S-[ and C-S-] to :tabprev and :tabnext [duplicate]

I'm trying to map C-S-[ and C-S-] respectively to :tabprev and tabnext, but when I try that then I get "no lines in buffer". A mapping like C-S-tab works. I looked through :nmap and didn't ...
0
votes
2answers
177 views

How to format a JSON snippet in a non-JSON file using jq?

I've got, in this case, a Perl module which has some JSON snippets inside of it. I'd like to be able to select the embedded JSON and format it via jq. So far I've got: :vnoremap jq <esc>:'<,'...
2
votes
1answer
158 views

Conflict between system compose key and insert mode meta key mappings

I use the right alt key as a compose key on my system, to easily draw diacritics and accent characters. In Vim, I unlock alt key mappings with this (from stackoverflow): " Allow <alt> key ...
0
votes
0answers
17 views

Using S to go to the proper indentation

I would like to do a mapping so that when pressing S at the start of a line in normal mode it automatically goes to the correct level of indentation. Here is what I have so far: " S to go to the ...
1
vote
1answer
19 views

<esc>v$ without trailing space?

I want to use $ in visual mode but it always includes a trailing space (even if there isn't one on the line). How do I make it so $ only goes to the actual last letter?
2
votes
2answers
96 views

Make an expr mapping dependent on the number of lines selected

How can I make a visual mapping's behaviour dependent on the number of lines selected? I tried creating an expr map, but the visual start and end marks don't seem to be correct: function! Xsurround() ...
0
votes
1answer
76 views

How can I make Neovim actually delete something instead of copy?

I find very frustrating in Neovim and vim that when I delete a text to replace it, what actually happens is that it copies the last thing I deleted. I've tried with this line in my init.vim: vnoremap ...
1
vote
3answers
317 views

Can I remove all maps containing key?

I have a plugin (c.vim) which includes a lot of maps (all with leader key). I changed my leader key to space, which I like, but the problem is that the maps also apply to insert mode. I would like to ...
2
votes
1answer
293 views

Shortcut for spell checking

I would like to create a shortcut for the spell checker, since it requires a relatively long command. I inserted the following map in the .vimrc file: inoremap <F5> <C-O>:set spell ...
0
votes
0answers
189 views

Remapping the menu key in Neovim-Qt

I would like to map the menu key (aka application key) on my keyboard to various behaviors in Vim, but in Neovim-Qt on Windows 7, Vim does not recognize presses of the menu button. For example, when I ...
0
votes
0answers
466 views

How to map the slash key "/"

I am trying to map the NERDCommenterToggle command from the nerdcommenter plugin. I want to use "Ctrl+/" for this: vmap <C-/> <plug>NERDCommenterToggle nmap <C-/> <plug&...
1
vote
1answer
244 views

Disable Shift+Insert from pasting from Primary

In Vim, the canonical methods to interact with X11's Clipboard and Primary is to use + and * registers. There are at least another two ways to paste from Primary into Vim: Shift-Insert and Mouse ...
1
vote
1answer
53 views

How to tell vim to ignore extern "C" brakets while indenting?

I have the following in my .vimrc to indent the whole file: nnoremap cu gg=G`` I have a problem using this in source files that have #ifdef __cplusplus extern "C" { #endif // code #ifdef ...
0
votes
1answer
157 views

How do I switch from terminal back to vim? [duplicate]

When I'm in vim and I use :term to open a terminal inside vim, how can I switch back from the terminal to vim?
0
votes
1answer
46 views

Moving and deleting one word at a time using Ctrl + Arrow keys or Ctrl + Del

I want to know if it's possible to delete a whole word or move around one word at a time when in INSERT mode, like in "regular" applications when pressing Ctrl and using the arrow keys jump ...
1
vote
1answer
48 views

Typing d in insert mode briefly moves cursor backwards

In Vim, when I'm in Insert mode and hit d, the cursor moves back one spot for a second, then jumps back to behind the letter just typed. This is quite distracting when typing texts. It looks like Vim ...
0
votes
1answer
131 views

neovim switch keymapping

I am in the process of getting myself to start using neovim instead of vim/vi which has been favorite editor for over 30 years. For my current use, I need to set keymapping to type characters that ...
0
votes
1answer
220 views

Fugitive: jump from diff to the current version

When exploring a commit using :Gedit HEAD, when I click o or Enter into the change, it shows me a vimdiff of the two file versions of the change. From there I often need to jump to the current version ...
0
votes
1answer
145 views

How to map command+shift+right to widen vim split?

When I use 5<C-w>> in vim it makes my currently selected split increase by '5'. When I try to create this mapping on my Mac: noremap <silent> <D-S-Left> 5<C-w><<CR>...
1
vote
1answer
22 views

Vimrc syntax move up and down a certain line continously

So I am new to Vim and I am trying to understand the language of vimrc. I have this in my vimrc: map <F8> <C-E>: sleep 100m<CR>j<F8> This would automatically move the cursor ...
2
votes
2answers
102 views

How to disable auto insertion of comment header when pressing enter, but keep auto insertion of header when auto wrapping comment?

When editing c and cpp files, this is the behavior I want to achieve: When typing a comment line of the form // Line..., pressing <CR> should not add the comment header // in the next line. ...
3
votes
1answer
190 views

Recording and playing macros with langmap activated

Thank you for your interest in this rather specialized question. This is a follow-up to this question : Mapping for expression register with langmap active I’m looking for the best way to associate ...
0
votes
1answer
19 views

enew is not allowed when used inside a function called by nnoremap <expr>

I have a function: function myPlugin#myFunc() " .... enew termopen(['cmd', 'here'], termopen_opts) endfunction And in my plugin/myPlugin.vim I do: nnoremap <expr> <leader>e ...
0
votes
1answer
40 views

Cycling between tabs and buffers

I want to set up some mapping that: if there are multiple open tabs, then goes to the next tab, like :gt otherwise it cycles through the open buffers, like :bn How do I go about doing this?
1
vote
1answer
47 views

Using <C-h> and <C-S-h> separately

I want to make separate bindings for <C-h> and <C-S-h>. For example: noremap <C-h> <C-w>h noremap <C-j> <C-w>j noremap <C-k> <C-w>k noremap <C-l> ...
1
vote
1answer
89 views

Silence command but not its output

I use the following function to compile a LaTeX document function! TeXCompile() let filepath = expand('%:p') execute "!cd $(dirname ".shellescape(filepath,1).") && pdflatex -synctex=1 "....
1
vote
1answer
18 views

Quickly go to the end of "syntax highlighted" element

I am using syntax highlighting to help with writing LaTeX documents in vim. My documents involve a lot of brackets, and it is easy to do a trivial mistake and end-up with something which doesn't ...
0
votes
0answers
119 views

Make vim commands be executed once a job on a terminal buffer has finished

The context I've the following mapping in ~/.vim/ftplugin/cpp/mappings.vim. What this mapping does is to compile an arbitrary C++ file and open two windows (a) and (b). (a) shows the output of the ...
1
vote
0answers
23 views

Noremap failing when it comes to <esc> [duplicate]

When I noremap my Esc key, it breaks other things even though I'm not pressing Esc and those other mappings are also noremap. I start with this vimrc: set nocompatible inoremap <silent> <Up&...
0
votes
1answer
115 views

How can I create mappings for replace mode?

I know how to create key mappings in normal mode using nmap and in insert mode using imap. However I do not know how to create mappings in replace mode. I would assume it's either rmap or Rmap, but ...

1
3 4
5
6 7
26