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
vote
2answers
140 views

Double Press Override for 0 Key

My .vimrc remaps 0 to ^ in normal and visual+search modes. :nmap 0 ^ :vmap 0 ^ Ideally, I would like 00 to go to the true beginning of the line (i.e., what 0 does by default). Is this possible in a ....
0
votes
1answer
28 views

Macro won’t repeat when remapping <esc>

I remapped vv to <esc> inoremap vv <esc> "some notes cnoremap vv <esc> When using a macro, it can't be repeated. For example: qaifind^Mvvq,then @a and @@ works fine but 2@@ ...
0
votes
1answer
632 views

How to map NerdTree commands?

I am used the vifm's hjkl key maps to navigate and open files. After installing NERDTree , I find it difficult as now the l key wont open file but will just move the pointer to the left( unlike in ...
0
votes
1answer
26 views

Sending two keys in series during autocompletion confirmation

I have the following mapping: inoremap <expr><CR> pumvisible() && complete_info().selected != -1? "\<C-y>" : "\<CR>" inoremap <expr><Space&...
0
votes
1answer
23 views

How to expand a value to place it in the ex command?

The goal is to create a mapping that will: create a mapping for the user --> remap does the trick that gets the current expression under the cursor --> expand('<cexpr>') will do the trick ...
0
votes
1answer
47 views

Key mapping for converting `((` to `\left( | \right)`

