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
143 votes
17 answers
180k views

Other ways to exit Insert mode besides Escape

The primary reason I like vim over emacs is that my hand movement distance away from the home row is very low (even as a programmer). However, the one main time that I do this is leaving insert mode, ...
durron597's user avatar
  • 2,131
137 votes
8 answers
195k views

How can I easily move a line?

What is the command (or shortcut) to move a line up or down in vim? My current workflow is to yank (copy) the line and than delete that line and than to put (paste) that line.
Vader's user avatar
  • 1,615
116 votes
9 answers
251k views

What is the command for "Select All" in Vim and VsVim?

How do I select all the content of a file in Vim and VsVim? Like in other editors Ctrl-A does the job for select all.
Armaan's user avatar
  • 1,263
111 votes
1 answer
30k views

How to debug a mapping?

I see a lot of questions on here where a user has a mapping which doesn't work and most of the time the reasons are pretty similar. I suggest to make this question a reference for this kind of ...
statox's user avatar
  • 49.4k
102 votes
2 answers
59k views

How can I find out what <Leader> is set to? And is it possible to remap <Leader>?

How can I figure out which key is set as my <Leader>, and how do I remap it?
krampstudio's user avatar
  • 1,205
93 votes
3 answers
31k views

Open filename under cursor like gf, but in a new tab (or split)?

The normal mode command gf go to a file with the path the cursor currently is at. But it does so in the current window, replacing the current text. That means you need to navigate back explicitly ...
Volker Siegel's user avatar
82 votes
8 answers
88k views

How to map Alt key?

I'm trying to map Alt key in the following way: :map <A-j> j :map <A-k> k but it doesn't work (bell is rang on Alt + j/Alt + k). What am I missing? I'm using Terminal on OSX, the same ...
kenorb's user avatar
  • 18.2k
52 votes
7 answers
10k views

Can I delete an entire line, except the line break?

