Skip to main content

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
7 votes
1 answer
862 views

vi (an old AIX vi, not vim): map: I can search, move, yank, or dd, but cannot paste

On regular AIX vi (not vim, just plain old vi): I tried to do the following map, but it fails on the "P" or "p" part with the message Cannot use the put command while inside a ...
Olivier Dulac's user avatar
0 votes
2 answers
30 views

Using filename in mapped command

I am on Neovim, and have ToggleTerm installed. I would like to do :nnoremap <leader><leader>r :ToggleTerm<cr>my_interpreter %<cr> but this will just open ToggleTerm, and run ...
CocoaNut's user avatar
0 votes
0 answers
48 views

How can I resolve "WhichKey: WARNING conflicting keymap exists for mode [...]"

How can I find the source of these errors as reported by :LazyHealth which-key: require("which-key.health").check() WhichKey: checking conflicting keymaps - WARNING conflicting keymap exists ...
Evan Carroll's user avatar
  • 1,433
0 votes
1 answer
109 views

How can I chain multiple commands in one mapping?

These two mappings work separately: nnoremap <leader>zs :let @+=substitute(substitute(join(filter(getline(1,'$'),'v:val=~"^source:"'),"\n"),'^\(source:\s*\)\(.*\)$','\2',''),'...
JitteryNutmeg's user avatar
0 votes
1 answer
46 views

Copying the previous block of code

// some // code 1 // some // code 2 // cursor here I wish to quickly copy and paste the immediate previous block of code (2). By a block, I mean all code that is between two empty lines (...
DatBoi's user avatar
  • 111
0 votes
0 answers
32 views

Remapping telescope's move_selection doesn't work

New to vim. Using Dvorak layout. Trying to remap the move_selection_{next,previous} to t for next and c for previous, to match my text editing mappings. Here's the code: { "nvim-telescope/...
splaytreez's user avatar
-1 votes
1 answer
30 views

How to make mappings for "jump to after next occurrence of character" / "jump to the before previous occurrence of character"?

There are standard keybindings: fx - jump to next occurrence of character x tx - jump to before next occurrence of character x Fx - jump to the previous occurrence of character x Tx - jump to after ...
Anton Samokat's user avatar
0 votes
0 answers
35 views

LINUX OS - Window resizing keymaps not working

This question follows this one. I set some custom keymaps to ease window resizing, such as nmap <A-j> <C-w>-. However, they do not seem to work in any window. But, if I play the command ...
mEm's user avatar
  • 157
1 vote
1 answer
32 views

Remaps to move across windows do not work when in netrw window

Can someone explain why remaps to navigate across windows like nmap <C-h> <C-w>h does not work when in the netrw window? Is there any reason why? Is there a setting to enable them?
mEm's user avatar
  • 157
0 votes
1 answer
34 views

What does this command do?

In vim fandom wiki I found this command: nnoremap \z :setlocal foldexpr=(getline(v:lnum)=~@/)?0:(getline(v:lnum-1)=~@/)\\|\\|(getline(v:lnum+1)=~@/)?1:2 foldmethod=expr foldlevel=0 foldcolumn=2<CR&...
Antonio's user avatar
  • 289
0 votes
2 answers
48 views

How do I remove the delay when using a key remapped to `k`?

I use the Dvorak layout and am trying to start using Neovim. By default, the arrow buttons were scattered all across the keyboard, so I created this script to remap them: local function noremap(...
splaytreez's user avatar
1 vote
2 answers
45 views

How do I swap surround's spacing for opening vs. closing delimeters?

I use vim-surround all day, and it's a constant annoyance to me that I have to reach a little bit farther to hit the closing delimiter when I don't want spaces around the delimited content (which is ...
Eric Burgess's user avatar
1 vote
1 answer
53 views

How do I start a search with the currently selected text?

What to add to init.lua such that / set the CLI with: / followed by the selected text if any / otherwise
user17227456's user avatar
0 votes
1 answer
51 views

How to hide keybinds in which-key.nvim depending on buffer type?

I have been refactoring my nvim setup. I manage my plugins with lazy.nvim. I have vimtex plugin, with following binds: local wk = require"which-key" wk.register({ l = { name = &...
Vladyslav Rehan's user avatar
0 votes
2 answers
29 views

How to get default Generic Keywords autocomplete functionality when LSP is in use?

I used to rely heavily on the default autocompletion provided by the Ctrl + n keys in the insert mode. But when I started to use NeoVim and its LSP functionality, the keys started to provide a ...
d.k's user avatar
  • 704
0 votes
1 answer
29 views

Neovim configuration to join lines with BACKSPACE [duplicate]

On insert mode, at the end of the line, how to make Neovim joins the current line with the next one when hitting Del? And harmoniously, on insert mode, at the start of the line, how to make Neovim ...
user17227456's user avatar
3 votes
2 answers
563 views

Is there a reliable way to know whether a keybinding is already in use?

When making a custom keybinding, it's always in the back of my mind that I might be conflicting with some other keybinding, especially one from a (not loaded) plugin. Hence the act of pressing the ...
stevec's user avatar
  • 133
0 votes
1 answer
38 views

<CR> behavior unexpectedly changed in normal mode

I recently made a bunch of changes to my vim configs and I later noticed that the enter/<CR> behavior on normal mode has changed. I used to be able to select and execute a line in the command ...
Daniel Baulig's user avatar
0 votes
2 answers
38 views

Any commands to switch to the window on the far left or right?

Let's say I have a grid of 3x2 windows open and I am focused on the bottom right one. I want to switch to the one on the bottom left with one command, not move left twice. Vice versa as well. There's &...
Oneechan69's user avatar
1 vote
1 answer
18 views

Paste and enter insert mode at the beginning of line, terminal bash Lunarvim

When editing a text file, p and I pastes what I copied and gets me to enter insert mode at the beginning of line. But in terminal (executed by term bash) this not works. p pastes somthing, but I or i ...
Crispy13's user avatar
  • 113
1 vote
1 answer
44 views

Show only 1 line from the prior screenful?

How may I tweak the Vim <C-F> command to show only 1 line from the prior screenful? Well I tried to map a normal mode command that scrolls forward by 1 line less than the number of lines in the ...
gregrwm's user avatar
  • 13
0 votes
1 answer
33 views

Get relevant script for (all) mappings

vim.api.nvim_get_keymap('n') does return a table with lnum (line number) , but not with the name of the script that set it (or path). I only know that verbose nmap .. does it, but prefer to avoid it (...
eyal karni's user avatar
  • 1,136
0 votes
2 answers
40 views

Select current Line from normal mode without changing cursor position AND without selecting the new line character at the end

What I am asking about can be done using multiple ways but none of them fully achieves what I want. For an instance : 0vg_ selects the current line without the new line character at the end but ...
pic810's user avatar
  • 1
0 votes
0 answers
16 views

Is there a way to define a "toggle breakpoint" mapping in termdebug?

How to implement a there_is_a_breakpoint_on_this_line condition to be used in the following if-then-else block in termdebug? if there_is_a_breakpoint_on_this_line <cmd>Clear else <cmd&...
Barzi2001's user avatar
  • 650
1 vote
2 answers
27 views

How do I bind a key to open an ipython shell in a new split

I want to bind a key that will open a new terminal running ipython in a vertical split. So far I have figured out opening a new terminal in vertical split: local map = vim.api.nvim_set_keymap opts = {...
Anurag Patil's user avatar
1 vote
1 answer
36 views

Can I bind with numbers in the binding, d{n}c to d{n}l for example?

I am trying to bind my keys in such a way that if I press d, then a number, and then c it deletes that number of characters, like d, number, l would do. So for example if I press d5c it would do d5l. ...
vosjedev's user avatar
0 votes
1 answer
65 views

Swap K and T not working

I'm trying to swap the K and T keys. T should give me help, K should do "till (backwards)" Moreover, the help command only makes sense in normal mode; the till action makes sense in normal, ...
ElRudi's user avatar
  • 191
2 votes
2 answers
61 views

How can I jump outside the scope of LaTeX delimiters?

I want to define insert mode mappings that will jump outside the scope of any delimiter I'm in (forward/backward). Where "delimiter" is in the broad sense of LaTeX delimiters, so not only {},...
Ur Ya'ar's user avatar
  • 127
1 vote
1 answer
32 views

Ctrl+w Shift+n after :term does not start a normal window

In Vim, you can start the terminal by :term, and Ctrl+WShift+N allows you to treat the terminal window as a normal Vim window. I tried the same in NeoVim, but it does not work. Is it an expected ...
T_T's user avatar
  • 189
0 votes
0 answers
36 views

How to fix a direction keys remapping bug?

I don't want to change the default position of my right hand to use the direction keys, also I'd like to be able to use them in the insert mode. So I've got the following part in my .vimrc file: "...
Fyodor's user avatar
  • 1
1 vote
1 answer
161 views

Neovim command mode keymap without executing

In my vimrc I had a mapping to read the word under the cursor (<C-R><C-W>) and put it on the command line as an argument ready to search with the GrepperRg tool: nnoremap <leader>gg :...
Noel Evans's user avatar
1 vote
2 answers
225 views

init.lua - Remove default mapping recursively

I want to use the i_CTRL-G mapping to abort the current cmp selection, but i_CTRL-G is already used by neovim. I tried to delete the mapping with this: vim.keymap.del('i', '<C-g>') But it just ...
Bog's user avatar
  • 509
1 vote
3 answers
76 views

Mapping two slashes to braces deletes two previous characters

In ftplugin directory I created pascal.vim with the following mapping: imap // <ESC>hc2l{ }<ESC>hi The aim of this mapping is to replace two forward slashes with braces and leave the ...
Pontiac_CZ's user avatar
0 votes
2 answers
44 views

Why does ":normal gv" keep removing one line from my visual block?

I'm trying to create a vimscript function that does a substitution on a visual block and then highlights the visual block again with gv. For instance: function! MySubstitution() s/foo/bar/ ...
wxz's user avatar
  • 155
0 votes
2 answers
28 views

How to use register expression with visual selection?

I have this key map in my Vim configuration: nmap <leader>rn :%s/\<<C-r><C-w>\>/ But for this code from php I have a problem. $text=$home_intro['text']; Because, if cursor is ...
serii 's user avatar
  • 91
0 votes
3 answers
48 views

Swap a 0 under the cursor with a 1 and vice versa

Assume that, in normal mode, the character under the cursor is either 0 or 1. I want that, upon pressing a key (say F6), it is swapped to the other one.
brad's user avatar
  • 131
2 votes
5 answers
546 views

auto enclose word under cursor with {} () []

Usually I would like to enclose the word under cursor with [, ], (, ), {, } by simply selecting the word (select mode or visual mode) and typing [ (or {, )), for example resulting to: hello to [hello]....
xyx's user avatar
  • 466
0 votes
0 answers
14 views

Make vim.execute function dot repeatable

I made the following keybinding to substitute "a/b" with "\frac{a}{b}". -- convert / to \frac{}{} -- (dot repeatable) _G.div_to_latex = function() vim.cmd('execute "normal f/...
robertspierre's user avatar
0 votes
1 answer
22 views

mapping works on next line instead of current

I have this mapping in my .vimrc: inoremap <C-f> <Esc> : exec '.!printf "world"'<CR> I expected it to replace the current line with "world" after pressing C-f in ...
k-dx's user avatar
  • 3
0 votes
2 answers
49 views

yank to register in a map expression

I have this mapping that starts a substitute command with the selected text prefilled: xnoremap <Leader>s "vy:% s#\v<C-R>v#<C-R>v#g<left><left> When I select the ...
MaxGyver's user avatar
  • 231
1 vote
4 answers
41 views

Rotate list of lines

Assume you have the following block of text (yes: I am using vim-latex, but this is not relevant): \begin{itemize} \item 1 % [[[ \item 2 \item 3 \item 4 \item 5 % ]]] \item 6 \end{itemize} My ...
brad's user avatar
  • 131
0 votes
0 answers
59 views

In Neovim which-key, how can I show the command instead of the description?

I'd like to make the label for each keymap the keymap.rhs instead of keymap.desc in the folke/which-key.nvim UI menu, even when they are both defined in the keymap. keymap.rhs is displayed by default ...
ql88888's user avatar
2 votes
1 answer
134 views

Vim macro to copy paste text

I would like to copy paste everything after a comment into the [] place holder of the next line. E.g.: %This is a comment Target box: [] with some more text The desired output would be: %This is a ...
Hugh's user avatar
  • 23
2 votes
1 answer
32 views

Neovim: Making a function that checks the beginning of line and acts depending on it

Extra details, The whole code: local obsidianSettingsGroup = vim.api.nvim_create_augroup('Obsidian Group', { clear = true }) vim.api.nvim_create_autocmd('FileType', { pattern = {'markdown'}, ...
Crimson Crusader's user avatar
1 vote
1 answer
475 views

How do I enhance the '~' command to toggle the "+/-" signs as well?

I need to make a report about investment everyday. It requires a lot of changes of the sign of figures. (from - to + or from + to -) Is there a simple way to overload (extend) the ~ command (switch ...
Charles Jie's user avatar
1 vote
2 answers
43 views

Help understanding this :global command

I have this command to prune :verb map down to only my plugin mappings: g!^\~/vimfiles/plugin/^-1d _ It also needs :$d to remove last line that has verbose comment "Last set [...]". Can ...
Tom's user avatar
  • 77
1 vote
3 answers
302 views

Order of sourcing scripts

I've recently been organizing my vimrc and putting mappings into vimfiles/plugin and vimfiles/ftplugin files (not to mention abbs, functions and commands). However, these scripts are sourced before ...
Tom's user avatar
  • 77
0 votes
1 answer
80 views

Keymaps get reset upon switching focused window back to Neovim instance

Lately I've been running into a strange issue where, upon switching focus in and out of Neovim to other windows, some of my keymaps will not be set properly upon re-focusing and instead use the ...
Devildude4427's user avatar
0 votes
1 answer
36 views

Keybinding to quickly update (aka prettify) React indentation

This is an example of the original code <Text fontWeight="bold" size="lg" color="turquoise.500">Use Search V2 Beta</Text> and I want a keyboard shortcut (say ...
abbood's user avatar
  • 743
0 votes
1 answer
273 views

Conditional Key Mapping in Neovim Based on File Type

How can I do in nvim if the file type is js do this: vim.api.nvim_set_keymap('n', '<A-1>', [[:w | split term://node % <CR>]], { noremap = true, silent = true}) else if file type is lua do ...
user50451's user avatar

1
2 3 4 5
32