New answers tagged

1

One simple way to achieve this is to make a buffer-local nowait mapping. autocmd FileType * nnoremap <nowait><buffer> [ { autocmd FileType * nnoremap <nowait><buffer> ] } Another option is to use langmap: set langmap=[{,]} You can use the associated option langremap to adjust whether [ and ] inside mappings will have the usual or ...


1

When you want to map a <Plug> mapping always use nmap not nnoremap. Basically a <Plug>(Something) is a sequence of chars that are mapped to some functionality. Imagine you have: " you have some mapping nnoremap a :echo "hello"<CR> " and want remap that mapping nmap b a " same nnoremap asdf :echo "world"&...


0

The solution was a mix between attempt 1 and 4. If you're stuck in INSERT MODE without escape This procedure maps jj to the Escape-key. Step 1 CTRL o -> Goes to -- (insert) ---mode (where you can type a single command. Step 2 Write: :imap jj <Esc> Found here ... This maps (in insert mode) a double-press on j to an ESC. Step 3 Press jj :-) If you'...


0

I found a solution for this issue. put your Ctrl-j key mapping into a local .vim file, like ./vim/myapping.vim as below: inoremap <C-j> <down> Then in your .vimrc file, add below line to source this file: so ~/.vim/mymapping.vim This solution can fix your reported issue


1

One other option is to use the expression register = together with the macro replay operator @. When you type @=, Vim will let you enter a Vimscript expression (i.e. a string) and will execute that string as a macro. You can pass @= a count and it will repeat the execution {count} times. In your case, start with, say, 7@= (to run it seven times), then in the ...


0

You could accomplish that with a mapping that stores the count (for example, in a buffer-local, script-local or even global variable) and start recording a macro (say qa), and then a second mapping for ] that stops recording the macro and executes it the number of times passed as the count (minus one, since the recording itself also counts!) In short: ...


3

You can use the following, somewhat hacky, maps to do this (inspired by the unimpaired plugin): " move a small word left imap ]w <ESC>mx$ox<ESC>kJ`xdawhelphmx$"_daw`xa " move a big WORD left imap ]W <ESC>mx$ox<ESC>kJ`xdaWElphmx$"_daw`xa " move a small word right imap [w <ESC>mx$ox<ESC>kJ`xdawbPhmx$&...


2

:h <Char> To map a character by its decimal, octal or hexadecimal number the construct can be used: <Char-123> character 123 <Char-033> character 27 <Char-0x7f> character 127 <S-Char-114> character 114 ('r') shifted ('R') This is useful to specify a (multibyte) character in a 'keymap' file. Upper and ...


2

You need extra onoremap mappings for Operator-pending mode. onoremap <C-L> $ onoremap <C-H> ^ Operator-pending mode gets triggered after a command such as d or y or c which takes a motion or text object to act on. See :help omap-info for more details.


1

You can always use the '> mark, which always selects the last line of the last Visual selection, regardless of having been selected from top to bottom or from bottom to top. So one possible solution to your mapping is: xnoremap <c-l> y'>p (It looks like from the other post you got ygP which is slightly better, as it's shorter and it's avoiding a ...


2

copy-paste entire block after (not inside the first selected block) with cursor at the beginning of 2nd paste Just four three keys ygP


1

I ended up combining bits of solutions provided by Luc and Maxim, ending up with the following in my .vimrc: " clear all mappings starting with space in insert mode " based on https://vi.stackexchange.com/a/26385/40274 " and https://vi.stackexchange.com/a/26384/40274 function! ClearInsertLeaders() abort let s:mappings = execute('imap &...


1

The netrw plug-in also defines a couple of <Plug> mappings that you can use to define your own mapping to the "browse" feature. To map gX to those, you can use: nmap gX <Plug>NetrwBrowseX xmap gX <Plug>NetrwBrowseXVis netrw checks whether there are already keybindings defined to these two <Plug> mappings and, if so, it ...


1

source command executes ex-commands from the file being sourced. This implies nothing is removed unless you explicitly didn't add unlet, unmap and other commands to remove specific things. Thus, :source $MYVIMRC doesn't remove mappings execute :unmap <cr>, do it for each mapping you want to "remove". If you want to remove all mappings use :...


3

No mapping necessary! Vim has the & command which just repeats the last substitution. The same way as . repeats the last command, I can move to the next true and simply hit & which will apply again the last substitution. Neat and simple. I found out by googling “vi repeat last substitution” which yielded this SO post as the first result.


2

My preferred method here is to just let you enter the range from the place you normally do: on the Ex command line: nnoremap <leader>t :Test<C-b> Since <C-b> puts your cursor between at the beginning of the line, you can type \t.,81<CR>.


4

Assuming the cursor is on line #80 and <leader> defaults to backslash, type directly 2\t. The point is that typing N: in Normal mode, where N is arbitrary number, is converted by Vim to :.,.+N-1. So you have to supply number of lines in range (rather than last line number).


2

There are typically two ways to pass a range to a Normal-mode command. One is to use a Visual selection (which is not exactly a Normal-mode command, but a Visual-mode one, but still pretty close) and the other is to create a mapping that takes an operator and acts on the range resulting of the operator or motions that follows it. For the Visual-mode command, ...


3

You mapping: inoremap <leader>m <esc> contains a trailing space. Since Space causes the cursor to move to the next line, because Space is allowed to move the cursor to the next line. This is caused by the default value of the 'whichwrap' which is b,s in Vim default mode. Note, when using :imap command, Vim even shows you that in your mapping, ...


Top 50 recent answers are included