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

Sometimes <c-w> has to be followd by <b> [closed]

Occasionally, when I use <c-w>, the cursor will simply move to the end of the word. If I then immediately press <b>, the word is deleted and I'm placed into insert mode (as expected from &...
1
vote
1answer
31 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
0answers
14 views

How to check if a user defined mapping exists from inside a vim script? [duplicate]

If I want to check weather I (or a plugin) have mapped some key, I can simply use the :map command and check it's output. How do I access and check this this output from inside a vim script? Or is ...
-1
votes
1answer
41 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
17 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
27 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
29 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
24 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
33 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>...
0
votes
0answers
17 views

Reverse n and N for ? and # searches (compared to / searches) [duplicate]

When I search with ? or #, I want n to move "forwards" through the buffer, and N to move backwards. This is opposite to current behaviour (where n moves in the search direction). How can I set this ...
1
vote
1answer
12 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
29 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
0answers
44 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
13 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
22 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
24 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
71 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
17 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
26 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
19 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
27 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 ...
0
votes
2answers
43 views

How to toggle `modifiable` property

When I edit .vimrc (for example), I often want to view the file as write-protected. noremap <C-a> : sview $HOME/.vimrc <CR> \| : set noma <CR> sets the nonmodifiable property for ...
2
votes
1answer
61 views

Create a mapping in .vimrc that accepts an argument

I want to create a mapping in my .vimrc file that takes an argument. I'm constantly defining latex commands which require arguments inside of curly brackets and writing them instead inside regular ...
2
votes
1answer
45 views

Mapping for expression register with langmap active

I am using Vim with a QWERTY/BÉPO langmap setting which allows me to use the French dvorak-like keymap for inputting text and the QWERTY commands for the normal and visual mode. Background: I am ...
2
votes
3answers
51 views

wrap a long line with specific format

I have a problem with breaking long line in markdown file. Given the following line * "fo" : You can use the 'formatoptions' option to influence how Vim formats text. 'formatoptions' is a string ...
0
votes
1answer
25 views

What does c<CR> do?

What does cEnter (not ctrlEnter) do in Vim? I didn't have any mapping about it and it behaves like the S command. See below image:
2
votes
1answer
37 views

Remapping `v` in netrw/calling NetrwSplit(5) directly

So I've created some helper functions to help work around netrw. They are some keybind simplifications that help with things like window/cursor management when opening files, where to open them, ...
2
votes
1answer
41 views

How is the fn key in written in vimscript?

How do I map the fn key in combination with another key to a macro? I know that the ctrl key in key combinations is written as a C (e.g., <C-c> for ctrl+c) in vimscript. So how would I do ...
1
vote
2answers
19 views

Handle ambiguous map

I can make a map like this: nmap wr :write<CR> but then it clashes with another map: http://vimdoc.sourceforge.net/htmldoc/map.html#map-ambiguous http://vimdoc.sourceforge.net/htmldoc/motion....
0
votes
1answer
67 views

Ctrl keybindings not working in wsltty

I have the following mappings: nnoremap <C-,> :tabe ~/.config/nvim/init.vim<cr> nnoremap <C-/> gcc Neither of these mappings is working - they both do nothing. I have a plugin ...
2
votes
1answer
66 views

Why doesn't this macro work? (expression register)

According to this: nnoremap Q @='n.'<CR>: The @ key tells Vim to execute a macro. Rather than using a named register we use the expression register, which lets us specify the contents in ...
1
vote
1answer
46 views

How to remap command based on buffer type?

I have coc.vim installed and added suggested mappings, then I installed vim-fugitive and I want to remap the "Toggle an inline diff of the file under the cursor." fugitive_= to Tab but the coc.vim is ...
1
vote
1answer
38 views

Why would you use `nnoremap gf gf` as SpaceVim does?

While writing this answer about vim-rails on SpaceVim, I found out these mappings set by SpaceVim, such as this one: nnoremap gf gf SpaceVim also creates similar mappings for all of the other gX ...
2
votes
4answers
133 views

What's the difference between a text object and a motion?

I've been using vim for a while and consider myself moderately proficient. I've also built custom text objects, primarily using the fantastic vim-textobj-user rather than natively, as well as using ...
1
vote
0answers
31 views

