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.

2
votes
2answers
38 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 ...
7
votes
3answers
793 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
33 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
34 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
36 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
62 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
31 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
25 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
44 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
21 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
12 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
31 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
134 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
22 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
106 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
64 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
48 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
17 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
21 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
49 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
46 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
60 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
31 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 ...
1
vote
1answer
26 views

In visual mode, how do I bind a key so that the selected text generates “%s/<SELECTEDTEXT>/<CURSORHERE>/g”?

In visual mode, how do I bind a key so that the selected text generates %s/<SELECTEDTEXT>/<CURSORHERE>/g ? Preferably ; considering I never use it otherwise. Thanks.
0
votes
1answer
27 views

How to start recording a macro, using commandline mode?

If I wanted to start recording a macro using command-line mode, how would I do this? Additionally, if I wanted to bind this action to a key, how would I do that in my .vimrc?
0
votes
1answer
50 views

what's the purpose of leading colon in key map?

:imap mmm <Esc> vmap '=y :w !pbcopy<CR><CR> I copied two lines of vim map scripts. The first one has a leading colon while the latter one doesn't have. So, what's the purpose of ...
1
vote
2answers
38 views

Substitute an insert-mode input immediately

I would like to type begin! in insert mode and having it immediately replaced by: begin [cursor here] end I considered mappings: :inoremap begin! begin end<Left><Left><Left><...
1
vote
1answer
28 views

How to insert special keys (like <return>, <m-r>) into macro registers with script?

I tried let @q = '<return>' and it obviously won't work
1
vote
1answer
87 views

Remap Esc key in Vim

Is it possible to remap the Esc key to another key in Vim? When I'm using Vim in a full screen VMware vSphere web client console window and I press the Esc key to exit edit mode, it also takes me out ...
1
vote
0answers
22 views

remap keybinding for vim gocode autocomplete feature? (remap keybinding in insert mode) [duplicate]

So I installed vim-go and gocode and Blackrush/vim-gocode.git (the latter because I use pathogen). So far so good! I am fine, I can type <C-x><C-o> in insert mode and I get completion ...
0
votes
0answers
22 views

The key remapping suddenly stop working

I have been using the neovim but suddenly the following key remapping stop working, after I upgrade the neovim version from 0.2.2 (I think) to 0.3.1. nnoremap <Leader>q :mksession! ~/.config/...
0
votes
1answer
27 views

importing skeleton on keybind

Task: on key press, lets say <C-G> print a basic skeleton, e.g.: 99 control '<++>' do 100 impact '<++>' 101 title '<++>' 102 desc '<++>' 103 describe <++>...
1
vote
1answer
39 views

Show external command output in preview window

Lets say I have the following cmake file (with | being the cursor). cmake_minimum_required(3.2) project(myapp) add_exe|cutable(myapp main.cpp) Now if I go to terminal and consult cmake documentation ...
0
votes
2answers
51 views

how to replace N characters without having to press <esc>, is it possible?

In command mode, r replaces the character under the cursor by the one pressed right after typing r without going into insert mode, so there's no esc to press. 5r replaces the 5 characters starting ...
0
votes
2answers
47 views

Move/filter to next *blank* line

I'm trying to do two things involving blank lines (empty lines or lines with only white-space on them). Move to the next blank line (or EOF if none) Filter (using !) to the next blank line (or EOF if ...
3
votes
2answers
55 views

How to set a shortcut to run make in Vim and show the output

I'd like to run make and display the output when I press Ctrl+m in Vim. I know how to run make and display the output while in command mode, thanks to this StackOverflow answer, namely with: :make | ...
0
votes
0answers
20 views

Why my `<c-[>` bindings automatically reflect to `<esc>`? [duplicate]

i have this code in my config file: nnoremap <c-[> :call PrevFunc()<cr> nnoremap <c-]> :call NextFunc()<cr> vnoremap <c-[> :call PrevWord()<cr> vnoremap <c-]>...
0
votes
2answers
96 views

vim split horizontal resize shortcut

I can resize horizontal split windows by ctrl-w-shift-< and ctrl-w-shift->. I would like to have a shortcut for that. Close to the topic, recently I learned about the following maps: nnoremap &...
1
vote
1answer
18 views

<S-Arrows> weird behavior (<S-UP>,<S-DOWN>,<S-LEFT>,<S-RIGHT>)

<S-DOWN> Moves the cursor back a few characters. But not always by the same amount. <S-UP> Moves the cursor to the end of the line. <S-LEFT> Deletes the next two lines. <S-...
2
votes
1answer
40 views

Revert effect of source $VIMRUNTIME\mswin.vim

On Windows, Vim does source $VIMRUNTIME\mswin.vim in its system-wide config and remaps many keys. I'd like to have default Vim key bindings but I don't want to touch system-wide config. How do I do ...
0
votes
0answers
66 views

Is there a command to get out of Terminal mode on Neovim?

I could not get out of my Terminal mode for some reasons, using C-\ + C-n combinations. Maybe since I map the \ to my Leader (I'm not sure)... So anyway I would rather map Esc to the command that ...
0
votes
1answer
76 views

How can I change the cursor moving on fzf?

Similar to the question about ctrlp, I would like to know how to change the key remapping to move the cursor on fzf library. Right now, only the ctrl + k works to move the cursor upward, but all the ...