New answers tagged

3

To send the original keystroke, you can use <C-w>. That said, I too find it annoying to have to remember.


4

You can set 'termwinkey' to a sequence other than <C-W> to use a different keystroke to access the special sequences on the terminal. For example: set termwinkey=<C-X> Or: set termwinkey=<F1> See also :help terminal-typing.


1

There is a Lexplore command to toggle a netrw window on the left hand side. However there is a bug that executing it multiple times will generate a lot of empty buffers. For now I think stimulate's anwser is quite good. I created my single-function version based on that answer (I am not a vim expertise so not sure if this is better): nnoremap <Tab> :...


1

I looked at the docs. You need to set: set backspace=indent,eol,start My previous installation was vim-gtk. I suppose this package has this value set as default. Now both backspace and delete work as before.


3

You actually want syntax enable (for good reasons which I’ll leave to the :help to explain). I created this custom command to toggle syntax; you could adjust the mapping similarly: command SynToggle \ if exists("g:syntax_on") | \ syntax off | \ else | \ syntax enable | \ endif This leaves you with nnoremap <expr> &...


1

TLDR: Make sure that g:submode_keyseqs_to_leave does not include the <esc> key. Either reset it to an empty list: let g:submode_keyseqs_to_leave = [] ^^ Or double the <esc> key: let g:submode_keyseqs_to_leave = ['<esc><esc>'] ^^^^^ In the latter case, you'll ...


0

Ctrl-; is not a valid control sequence, so vim cannot capture it. You will need to use gvim or to configure your terminal emulator to translate Ctrl-; to something vim can capture


0

Manual approach You can use 2<c-w>0 to resize current window to fit buffer, with 2 extra lines. It's fully commented, read comment as explanation. " Resize window to fit buffer + <count>. It works the same as <c-w>_ if there " are too many lines to fit. command -count WinFitBuf call s:win_fit_buf(<count>) nnoremap <expr> <...


1

According to coc readme you can trigger completion manually with: " Use <c-space> to trigger completion. inoremap <silent><expr> <c-space> coc#refresh() NOTE that not every terminal supports <c-space>... I don't know for sure how to map cmd in vim... Probably D or something: " Use <CMD-x> to trigger completion. ...


1

The documentation explicitly recommends using the maximum number of digits. See :help i_CTRL-V_digit: Normally you would type the maximum number of characters. Thus to enter a space (value 32) you would type <C-V>032. You can omit the leading zero, in which case the character typed after the number must be a non-digit. This happens for the ...


0

This works for me if you want something simple: " Move selection up xmap <kMinus> :move '<-2<CR>gv " Move selection down xmap <kPlus> :move '>+1<CR>gv


3

This is documented under :help map-error: Note that when an error is encountered (that causes an error message or beep) the rest of the mapping is not executed. This is Vi-compatible. Regarding this part of your question: 2) In the case of the above answer, the error is invisible: if i press up in the first line in vim, theres no notification of an ...


1

Mappings abort on errors, and trying to move further « up » than the first line is an error, so the P never gets executed. I have some other « bubble » mappings you might be interested in.


2

To change the behavior of <Del> so that it only deletes the character under the cursor and doesn't behave like backspace when at the end of the line, you can use the following mapping: cnoremap <expr> <Del> getcmdpos() <= strlen(getcmdline()) ? "\<Del>" : "" See @D.BenKnoble's answer for a solution to deleting until the end of ...


2

