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

How to search and replace the highlighted text from visual mode?

What works (normal mode): Search/highlight the word the cursor is on. Replace the word the cursor is on. Note that the word doesn't get erased when I get prompted to replace it, allowing me to make ...
Vladimir's user avatar
  • 135
1 vote
4 answers
98 views

Vim mapping to make function parameters become multi-line?

I'm looking for a minimal way to convert code that looks like this: my_function(param1, param2=value2, param4=a_function_call()) into something like: my_function( param1, param2=value2, ...
beyarkay's user avatar
  • 205
1 vote
1 answer
80 views

Restricting `bufdo` to Specific File Types

I'm currently using a key mapping in Vim that's causing some issues. The mapping is: nmap <buffer> <Leader>tr :silent bufdo TaskWikiBufferLoad<CR> The problem is that the command ...
faceclean's user avatar
  • 113
0 votes
0 answers
39 views

Why is key binding for CTRL-L key messed up?

I have run into a Vim key binding issue at the office recently. On the Linux system where I do my development work, while running Vim the CTRL-L key no longer redraws the screen. The .exrc file in my ...
Barry Kimelman's user avatar
0 votes
1 answer
34 views

How do I create key mappings for Windows and/or nano Shortcuts?

Having used text editors (mainly Notepad/++) and some IDEs on MS Windows, I've become familiar with their Alt and Ctrl shortcuts to the point that I use them automatically. Having used nano on a GNU/...
Agi Hammerthief's user avatar
1 vote
1 answer
49 views

How to save the files when global replace completed in one command line

I have so many huge size of files and always need to do search and replacement so I map the command as nnoremap aa :let i=1 \| g/regexp/ s/^/\=printf("%1d. ",i)/g \|let i =i+1\|:w! 1.txt ...
M_Sea's user avatar
  • 137
1 vote
2 answers
71 views

How to replace a space after a word with a line break (new line)?

In Neovim, I used the J command to join lines, and now I'm looking for a keybinding in normal mode that can do the opposite: replace the space after a word with a line break. I've tried a few "...
pwanker's user avatar
  • 11
1 vote
1 answer
196 views

How is the right hand side of an <expr> binding evaluated?

I like using <cr> to save a file, except in a quickfix window where I want <cr> to enter the directory or file shown. Here's one way to achieve this (works as a .vimrc by itself). I'm ...
Greg Nisbet's user avatar
  • 1,839
1 vote
1 answer
57 views

File Type dependent key mapping valid only for that specific filetype

I am aware that you can either use an Autocommand or defining a key-binding in some ftplugin file. However, once the key-binding is defined, it will stay, no matter the filetype. However, imagine that ...
Barzi2001's user avatar
  • 481
1 vote
1 answer
25 views

Clean the placeholder text after multiple jumps

I am studying the book "Hacking Vim" by Packt publishing. In chapter 4 the author gives us an example of a template for HTML files. I followed the guide of the author. Created a file ~/.vim/...
user4035's user avatar
  • 133
1 vote
1 answer
26 views

How to open NERDTree quickly?

I have read the NERDTree help and found that to close NERDTree, we could type :q. How can I open NERDTree the shortest way? I am now typing :NERDTree to open NERDTree, but I think it is too slow for ...
Dolphin's user avatar
  • 113
2 votes
1 answer
76 views

Cannot overwrite existing keybinding Shift+k in Neovim

I want to map Shift-k (K) as 5k but it is mapped to call a function vim.lsp.buf.hover() These commands dont work: map <S-k> 5k nmap <S-k> 5k noremap <S-k> 5k nnoremap <S-k&...
Sahaj Bhatt's user avatar
2 votes
1 answer
89 views

How do I capitalize the first letter of a list item (ignoring the bullet)?

I have a list: - item one - item two - item three and this as well. and I want to capitalize the first word in a line. However the two bindings that I know to go to the first character of a line '0' ...
alejandro_hagan's user avatar
3 votes
1 answer
129 views

# key causing delay in Neovim

Whenever I input # in Neovim I get delay. I tried to fix this with nnoremap # <nop> vnoremap # <nop> In my init.vim but that seemed to only fix it in non .tex environments. I assume this ...
Maths Wizzard's user avatar
1 vote
1 answer
68 views

How to add a keymap for a visual mode plugin command and pass it the visually-selected range?

I have the linediff.vim plugin installed. Its main command :Linediff only works for visual mode, to which I'd like to add a keymap for this command. I'm using Neovim's Lua API, so I tried this: vim....
Jethro Cao's user avatar
2 votes
2 answers
505 views

How to validate and reference digraph /special character in Vim?

