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
1 answer
44 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 ...
2 votes
1 answer
20 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'}, ...
1 vote
2 answers
38 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 ...
1 vote
1 answer
407 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 ...
34 votes
4 answers
79k 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 ...
0 votes
1 answer
48 views

MacVim: <Delete> key does not work in a terminal window

I happened to find that we may open 'Terminal windows' in Vim and am happy to stop using terminal app. (It's available in v8 and v9) However, when I have a typing mistake, pressing Delete key does not ...
6 votes
1 answer
1k views

Why can't I type certain non-ASCII letters?

I recently had a need to type the letters æ, ø, and å. For context, these are available on my physical keyboard, and work fine in other programs. It's also a Norwegian keyboard (+ layout), if that's ...
1 vote
1 answer
777 views

<Tab> out of insert mode - lua keymap

I'm a relatively new neovim user. I use nvim-autopairs to always induce matching (, [, {, ', " character pairs, and automatically placing my cursor inside them. As an example, in insert mode, if ...
1 vote
3 answers
262 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 ...
1 vote
1 answer
184 views

Can't figure out where this mapping comes from

For more than a year, I have unmap <C-X> in my .vimrc because I can't figure out where this mapping comes from. I used verbose map <C-X> as suggested in another topic, it returns v &...
0 votes
1 answer
32 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 ...
0 votes
1 answer
71 views

Mapping works only on select mode and not with visual mode?

I have a custom "plugin" I use extensively for verilog development, and I have a few functions I obviously call using respective mapping. For example: function! FormatIoInstance() range ...
0 votes
1 answer
44 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 ...
1 vote
1 answer
570 views

Special characters, escaped special characters, escape sequences, and terminal codes

I refer to those 4 terms using terminology picked up by various sources: Steve Losh, in his Learn Vimscript the Hard Way's chapter 16 refers to things like <cr> (these 4 characters typed in a ...
117 votes
9 answers
257k 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.
0 votes
1 answer
96 views

How to debug this problem with the :map command?

I was trying to view my key mappings because I can't seem to jump through parts of snippets in UltiSnips. So I type :map and hit enter and it comes up with the start of the list, but there I can't ...
0 votes
3 answers
92 views

How to map q for saving and quitting?

I was reading the Vi documentation, by Joy and Horton and on section 6, 6.9 Macros they give a way to map q to save and quit: :map q :wq^V^VCR CR When trying that out in Vim it creates a new file ^V^V ...
0 votes
1 answer
235 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 ...
2 votes
1 answer
45 views

What is set_opfunc?

I'm configuring toggleterm.nvim, and in particular I'm putting this keybinding in my config file, as suggested by the plugin author here: -- Send motion to terminal vim.keymap.set("n", "...
0 votes
1 answer
28 views

keybindings that change mode: cannot use keybindings on the new mode

I have defined the following keybindings: local opts = { noremap = true } local ll = "<leader>i" opts["desc"] = "Send visual lines" vim.keymap.set("v", ...
1 vote
1 answer
408 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, "<&...
1 vote
1 answer
55 views

Redraw cursor at absolute top or bottom while keeping scrolloff

My goal is to remap zt and zb to set scrolloff=0, run zt or zb, then set scrolloff back to its original value. I like the context when scrolling, but when I hit one of these keys I really want the top ...
1 vote
4 answers
2k views

Toggle Vim Terminal with Mapping like VS Code

I am trying to implement toggling of the Vim terminal like VS Code by doing <C-~>. But am not sure how to go about it. I find executing :term to open and to close tedious. I figured having a ...
0 votes
0 answers
13 views

":term" style completion in vim.ui.input()

I currently have the following keymap: vim.keymap.set('n', '<leader>sr', function() return ":vs | term " end, { expr = true }) This drops me into a vim command where I can complete ...
1 vote
2 answers
124 views

jedi-vim prevents mapping [[ to * and ]] to #

jedi-vim appears to prevent mapping [[ to # and ]] to * mapping does not alter behaviour produced by [[ or ]] in .py files when jedi-vim in bundle folder (and does alter behaviour in .py files ...
0 votes
1 answer
26 views

AstroNvim in diff mode: navigating to next difference

In plain old (n)vimdiff, one can jump to the next/previous difference using [c or ]c respectively. (says :help diff documentation, at least) Not so much in my AstroNvim; running nvim -d -R old.txt new....
0 votes
2 answers
50 views

How to automatically fold html tags?

If I have this react code: <tag> .. </tag> and the cursor is on top of <tag>, tapping on % will make the cursor jump to the closing </tag>. I want to create a vim key mapping ...
1 vote
1 answer
30 views

Vim keybinding case-insensitive

I would like to have a key bindings on <C-l> and on <C-L>. But it seems that Vim is case-insensitive regarding this. For example, if I have a Vim script like this: imap <C-l> <C-W&...
10 votes
1 answer
17k views

How to enter tilde (~), back tick (`) and special chars with a non-US keyboard?

I usually use Vim with an Italian keyboard (I'm from Italy), (mainly in an Ubuntu Linux Virtualbox guest from a Windows host). I have problems when I have to enter some frequently used characters (...
0 votes
1 answer
161 views

Can I make a new mode in Nvim?

I want to create a new mode other than normal, visual, or insert because I want to: change the functions of all keys at once allow remapping preserve the mappings of other modes and retrieve when go ...
2 votes
3 answers
101 views

Best way to keybind subsequent substitutions in visual mode

I need a keybinding that, given some text selected in visual mode (line visual mode, block visual mode, or whatever): Add > _ before the text Add _ after the text In case of empty lines, > ...
0 votes
1 answer
19 views

Efficiently create "key-key" pairs from "key-value" pairs

I'm looking for an efficient way of going from this: AIRFLOW__SMTP__SMTP_HOST=asd.sadas.dashasd AIRFLOW__SMTP__SMTP_STARTTLS=False AIRFLOW__SMTP__SMTP_SSL=False AIRFLOW__SMTP__SMTP_USER=asdash@...
0 votes
0 answers
53 views

How do I allow higher function keys (F13-F24) in Vim?

My vim sessions use term=win32 and my F13-24 keys do not work, but they are permitted I believe from checking :help t_ku. I've gained shallow insight on how to connect vim keycodes to term keys via &...
0 votes
1 answer
1k views

super key not working in Neovim on Linux

I'm trying to create a shortcut, but I can't get vim to recognize my super key. I tried the following combinations: lvim.keys.normal_mode["<A-h>"] = ":BufferLineCyclePrev<cr>...
0 votes
0 answers
339 views

How to map Enter, Ctrl-Enter and Shift-Enter in Neovim (nvim-cmp)?

According to this My Kitty conf map shift+enter send_text all \x1b[13;2u map ctrl+enter send_text all \x1b[13;5u According to this My Tmux conf bind -n S-Enter send-keys Escape "[13;2u" ...
1 vote
3 answers
59 views

Block select unequal lines

I often have code of the form: money = double(123) user_level = user["level"] timer = get_time() and want to have: money = double(123) user_level = user["level"...
1 vote
0 answers
33 views

How to prevent cursor shift when using `<cmd>` (like `<c-\><c-o>`)?

I currently have inoremap <M-j> <C-\><C-o>gj in my config but I would like to avoid triggering all InsertLeave autocommand when doing this. inoremap <M-j> <cmd>normal! gj&...
1 vote
1 answer
44 views

Can I map Alt+j without mapping Escape followed by j to the same thing?

If in insert mode I do Ctrl+v and then press Alt+j, I see ^[j inserted, with ^[ being actually a single character. That's the same I get if I press Escape followed by j instead of Alt+j. I've known ...
0 votes
1 answer
35 views

How do I append every single occurance of a phrase with that phrase plus an incremental number?

I am using the Vim extension in VSCode. I want to append every occurrence of a phrase, for example: breadCrumbLabel In my codebase with the instance number. The first occurrence would have to be: ...
1 vote
1 answer
47 views

Make operator that doesn't change gv

I'm trying to redefine my inner and outer line text objects so that they don't change gv. First I had onoremap <silent> il :<C-u>normal! $v^<CR> I changed it based on Using visual ...
0 votes
2 answers
46 views

How to combines two mappings into one in Neovim?

I have two keymaps like this vim.keymap.set("n","te","<C-w>l|ia.exe<CR>") vim.keymap.set('n', 'c', ':w <bar> !gcc "%" -o "~/Newfolder/...
2 votes
2 answers
200 views

How can I make Tab insert tabs at the start of the line only, and spaces after text?

What I want to achieve I would like to setup vim such that tabs are inserted on lines until another character is inserted, after which, further tabulation results in spaces (similarly to expantab). ...
1 vote
1 answer
67 views

"gi" doesn't work in my buffers. No error

I recently learned about gi. It doesn't seem to work in my PHP buffer. I get no error message. I expect gi to go to insert. I also write with markdown. In this buffer I get an error that says I do not ...
3 votes
3 answers
236 views

Perform action after invoking a <Plug> command

I use the following mapping to send code to a REPL using vim-slime and tmux: nmap <buffer> <S-CR> <Plug>SlimeLineSend How can I perform an action after I invoque this mapping?. For ...
1 vote
1 answer
42 views

Normal mappings not working anymore in Vim 9.0 for foreign and special characters

I used to have the following key mappings within _vimrc: nmap è "_ddP nmap ò yaw nmap à "_dwP nmap § .n working in Vim 7.4 on Windows and an Italian keyboard. Now, after upgrading to Vim 9....
1 vote
2 answers
62 views

Is there a default normal-mode command for `:write`?

I know ZZ will write and quit, and ZQ will quit without saving. Is there another such command to write the buffer without doing anything else, or should I map one myself? I'd like to know if there's ...
1 vote
1 answer
44 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> ...
2 votes
1 answer
275 views

Cannot remap Control Backspace and Control Shift Z in Windows

What's up with Control Backspace, and Control Shift Z for the Windows cmd terminal? I cannot seem to remap them. All the former does in Insert Mode is type Î, and then make the "z" letter ...
2 votes
1 answer
376 views

<s-f10> cannot be mapped in neovim

At least not on my mac. it works fine in vim. is this simply an error in nvim?
28 votes
5 answers
13k 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 ...

1
2 3 4 5
31