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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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.

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
47 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
43 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
24 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
30 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
22 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
votes
0answers
22 views

How to map alt + arrow keys in iTerm?

I set option to meta have successfully mapped <m-left> <m-right> in iTerm by choosing to send escape sequence [1;5C and [1;5D when pressing alt-left and alt-right, but when I set alt-up ...
1
vote
1answer
24 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
23 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
28 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 ...
0
votes
1answer
16 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><...
0
votes
1answer
18 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
47 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
21 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 ...
-1
votes
0answers
23 views

String concatenation with variable in mapping

I want to concatenate string with variable to create path similar to: let note_path = 'd:\m\notes' map <Leader>nv :tabe! note_path . \vim.yml<CR> but vim treats note_path as string. How ...
0
votes
0answers
19 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
17 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
33 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
47 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
38 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
45 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
53 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 &...
0
votes
1answer
12 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
33 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
33 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
31 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 ...
1
vote
1answer
25 views

How can I change the cursor moving on ctrlp?

I want to change the key mapping when I run CtrlP. For example, if I press ctrl+p to run CtrlP, type in something, and try to move the cursor to choose a file, I want to use ctrl+j to move down, and ...
1
vote
1answer
30 views

Make Ctrl-] give a list of matches to choose from instead of taking me to the first match

When the cursor is over a word that has multiple matches according to ctags, the Ctrl-] command on one machine I use gives me a list of matches to choose from, while on another it just populates the ...
0
votes
1answer
30 views

How to invoke mapped `i_CTRL-W` in function

First I will describe what I am trying to achieve: In general I use set iskeyword+=- as I see this more usable (one should always put spaces around operators when needed). This is quite helpful, but ...
0
votes
0answers
18 views

Nordic characters “æø” works, but not “å” because it's mapped from a plugin in normal mode

When listing key mappings with :map, it says <å> is bind to <å> <space>, but what happens when the key is pressed in normal mode is that it makes two characters switch place and then ...
0
votes
1answer
30 views

How to open file based on current file path

Is there a way to retrieve the current filepath, modify it, and open the result? To be more specific, let's say I'm editing ./some/file/awesome.controller.ts Then I'd like to automatically open ./...
4
votes
1answer
40 views

Add ^M character in mapping without entering <CR>

I've run into the problem mentioned here, but in a context in which I don't have an easy alternative that I can think of. I'm trying to add a mapping to fix bad newline characters in a file. I would ...
0
votes
0answers
36 views

Is it possible to change the key with combination via langmap?

I use Dvorak so I must use the following langmap setting to make the cursor moving compatible with the QWERTY's: set langmap=dh,hj,tk,nl But then, I would like to use the following setting to move ...
1
vote
0answers
39 views

How can I detect which command triggers a shortcut in a third-party package?

I remap Shift + k to noh, but once I installed ale, it is no longer working since one of the command on the package uses the shortcut. At least as far as I know, I feel that it is related to ...
1
vote
0answers
30 views

applying a map only to normal buffers

I have a binding that I use heavily and is very close to my heart. However, it tends to break (only a few) other functionality, primarily the command-line window. The bind is normal mode : ...
2
votes
1answer
171 views

copy line XX and paste it below my cursor (avy / ace jump style)

I am wondering what the way of copying a line and pasting it below my cursor in vi/vim might be? Current workflow (copy line 21 and paste it below cursor): 21ggyy''p Is there something shorter like: ...
3
votes
1answer
79 views

Is there a way to disable the command line window?

Often the mechanism to end up in the command line window is a transposition typo q: instead of :q when I intend to be closing Vim. You can imagine the frustration at this point because the program ...
1
vote
2answers
35 views

Applying vimrc to vimtutor in Windows

I'm using Git's MINGW64 bash shell to run vim and vimtutor. I managed to change the movement key bindings via e: $MYVIMRC, but the changes in keybindings do not apply to vimtutor. When I open ...
0
votes
1answer
23 views

map something to the action of the leader key?

I have this in my vimrc: let g:mapleader = "," nnoremap # , so I use , as my leader, and want to use # for backwards search after f,t...But my # mapping does not work, so something is amiss thanks
-1
votes
1answer
35 views

key mapping : completely change one key to another

I want to map these keys: H => ^ L => g_ J => L K => H Q => J I previously mapped them in normal and x-mode. But today I found out I needed operator-pending mode too. I want to map ...
0
votes
0answers
38 views

Remapping key combinations vim [duplicate]

Is it possible to remap key combinations in vim? I basically want to remap <c-w>] it doesn't seem to be working. Is there some special syntax that is needed to remap combinations which require ...
0
votes
1answer
27 views

autocmd buffer local mapping if not *.py file

As the title stated autocmd BufRead,BufNewFile not-py-file nnoremap <buffer> <F3> :call some_func<CR> is what I want to acheive, but I don't know how to implement that not-py-file ...
0
votes
1answer
80 views

Mapping tab with another key

Can I map the Tab key as the same style as Control plus another key? For example ,<c-k> means press the Control and k keys together. I've tried <tab-k> but it didn't work.
1
vote
3answers
78 views

How to redirect terminal output to vim or get `vim like` behaviour in terminal output [closed]

How to get vim keybindings at terminal output so I can navigate/operate at terminal output like in vim or get smooth shell command processing in vim. For example I type: ifconfig an i want to make ...
1
vote
0answers
31 views

Can I map contrl and hyphen <C-->? [duplicate]

How can I map Ctrl and hyphen key? Usually when mapping Ctrl key with other keys there is a hypen key in the middle. But I would like to use this hypen key as my mapping, can I do that? When I tap ...
0
votes
2answers
32 views

Invoke command-line mode in input waiting state

For example, I'd like to map <leader>l to enter command-line mode with a command (AsyncRun followed by a space) partially typed in, so that I can continue to type to complete the command. So ...
1
vote
0answers
57 views

^O (Ctrl+O) works slowly

In my system, <C-o> works really slowly compared to <C-i> or <C-p>. Is it just my experience or is there a subtle reason behind it? Is this in any way related to ttimeoutlen? I saw ...
2
votes
1answer
37 views

Execution of nnoremap takes significant time

I am developing a vim plugin and I have set a default mapping this way. if !hasmapto('<Plug>DumpDebugString') nmap <unique> <Leader>ds <Plug>DumpDebugString nmap <...
0
votes
1answer
76 views

How to remap :w to :up?

I have a file-watcher system which triggers some compilations upon time-stamp changes in the source file I am editing. I have the obsessive habit of using :w quite a few times during my editing ...