I want to remove the ending section of my output that typically follows the below pattern: ^[[2D[^[D but my regex will not allow me to select the ^[ parts of the word. Note on my Vim that part shows ...
alejandro_hagan's user avatar
2 votes
1 answer
47 views

How to use function argument in a mapping?

Let's take a look at the example below. function! Print (text) echo a:text endfunction function! Mapping_test (parameter) nnoremap m1 :call Print (a:parameter)<CR> nnoremap m2 :call ...
Artur Pyszczuk's user avatar
1 vote
2 answers
112 views

Conditional keymap

Is it possible to map a key (e.g.: Alt h) to _ (to go to the first character in the line), but to |, when already there? Perhaps in nvim/lua? What I have tried is: vim.keymap.set({'v', 'n'}, '<A-...
Alois Pichler's user avatar
2 votes
2 answers
852 views

How to disable hjkl movements?

Before you crucify me please note I have a an Ultimate Hacking Keyboard and I already can move with arrow keys on the home row :) I suppose I don't have to since I have a different layer to activate ...
Rick Penabella's user avatar
0 votes
1 answer
68 views

Can not remap command using mapleader and keymap

I am trying to set <leader>pv as :Ex but always it shows E492: Not and editor command: ,pv Basically the newly added command mapping is not setting up or saving properly. I do not know what to ...
piedpipr's user avatar
  • 101
0 votes
1 answer
51 views

Neovim Markdown toggling bold keybind

I am trying to make it so I can have a keymap for toggling things like bold in a markdown file. I used to use vscode with the markdown plugin and they offered the option to, with a simple keybind, ...
Educpf's user avatar
  • 33
1 vote
1 answer
167 views

vim.keymap.set issue

I've tried to make a key map as follows: vim.keymap.set('x', '<leader>n', function() -- Here <leader> is <Space> line1r, line1c = unpack(vim.api.nvim_buf_get_mark(0, "<&...
HRC's user avatar
  • 11
1 vote
1 answer
473 views

Neovim/Lua: How to use vim.keymap.set with vim.v.count

I'm trying to add a count to one of my keymap bindings. vim.keymap.set("n", "<leader>o", vim.v.count .. 'o<Esc>') does not work as expected. My intention for this ...
agshe's user avatar
  • 23
1 vote
1 answer
59 views

What is CTRL-W Tab doing?

By pure coincidence, I hit CTRL+w and then Tab while editing a C++ file, and what happened is that the window was horizontally split and the new window loaded the buffer where the word under the ...
Enlico's user avatar
  • 2,172
2 votes
1 answer
67 views

How to map Ctrl-Delete?

I am new to Neovim and its configuration. I would like to know, first of all, what is your opinion on maintaining the functionality that Ctrl-Delete has outside the editor. In my case, it deletes the ...
Educpf's user avatar
  • 33
0 votes
0 answers
38 views

How to use <Leader> in a normal command today?

The answer to the question with the same title doesn't seem to work for me. Not sure if the behavior has just changed overtime. To reproduce the issue, open Vim via vim -Nu filebelow.vim, where the ...
Enlico's user avatar
  • 2,172
0 votes
0 answers
52 views

leaderkey binding errors in Mingw64 (git bash)

Learning Vim and love it. I’m having challenges getting the below leaderkey to work in my git bash instance of Vim. I want to: while in normal mode I want to insert new line under the current line Go ...
alejandro_hagan's user avatar
0 votes
2 answers
30 views

How to paste from register within a keybinding expression?

I want to open the file of the path within my clipboard in the current buffer using a key binding. <CMD>e <C-r>+<CR> is the thing I want to do. Doing this manually works, but doing ...
Martin Braun's user avatar
2 votes
1 answer
81 views

Make { ( and ) } normal mode motions skip blank lines

Normal mode ) } and ( { navigate paragraphs and lines but they don't skip blank lines. (They land on them.) This is obviously the preferable behavior when writing code, but when writing "normal&...
Anthony's user avatar
  • 55
1 vote
1 answer
28 views

What does `@<Plug>` mean in a mapping?

I have vimwiki and vim-vinegar and they conflict on an nmap. Calling map - shows these two maps: n - @<Plug>VimwikiRemoveHeaderLevel n - <Plug>VinegarUp unmap ...
fbence's user avatar
  • 603
1 vote
1 answer
34 views

configure omnicomplete to use `gj` `gk` to go the next and previous completion

Having decided to use the arrow keys to navigate instead of hjkl, and having decided that I want to move to the previous screen line, not actual text line, I have put this on vimrc nnoremap <Up> ...
Rho Phi's user avatar
  • 111
1 vote
0 answers
27 views

How to programmatically input a motion in operator-pending mode without switching to normal mode?

I need to programmatically input a motion in operation-pending mode, kinda like using :normal!, but without switching modes, so the operator still takes effect. Context I'm writing a script that ...
Tae's user avatar
  • 2,085
0 votes
1 answer
31 views

Lua insert mode mappings are pasting the rhs in buffer instead of executing them

In my init.lua, I've got some keys bound to some actions in insert mode. e.g.: vim.keymap.set('i', '<C-j>', '<Plug>(easymotion-bd-w)') But when I press Ctrl-ew, instead of highlighting ...
technicguy1's user avatar
1 vote
1 answer
43 views

Behaviour of Neovim when in insert mode is different from expected

I recently switched from vim to neovim. I have the following keybindings in neovim: vim.keymap.set("i", "0", "<Esc>la", { noremap = true }) vim.keymap.set("i&...
caffeinemachine's user avatar
2 votes
2 answers
159 views

How to replace till the end of the line without joining lines?

One of the main usage I have for selection is replacement. Suppose I have: Jane: Hello foo1 & bar1 John: Hello Jane: Hello foo2 and bar2 John: Hello Jane: Hello foo3 or bar3 John: Hello That I ...
Vivian De Smedt's user avatar
3 votes
2 answers
201 views

Vim yank from cursor position to end of nth line

I am trying to yank from my cursor posintion to end of nth line defined by a motion. So for the below text Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec non quam et erat pharetra ...
gmtek's user avatar
  • 145
1 vote
2 answers
208 views

Substitution command in neovim remaps not working

I simply want to map < leader> pu to erase all occurrences of the carriage return character (represented as ^M) in a file. I can execute the command: :%s/\r//g and it works. Any attempts to use ...
fireq1's user avatar
  • 13
0 votes
1 answer
35 views

Map `^[` or `<c-[>` in neovim (without mapping `<esc>`)

At least on nvim-qt, <c-[> or ^[ can't be mapped without mapping <ESC> as well (as it usually translates to it!
eyal karni's user avatar
  • 1,058
1 vote
1 answer
134 views

How can I run a java file from a neovim terminal using a remap

For a bit of background, I'm trying to set up a function that runs a java file in Neovim, I've tried using the following autocmd: vim.api.nvim_create_autocmd( { "FileType" }, { ...
Nico Elbers's user avatar
0 votes
1 answer
43 views

NeoVim - Single Redo my mapping containing an <Escape>

Well I know it doesn't work because of the <Esc>, but is there any way to do it so that .(vim single redo) repeats the whole mapping and not only the part after the first <Esc> (without ...
Pixelbog's user avatar
  • 417
-1 votes
2 answers
89 views

What are the letter keys in vim that can be mapped along with Alt and Ctrl?

Probably the most frustrating/lame part of using vim has been the fact that a lot of the easy-to-imagine shortcuts have already been mapped to something else by the developers...For some reason, <C-...
user avatar
0 votes
0 answers
48 views

In Neovim where is {lhs} of triggering a keymap stored? Can we access it?

If we set a keymap that {lhs} is abc in normal mode. For example, local opts = { noremap = true, silent = true } vim.keymap.set('n', 'abc', function() print("Keymap abc!"), opts) If we type ...
HRC's user avatar
  • 11
0 votes
1 answer
42 views

Insert current branch name in insert mode in Neovim

I'd like to create a hotkey to insert the current branch name directly in insert mode with the hotkey <C-b>. I use the plugin gitsigns which has a variable vim.b.gitsigns_head containing the ...
Marc's user avatar
  • 113
3 votes
5 answers
835 views

Is it possible to type a single quote/paren/etc. when you have Vim mapped to always print two?

Recently I have been experimenting with ways to improve Vim's efficiently with keyboard mappings, and I have these mapped in order to make Vim behave like a graphical IDE: inoremap " ""&...
user avatar
1 vote
1 answer
161 views

Is there any difference in mapping commands with <Cmd> or with :?

As per title, is there any difference in mapping commands when using <Cmd> or : ? For example, is there any difference between the two following mappings? nnoremap <leader>c :close<cr&...
Barzi2001's user avatar
  • 481
0 votes
1 answer
292 views

Opening files from vim-fugitive's :GcLog

When I'm in :GcLog how do I go to the source file? The documentation shows: <CR> Open the file or |fugitive-object| under the cursor. But, I've only been able to open up &...
Zach W's user avatar
  • 103
0 votes
0 answers
70 views

How to load method definition in a popup?

This is a followup to this question, where I would like to load the method definition in a pop-up rather than a split screen (or the whole screen for that matter). Attempt 1: using nui.vim I’m using ...
abbood's user avatar
  • 671
2 votes
0 answers
32 views

Consecutive pressing mapped function keys emits unwanted "^[[I" in input buffer in Ubuntu 22.04

OS: Ubuntu 22.04.2 (ubuntu-22.04.2-desktop-amd64.iso) Vim: vim-gtk3 (8.2.3995-1ubuntu2.7 amd64) vimrc: nnoremap <F7> : ! g++ % -o %< <CR> nnoremap <F8> : ! time ./%< <CR> ...
fstqwq's user avatar
  • 21
0 votes
1 answer
31 views

How to change the behaviour of <c-w>v?

Say that I have only one window on the screen. When I hit <c-w>v I got a vertical split and the cursor jumps in the window on the right. Instead, I want the cursor to stay in the left window ...
Barzi2001's user avatar
  • 481
0 votes
1 answer
375 views

Shortcut to open definition of variable in a vertical split with Neovim mapping

This is a follow up question to this post where I would jump to the definition of a variable in a vertical split for ctags. I’m currently using an lsp language server like so: local bufopts = { ...
abbood's user avatar
  • 671

1
2 3 4 5
31