Re-mapping Swedish letters

On a Swedish keyboard to the right of the keyboard one has: O, P, Å L, Ö, Ä [ and ] are extensively used by Vim, and hard to reach on my keyboard, so therefore I've mapped these to Ö and Ä in my ....
0
votes
2answers
72 views

How can I discourage myself from using ':q', ':wq', etc. to quit vim?

I've had some success over the past year or two using vim-hardtime to wean myself off using the arrow keys in favour of h, j, k, l. However, I'd really like to wean myself off :q, :wq, etc. in favour ...
0
votes
0answers
13 views

ctrl-k mapping does not work (but h,j,l does)

I have the following mappings in my vimrc: " -- J :nmap <C-j> } :imap <C-j> <C-O>j :vmap <C-j> } " -- K (currently not working??) :nmap <C-k> { :imap <C-k> <C-...
2
votes
1answer
30 views

Why mapping enter to nop makes the last search to be repeated?

I use the enter key as my leader: nnoremap <cr> <nop> " To avoid moving the cursor let mapleader="\<enter>" So far so good. To have the same behavior on Dirvish I need to remap ...
4
votes
1answer
87 views

How to map “q” to “<cr>” for the hit-enter prompt?

I regularly press q to exit the -- more -- prompt in Vim. I often mistakenly use this same key to exit the hit-enter prompt, which then starts recording a macro after a subsequent key is typed. I'd ...
1
vote
1answer
22 views

Whats the difference between k and C-p?

Is there any difference between the behaviour of C-p and k? The seam to be doing the same thing; moving down a line
0
votes
1answer
42 views

Why is my 'noremap % =' not taken into account?

I use a completely remapped layout to match the traditional qwerty action position over a bépo layout. Lately, using NVIM v0.4.3, my binding to map the % to = (format auto) ceased to work. This is ...
1
vote
0answers
16 views

Mapping <C-[> causes input() to not be abortable

The following function, when at the prompt, if one presses <Esc>, then it will print EXIT. function! Testinput() let g:searchString = input("Enter search string: ", 'default', 'syntax') ...
4
votes
1answer
71 views

Why does custom map of <c-w><space> cause mapping delay in terminal mode?

I'm using <c-w><space> to open current terminal buffer in a new tab: tnoremap <c-w><space> <c-w>:tab split<cr> This map cause <c-w><c-w> trigger ...
0
votes
1answer
31 views

Simulate backspace in normal mode

I would like to have the delete key work similarly in normal mode as it does in insert mode, and it's been a bit tricky to map this. Here is what I have so far: :nnoremap <Backspace> i<BS>...
0
votes
0answers
33 views

UltiSnips snippets not expanding in vim

I installed YouCompleteMe and UltiSnips together in order to use snippets. Here is my .vimrc: call plug#begin() Plug 'preservim/NERDTree' Plug 'ycm-core/YouCompleteMe' Plug 'SirVer/ultisnips' call ...
1
vote
2answers
72 views

Usage of timeoutlen and ttimeoutlen

I was trying to set a timeout length to apply to: Key combination presses (for example, pressing gh in netrw); and Exiting modes (for example, zero delay when exiting visual mode). Here is a portion ...
0
votes
1answer
21 views

Easymotion remapping not working (does nothing)

Here's my section for Easymotion in my .vimrc: let g:EasyMotion_do_mapping = 0 let g:EasyMotion_smartcase = 1 let g:EasyMotion_startofline = 0 nnoremap fw <Plug>(easymotion-bd-w) nnoremap fW &...
1
vote
1answer
26 views

Autocmd with a python file not working

I'm using the regular Vim that comes with Ubuntu. I have the following line of code in my .vimrc: autocmd filetype py nnoremap <F10> :w <bar> !python3 %<CR> It's not working, ...
0
votes
1answer
51 views

Why is `vmap` for both Visual *and* Select mode?

Vim has both Visual and Select modes. Select mode is similar to Visual mode in some senses, but different in that when a printable character is typed, Vim will replace the selection with that ...
1
vote
1answer
26 views

Shortcut for binding same command to multiple key

Is there any way to map same command to multiple key without repeating mapping. Like mapping this one inoremap ) <right> inoremap " <right> inoremap ] <right> into something like ...

1
2 3 4 5
21