You can use the following function: function KillEnd() let l:cmd = getcmdline() let l:pos = getcmdpos() let l:newcmd = strpart(l:cmd, 0, l:pos - 1) return l:newcmd endfunction To use it on the command line, you need to do (I choose <C-x> arbitrarily since it wasn't used for anything else, and reminds me of X in normal mode): cnoremap <C-x&...


1

With a recent enough Vim binary, and for some terminals – including xterm – Vim can distinguish C-i from Tab. You need at least the Vim patch 8.1.2134. And you may need to add these lines in your vimrc: let &t_TI = "\<Esc>[>4;2m" let &t_TE = "\<Esc>[>4;m" Unless your Vim binary also includes the patch 8.1.2194, in which case it ...


2

Short answer: you cannot. Long answer: <C-i> being equivalent to <Tab> isn't a vim quirk or builtin. It's a quirk of how terminals represent characters (cf. https://bestasciitable.com). You simply cannot avoid this fact. Now, it may be possible to force your mapping to take precedence over the tab-behavior of inserting tabs/spaces, but I haven'...


0

As mentioned in the comments, you need to make sure cpoptions does not contain the k and < flags before defining your mappings (this explains why netrw broke too). The likely culprit is that vim was running in compatible mode (this should not be the case if you have a .vimrc file, but it's possible to do some funky things with the invocation to end up in ...


1

You can use <Left> to move the cursor to inside the single quotes after you do the expansion. For example: inoremap jj print('')<Left><Left> The main problem with using an insert-mode mapping here is that typing a single j in insert mode is weird and blocks waiting for another character... Also, typing jj in any context, including inside ...


1

Hmm. This is interesting. Here's what get saved as the command (:com Test0): nnoremap <NL> :echom "c-j"<CR> (<C-J> is equivalent to <NL> in Vim) So what do we know about the <> format? That it can be used in mappings and abbreviations as a substitute for the represented keys/chars. That it can be used in exe command arguments ...


1

I wrote something similar recently, I changed it again to make <c-a> and <c-x> work on any step. You may get the command here and the function here. It support 123.24 or 123. or 123 or .123 style number, count is also supported now: # change slide step to 0.000001, Slide 0.000001 # change slide step to 0.1, save after slide. I use this to # ...


1

If you need to do sh/bash commands, you should run it via sh -c let &makeprg = 'sh -c "..."'


1

There are several issues. First of all what happens when you make a visual selection and then go to the command line with :? You see how it's pre-populated with '<,'>. You should drop that from the first substitution in your mapping as it's redundant. (Or you can leave it in and make the first part of your mapping <C-U> as in Ctrl-U. That will ...


3

If your terminal has support, you can simply press End. Otherwise, use CtrlO to get into normal mode for a single command only. So Ctrl-O and then $ (or A) will do the trick. In principle, you can remap Ctrl-E to do Ctrl-O $ (like inoremap <c-e> <c-o>$), but :h i_ctrl-e is sometimes useful in Vim on its own.


0

The best I could come up with for now. It does not respect the current tab page yet, but maybe this could be achieved with using some kind of map data structure nnoremap <Tab> :call OpenNetRW()<CR> let g:netrw_buffer=0 function OpenNetRW() Vexplore let g:netrw_buffer=bufnr("%") nnoremap <Tab> :call CloseNetRW()<CR> ...


2

This is a normal behaviour of gui flavours of vim like gvim. <m-i>, <a-i> and é are the same thing. Usually people aren't bothered by meta+key inserting an accentuated character, but the other way around. See the very old issue with French people needing to insert é in LaTeX document which in turn triggers \item insertion (IIRC) with vim-latex. ...


2

I suspect, but cannot confirm because information is missing, that the line is "bare" in the OP's vimrc. This means it would execute, no matter what, for the first buffer vim opens. Because of <buffer>, that mapping is only available in that buffer! Instead, you should put the mapping in ~/.vim/after/ftplugin/python.vim as follows: nnoremap <...


1

I have this since 2002 it seems It also handles <end> key inoremap <silent> <Home> <c-o>@=<SID>HomeLikeVCpp()<cr> nnoremap <silent> <Home> @=<SID>HomeLikeVCpp()<cr> vnoremap <silent> <Home> @=<SID>HomeLikeVCpp()<cr> inoremap <silent> <End> <c-\><c-n>...


0

This is what I came up with. It is not as short as other options, but seems to do the job: func F_home() let n_ind = indent(line('.')) let n_col = col('.') - 1 if n_col > n_ind normal ^ else normal 0 endif return '' endfunc nmap <Home> :call F_home()<CR> imap <Home> <C-R>=F_home()<CR>


1

Yes, it is possible to create a mapping for that. For example, a mapping that will go to the indent if you're elsewhere in the line, but go to the first character if you're on the indent: noremap <expr> <Home> col('.') == match(getline('.'), '\S') + 1 ? "\<Home>" : "^" inoremap <expr> <Home> col('.') == match(getline('.'), '\...


3

Maybe there is some kind of remapping plugin for either chrome or firefox that addresses this? Regarding Citrix, Citrix Lite and the browser, you'll have more luck asking about it on Superuser, so I suggest you post a question there for a solution from that front. Is there any other strategy that vi users adopt? You should be able to use Vim mappings to ...


1

I'm not familiar with mintty, but a quick google search returned the following: 1. mintty tips: Unexpected behaviour with certain applications (e.g. vim) If for example the PgUp and PgDn keys do not work in your editor, the reason may be that in the mintty Options, the Terminal Type was set to "vt100" and based on the resulting setting of the ...


2

I feel like this is all overly complicated, you can realize this with just a few lines of regex: s/<\(\w\+\)>\%#/&<\/\1>/g This expression will allow you to add a closing tag after the cursor: - < matches the start of the opening tag - \w\+ matches the tag content, we include it in braces so that we can use it in the replacement - > ...


1

So the issue is that the mapping for <Esc> is interfering with other mappings. Since most special keys generate sequences that start with an ESC character (which typically shows up as ^[), the mapping is causing Vim to take that initial ESC from the first mapping, which is ignoring the <Esc>, then keeping the rest of the characters (OA) as a ...


Top 50 recent answers are included