I would like to have something in .vimrc where when I type (( in insert mode, it automatically converts that into \left( | \right) with the cursor position at | in insert mode. Any ideas? I also would ...
0
votes
1answer
53 views

noremap in .vimrc for YouCompleteMe does not work

noremap <leader>gdf :YcmCompleter\ GoToDefinition<cr> noremap <leader>gdc :YcmCompleter\ GoToDeClaration<cr> noremap <leader>gi :YcmCompleter\ GoToInclude<cr> ...
0
votes
1answer
32 views

Can I make old Vim treat Alt key mappings <M-..> as Esc-prefixed, like Neovim and other CLI software(e.g. bash) do?

Do Vim users use Alt key for mappings? If yes, how exactly? As it is known, there are 2 common ways of handling Alt key in CLI software: either <Esc>-prefix or 8-bit. It seems like Vim chooses ...
0
votes
1answer
13 views

How can I leave completion mode keeping the completion result in a binding when there's no popup?

Currently: I have some key binding A → ^X^O (in insert mode) to omni-complete something I have some key binding B → ^Ogj to temporarily do something in normal mode (in this case, move down a display ...
6
votes
2answers
1k views

Ctrl-A and Ctrl-X doing the opposite of what they should

I had the following piece of Markdown text that I wanted to edit: * 2-6 for a moka pot * 7-10 for a drip machine * 5-12 for a pour-over When I had the cursor over the number 6 in the first bullet ...
0
votes
1answer
138 views

Mapping Leader to a Ctrl combination not working/being ignored in NeoVim mappings?

I'm trying to map my leader to <C-s> and local leader to <C-q>, in my NeoVim (0.5.0) init.lua file. I know Ctrl-S and Ctrl-Q are software flow control, and I mainly use the terminal ...
1
vote
2answers
22 views

Insert mode remap to insert an underscore

I am starting to have issues with my pinky finger. I tend to write variables and functions using underscores as in my_variable. I would like to find a way to avoid having to press "shift + -"...
1
vote
1answer
106 views

Remap enter Terminal-normal mode Neovim to something else than Esc

I have remaped enter terminal normal-mode to <Esc> with: tnoremap <Esc> <C-\><C-n> and it does work. But I am using zsh vi-mode, which also requires the use of <Esc> to ...
0
votes
0answers
24 views

Is is possible to include other behaviour in a keymapping which would normally invoke a <Plug>?

I am working with a plugin which exposes mappings via <Plug>. For example, let's say it has a mapping for <Plug>XYZCommand. Then, I can put the following in my ~/.vimrc: nmap a <Plug>...
6
votes
4answers
598 views

Prevent the cursor from moving to the start of the yanked text?

Vim help's change.txt states that Note that after a characterwise yank command, Vim leaves the cursor on the first yanked character that is closest to the start of the buffer. This means that "...
1
vote
2answers
46 views

Tab to align cursor with next non-whitespace character in the line above (in insert mode)

How can we do this with vim? set hlsearch " Highlight search matches set incsearch " Highlight search matches as you type set visualbell ...
1
vote
1answer
236 views

Jump from tag-to-tag in xml?

I'm using emmet-vim which says that it can work in xml files but I can't seem to navigate between tags. Say I have this structure: <dependency> <groupId>com.google</groupId> &...
0
votes
1answer
61 views

How to set up an execute-once mapping

Autocommands support the ++once modifier. I am trying to achieve the same effect for a map. Instead of coming up with a general solution I have been trying to solve my particular case via a side-...
1
vote
2answers
46 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
1answer
182 views

Run a command every time any key is pressed

I want to run a function every time the user presses any key. I have already looked through the autocommand documentation and there does not seem to be one for this. Is there any function I do not ...
0
votes
1answer
32 views

How to map a surround command?

I'm trying to map commands that are used with the vim surround plugin. Using vim surround you can type ysiW], for example, while in normal mode and it will surround the word at the cursor with ...
0
votes
2answers
31 views

How to deal with two vim plugins having the same mapping?

I have two plugins (todo.txt-vim and vim-buffergator) that both map the <localleader>b command (for .txt files at least). One plugin ended up dominating the other. I solved this by removing the ...
1
vote
1answer
39 views

How can I create a shortcut that saves the file and executes a sequence of shell commands?

I know that I can create shortcuts on a vimrc file like the following: :map <C-W> :w<CR> However, let's say I have some different commands that I can execute on my shell: notify-send &...
1
vote
1answer
333 views

Vim feedkeys in operator pending mode

I'm trying to build a very simple plugin that allows for pressing a keymapping <Leader>, to call a function that prompts for a single keypress: function! ControlKey() echo "Key → <C-Key&...
38
votes
5answers
23k 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 ...
1
vote
1answer
126 views

Change behavior of `gx` key

I used to use chromium before and then, I could press gx on an url and vim would open it in a new tab if a chromium instance was already running, otherwise create a new window. But in firefox, when I ...
16
votes
5answers
1k 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 ...
7
votes
1answer
612 views

Switching arrow key mappings for wildmenu tab completion

When wanting to edit another file, I'm a big fan of typing :e then tab (or a few characters before) to see the wildmenu pop up. Problem is that the way it works, arrows keys up and down go 'down' ...
2
votes
2answers
960 views

Configuring CoC -- open suggestion-box with shortcut only

I successfully installed CoC in my Vim to have some code-suggestions/completions while coding in Rust. It works fine, but I want make the suggestion-box only show up when I press a key-shortcut (E.g ...
11
votes
2answers
2k views

How does vimgolf record all keystrokes?

From time to time I like to engage in a round of vimgolf. It can be enlightening. How are they able to record all the keystrokes? That must be a vim feature. Anybody any idea how to do that. It could ...
0
votes
0answers
28 views

Mapping Esc makes vim open in REPLACE mode [duplicate]

I've enabled hlsearch to highlight text after searching, $ grep hlsearch ~/.vimrc set hlsearch and now I want to clear the highlight, which I can do with :noh. I saw that I can assign this to esc key ...
1
vote
1answer
38 views

To toggle statusline colors when switching modes. Problem with C-C

I use the following code to have different statusline colors for Normal and Insert modes: highlight statusLine ctermfg=black ctermbg=red guifg=red guibg=black autocmd ...
2
votes
1answer
302 views

How can I make Vim NOT remove lines below with Ctrl and Left Arrow?

How can I make Vim not remove lines below with Ctrl and Left Arrow? So I just found a dangerous setting with Vim on Linux. If I press Ctrl and Left Arrow then whole rows below start vanishing. With ...
0
votes
1answer
37 views

Is there a way to navigate windows without CTRL-W + ... ie. from the command prompt?

I want to reclaim CTRL-W for closing my terminal tab to get the same behaviour as in Firefox and other programs. Is there a command I can run to avoid having to press CTRL-W to navigate windows in vim ...
2
votes
1answer
2k views

Integrating autocomplete and snippets

I'm trying to set up an autocompletion/snippet workflow that's a bit complicated. This is stemming from needing a better workflow for latex. Right now I'm using coc.nvim and UltiSnippets but I am ...
0
votes
1answer
27 views

Dump output with command line in vim with placeholder

I use :enew|pu=execute('scriptnames') for dumping output into a buffer. How do I write a mapping with this command line? For example, I press <F6> and it auto write the command line and jump to ...
102
votes
7answers
124k 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.
0
votes
2answers
30 views

Stop waiting for the rest of a normal mode command and accept the command typed so far

I have a mapping for m and a mapping for m/ in the same buffer, in Normal mode. If I type m, is there a way to tell Vim to stop waiting for the 2nd character, and to just submit the current command as-...
0
votes
1answer
19 views

Spaces in mappings: where to put them and where not?

The question is actually rather short, don't be afraid. :-) I'm Russian, and so to tweak Vim in a way it will understand its commands even if a Russian language is currently active, I have the ...
0
votes
2answers
39 views

how to make a word turn into certain commands in vim command line?

I want :cup in vim command line to turn into :tabdo call MapRunCmd()<CR> Hope that somebody can help me out PS: I've tried this nnoremap :cup :tabdo call MapRunCmd()<CR> but didn't like ...
2
votes
1answer
42 views

What is the purpose to use "==#" with empty string?

The following is from vim-sensible plugin: set incsearch " Use <C-L> to clear the highlighting of :set hlsearch. if maparg('<C-L>', 'n') ==# '' nnoremap <silent> <C-L> :...
0
votes
1answer
59 views

How to make a toggle function in .vimrc that toggles multiple configs of almost same type?

My .vimrc code autocmd FileType cpp nnoremap <F4> :RunWithFile autocmd FileType cpp nnoremap <F4> :RunWithFile ~/Downloads/ > output.txt && cat output.txt<s-left><s-...
1
vote
3answers
841 views

Unable to Open NERDTree

I'm new to Vim, and for the paste couple of weeks, I've been using NERDTree with no problems. However, I recently added a few key mappings and am now unable to open NERDTree with the <C-n> ...
0
votes
2answers
39 views

How to move `n` number char <left> in vim command line?

My init.vim code autocmd FileType cpp nnoremap <F4> :RunWithFile ~/Downloads/ > output.txt && cat output.txt I want my cursor position to be exact 31 times <left> in command ...
0
votes
1answer
43 views

Youcompleteme: shortcut key to format selection

According to this documentation :'<,'>YcmCompleter Format will format the selected text. I am struggling to map this to shortcut key <S-F2>. I have tried all of the following after having ...
1
vote
1answer
171 views

Remapping caps tock to ctrl and backspace while in vim only

I'm pretty new to vim, and I'm starting to discover it, and seeing how important the ctrl key is. I've seen that many remap the caps lock key to ctrl and escape at the same which seems really useful, ...
0
votes
1answer
25 views

how to delete character which inserted automatically

I have the following mapping in my vimrc inoremap < <><left> but this statement conflicts with iabbrev cout cout<< and in insert mode I get cout<<>> how to delete &...
12
votes
2answers
1k views

Using vim and Caffeine on the same machine

Background I work at a research laboratory and use three different OS's daily. On the Windows and Mac machines I make use of Caffeine to keep those machines from enabling the screensaver while I work ...
0
votes
1answer
31 views

Get path to parent directory and use it in a nnoremap command?

Say I have a nnoremap and I want to pass the path of parent directory of current file to it, so the command can use this information. I have read this answer: How can I see the full path of the ...
0
votes
1answer
29 views

How do I remap <c-x><c-k> to work with fzf.vim completion?

I'm trying to set up work completion with fzf.vim. Following the manual, I have: inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': ...

1
2 3 4 5
26