A fairly common operation for me in Vim, since I am compulsive-obsessive and like to keep my files free of whitespace, is to delete the contents of an entire line, but not the line itself (i.e. not ...
Andrew Ferrier's user avatar
46 votes
8 answers
18k views

Why is using arrow keys in normal mode considered bad practice?

I have read it in many articles (e.g.) that it's a bad practice to use arrow keys in normal mode. Could somebody explain why is it considered a wrong practice, if at all?
Ankit Jain's user avatar
43 votes
4 answers
29k views

How can I work with splits in Vim without Ctrl-W?

My terminal doesn't allow me to type Ctrl+W, because that's a shortcut for closing a terminal tab. I like working with splits, but I can't find any way to do so without using C-W. This forced me to ...
Mateon1's user avatar
  • 533
42 votes
8 answers
32k views

How to disable arrow keys in vim?

I want to teach myself to prefer hjkl more over the arrow keys in order to stay on the home row. (I am very aware that one should not use hjkl as the main navigation keys as there are more powerful ...
k0pernikus's user avatar
  • 2,957
42 votes
2 answers
8k views

Why is Y a synonym for yy instead of y$?

Is there a specific historical reason for this? Background — (you can skip this part if you already understand the question.) As intermediate/advanced vi users will know, y is the "yank" command—it ...
Wildcard's user avatar
  • 4,364
40 votes
2 answers
6k views

What is <Leader>?

I see <Leader> quite often in other people's vimrc files. Like this one. What is it? What does it do?
Frames Catherine White's user avatar
39 votes
1 answer
15k views

What are the differences between the map, noremap, abbrev and noreabbrev commands?

These commands transform one set of keystrokes to another in some way, but I am somewhat fuzzy on which one is most appropriate for some situation. In addition, there are the ! variants of them as ...
muru's user avatar
  • 24.7k
34 votes
1 answer
19k views

What does z stand for in vim?

I was looking up at tips on screen shifting and came across the following tips: zz = shift current line to middle of screen zt = shift current line to top of screen zb = shift current line to bottom ...
James Franco's user avatar
  • 1,081
32 votes
4 answers
75k 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 ...
Beam Davis's user avatar
31 votes
3 answers
10k views

How can I redefine plugin key mappings?

I have installed a plugin that doesn't provide a mechanism to disable the key mappings it defines. I want to redefine one of the mappings (<leader>cc) defined by the plugin for my own pursope, I'...
toro2k's user avatar
  • 4,822
30 votes
1 answer
11k views

Understanding CTRL-U combination

In this answer I faced the CTRL-U used in function call after : and before the actual function name. :nnoremap <buffer> <cr> :<C-U>call append('.', repeat([''],v:count1))<cr> ...
user3663882's user avatar
28 votes
2 answers
20k views

File Type dependent key mapping

I'm trying to setup mappings for <C-]> that, depending on the buffer's file type, trigger different functions. For example, if I'm in a Javascript buffer, I want <C-]> to trigger :TernDef. ...
domi91c's user avatar
  • 469
28 votes
1 answer
4k views

Disable <Esc> but keep <C-[>

For switching back from Insert mode I'm used to <Esc>. Now I'm looking to retrain myself to <C-[> instead of <Esc>. For that i need to disable <Esc> to help with the ...
mxlian's user avatar
  • 545
27 votes
3 answers
10k views

What does `<Bar>` mean?

In answering a question just now, I mentioned using a normal mode key mapping that can be found at the Vim Tips Wiki. In the middle of explaining the key mapping, I realized that I had no idea what &...
Christopher Bottoms's user avatar
27 votes
4 answers
12k views

How to enter insert mode when entering neovim terminal pane?

I have the following mappings to make it easy to move out of a terminal pane in neovim: tnoremap <C-h> <C-\><C-n><C-w>h " Workaround since <C-h> isn't working in neovim ...
aharris88's user avatar
  • 1,837
27 votes
1 answer
7k views

Can I map a Ctrl + upper-case letter separately from Ctrl + lower-case letter?

I am trying to figure out how to navigate windows little quicker, so I would like to map the following: :nmap <silent> <C-F> :wincmd f<CR> The problem is this remaps the ^f (lower-...
user1135541's user avatar
  • 1,103
26 votes
2 answers
10k views

ale linter + eslint: Jump to next error

I use eslint with ale to lint my Javascript code. After editing a code block, I often have a few errors to fix. Fixing is done by navigating to the next erroneous line, reading the problem from the ...
Adam Matan's user avatar
26 votes
1 answer
4k views

What is the difference between "mapped key sequences" and "key codes"? (timeoutlen v ttimeoutlen)

The vim manual says we can use timeoutlen to specify the timeout length of mapped key sequences and can use ttimeoutlen to specify the timeout length of key codes: A useful setting would be :set ...
Niko Bellic's user avatar
  • 1,754
25 votes
5 answers
17k views

How to find out what a key is mapped to?

I know that running :map commands without arguments should give me a list of user-defined mappings, but, for example, when I press Ctrl-W Ctrl-I something happens, yet I have no idea what function was ...
Mad Wombat's user avatar
24 votes
3 answers
4k views

How to enable/disable an augroup on the fly?

I created an augroup in my .vimrc containing several autocmd and I need to enable/disable these autocommand on the fly. The idea is to create a mapping (let's say F4 for example) which would enable ...
statox's user avatar
  • 49.4k
24 votes
3 answers
2k views

How can I get ‘n’ to go forward even if I started searching with ‘?’ or ‘#’?

Vim has (at least) two sets of commands that search in opposite directions. Typing / and then a pattern will search forward through the document for the pattern; typing ? and then a pattern will ...
bdesham's user avatar
  • 2,923
23 votes
4 answers
2k views

Clear a line faster than [0][d][$]

Is there a faster way to erase the text on a line than pressing 0 to jump to the start, then pressing d$ to delete until the end of the line? Also, what if I wanted to delete everything except the ...
Robbie Wxyz's user avatar
23 votes
1 answer
10k 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 ...
mas's user avatar
  • 535
22 votes
4 answers
5k views

What is the most convenient way to work with different keyboards in vim?

I sometimes need to write Greek words, but when I am using the Greek keyboard, hitting, say, <C-p> will be understood as <C-π> and not as the command I intend. This can be fixed with :map &...
Toothrot's user avatar
  • 3,119
21 votes
4 answers
6k views

How I apply a command to all lines?

If I want to indent all lines in a document, I can type >G to apply it to the current line and below, followed by and >gg to apply it to the lines above. Is there a combination I can use to ...
drs's user avatar
  • 3,018
21 votes
1 answer
585 views

Figure out which plugin is responsible for a key binding

I was about to answer a question but realized that my answer depends on a key binding provided by a plugin I have installed. Even worse, I don't know which plugin provides it. The only way I know to ...
Praxeolitic's user avatar
  • 2,448
20 votes
1 answer
20k views

What options are there to enter insert mode?

I used to enter insert mode by a never realizing that there is a system as to where the insert mode starts. I was sometimes annoyed that a would put the cursor after the first character of a line, ...
k0pernikus's user avatar
  • 2,957
20 votes
1 answer
3k views

How can I map d[count]d?

N.B. This is not a duplicate of How does the "d3fg" command work? Please read it before voting to close! I've come to a bit of an impasse in my quest to get small deletions work like big ...
Rich's user avatar
  • 31.3k
20 votes
4 answers
3k views

How can I use Readline shortcuts in the vim command line?

When I'm editing a Vim command, I would like to use the same shortcuts as in Bash and every other REPL: M-b to go back a word, M-Backspace to delete a previous word, M-u to convert the word to ...
Mihai's user avatar
  • 311
18 votes
3 answers
8k views

How to map a shortcut for saving the file

Can I set something like ctrl+s to save the file? I don't want to use :w every time.
Canux's user avatar
  • 193
18 votes
2 answers
4k views

How to repeat a mapping when keeping key pressed

I have in my .vimrc some simple mappings to resize split windows easily: noremap <Leader><UP> <C-w>+ noremap <Leader><DOWN> <C-w>- That works pretty fine but ...
statox's user avatar
  • 49.4k
18 votes
3 answers
3k views

Mapping with motion

I'm trying to understand how can I use operator with subsequent motion inside a mapping. For example: nmap /c c{here we pending for a motion}/<C-r>"<CR> The map should do the following: ...
Timur Fayzrakhmanov's user avatar
17 votes
2 answers
3k views

How to save and restore a mapping?

I am developing a plugin for Vim and I would like to define a mapping which would be available only while the "execution of the plugin". So far the (simplified) workflow of the plugin is the ...
statox's user avatar
  • 49.4k
17 votes
5 answers
2k views

Why does this <Esc> normal mode mapping affect startup?

I'm experiencing a weird problem with a normal mode mapping of Esc. If you create the file escmapvimrc with the contents: set nocompatible set showcmd " Doesn't affect the problem: just makes it ...
Rich's user avatar
  • 31.3k
17 votes
1 answer
2k views

How to move the cursor to the correct indentation level without quiting insert mode?

For example I have this JavaScript code. The | character represents the cursor position and it is on an empty line. function a() { console.log("a"); function b() { console....
silviubogan's user avatar
17 votes
3 answers
6k views

Problem following links of vim's doc (:help) on the terminal

I'm having some trouble reading vim's documentation on the terminal because I can't follow the links that are given. I quote: Jump to a subject: Position the cursor on a tag (e.g. |bars|) and ...
Wylex's user avatar
  • 543
17 votes
3 answers
6k views

Fix arrow keys displaying A, B, C, D in vi (not in vim)

I know that in vim I can add set nocompatible in .vimrc to avoid that arrow keys display A, B, C, D in insert mode. But I'm using vi Version 4.0 (gritter) 12/25/06. How can I obtain the same ...
Ortomala Lokni's user avatar
16 votes
4 answers
7k views

Swap values "true" and "false" via ctrl+a, ctrl+x

I think it would be useful to have possibility to swap true and false values in the code rapidly, with combination ctrl+a or ctrl+x. Is there some plugin for that or something else?
Alexander Myshov's user avatar
16 votes
1 answer
10k views

find next occurrence of word or line at cursor

For example when editing a big .gitignore file and pasting in a block for a newly added toolset's suggested ignore patterns, I manually looked at each line and typed /\.filetype where filetype is what'...
dlamblin's user avatar
  • 305
16 votes
1 answer
6k views

Mapping a command in Visual Mode results in error E481: No range alllowed

I'm trying to make a keyboard binding in Neovim that would send a selected block to the opened Neovim terminal. I've used these answers as guidelines https://vi.stackexchange.com/a/3390/3405 https://...
6D65's user avatar
  • 403
15 votes
1 answer
5k views

Mapping Ctrl with equal sign

I am trying to map my Ctrl and plus sign together. This is what I am trying in my vimrc: nnoremap <C-=> : echo "Hello" <CR> However it seems like the mapping is not being triggered. ...
James Franco's user avatar
  • 1,081
15 votes
3 answers
5k views

Is it possible to create mappings with parameters?

I have created a few mappings like so: :nnoremap <buffer> <leader>xyzABC :call SomeFunc('ABC')<CR> :nnoremap <buffer> <leader>xyzDE :call SomeFunc('DE')<CR> :...
René Nyffenegger's user avatar
15 votes
2 answers
8k views

How can I modify Vim to work with a different keyboard layout?

I type with a non-QWERTY keyboard layout. Many of the keys Vim uses are now on the home row, but some key bindings just don't work, the most obvious one being the hjkl keys. How and where can I ...
Earthliŋ's user avatar
  • 313

1
2 3 4 5
31