New answers tagged

0

As per @Knoble's answer .vim/after/ftplugin/*.vim are the right config files to be fiddling with. My preferred solution is now to put the mappings in the .vimrc (i.e. nnoremap [[ #) and just unmap the overriding buffer specific mapping in the after/ftplugin/*.vim file (i.e. nunmap <buffer> [[) This has the benefit of leaving the mappings in the .vimrc ...


0

Answers from the comments: An ftplugin version (fairly standard): in .vim/after/ftplugin put the following where you need it (e.g., python.vim): nunmap [[ nnoremap <buffer> [[ # It is odd that you need to nunmap though. Working with the plugin: if you want to get rid of all python specific mappings, you can simply define :let g:no_python_maps=1, if ...


1

It works fine for me except the color is not changed back to red when I exit from Insert mode by using . If you do :h i_CTRL-C you'll get answer on why your statusline is not changed when you hit <C-c>: *i_CTRL-C* CTRL-C Quit insert mode, go back to Normal mode. Do not check for abbreviations. Does not trigger ...


1

In :h windows.txt you can find the following : Note: All CTRL-W commands can also be executed with :wincmd, for those places where a Normal mode command can't be used or is inconvenient. and :winc :wincmd These commands can also be executed with ":wincmd": ...


2

Do not use <CR> in the mapping as it executes the command you provide. Instead add enough number of <left>s to position cursor between '' where you can provide your command and press enter to get result: nnoremap <F6> :vnew +pu=execute('')<left><left> PS, I use custom :Redir command for that: " Redirect the output of a ...


0

The existence of the m/ mapping REQUIRES that the m mapping needs to wait for the possibility of hitting the / key before the timeout expires. There's no way around it. If you want the m mapping to immediately execute, then it makes no sense to also expect m/ to do anything. Vim will immediately accept whatever you already entered if what you've already ...


0

This appears to be impossible in general using standard key mappings. There is no functionality to tell Vim to "accept whatever I already entered" for an arbitrary sequence of inputs, at the user's discretion (i.e. without baking it into a key mapping with <nowait> or changing the timeout).


0

Here’s one way: first press yy to copy line after press dd to delete line and finally press p to paste That is, press yyddp.


1

Why the second version doesn't work? Because there is nothing mapped to <C-Space><C-^>. Space separates a sequence of keys and a mapped value. Are there explanations/rules/best practices where to put and not put spaces when we define mappings in Vim? :h :map is concise indeed. :map {lhs} {rhs} should tell you that there should be a space ...


1

You were close with trying a map command, but you want to define a command line mode mapping, not a normal mode mapping. cnoremap cup tabdo call MapRunCmd()<CR>


1

@ChristianBrabandt 's simple solution type :Cup in vim command line, it will turn into :tabdo call MapRunCmd() :com -nargs=0 Cup tabdo call MapRunCmd()


2

:help maparg() explains that maparg('<C-L>', 'n') will return the normal mode mapping assigned to control-L. When there is no mapping for <C-L>, then it will return an empty string...so it's politely checking for the existence of a mapping before assign the mapping. Concerning ==# with an empty string, some plugin authors automatically use ==# ...


0

If I understand correctly, Maxim Kim's solution was close to perfect, the only missing thing is that the exact command to run should be specific to the current project. IOW, the value to use should be buffer local. As this is something I do a lot in my plugins, I've factorized everything regarding option fetching to option toggling (I also have a :Toggle ...


0

I had the same problem, what solved it for me was to put my line for nerd tree mapping towards the bottom of the .vimrc, AFTER where you remap the 'leader key'. I used nerd tree toggle so it can open and close easily. Here's what worked for me (using 'leader ctrl+b' like bookmark in a browser): :map <leader><C-b> :NERDTreeToggle<CR>


2

There is no straightforward way to tell vim to land the cursor at a particular place in the cmdline during a map, but there are a number of workarounds. Direct positioning autocmd FileType cpp nnoremap <F4> :RunWithFile ~/Downloads/ > output.txt && cat output.txt<c-r>=setcmdpos(getcmdpos()-31)[1]<cr> You can use setcmdpos() to ...


1

Normally prefer :h ftplugin over autocmd FileType. If still want autocmd, at least, put it into augroup. Use :h map-<buffer> to define a local mapping. Otherwise it will affect all other buffers/windows too. Typing foo[cursor]bar is as simple as bar<C-B>foo.


1

As mentioned in the comments, <S-F2> may not work in some terminals or with some vims. Using another key solves the issue of binding it correctly: I would use something like vnoremap <leader>f :YcmCompleter Format<CR> But it might also be nice to set formatexpr or indentexpr instead.


1

You should use :inoreab instead of :iab. nore avoids mappings/abbreviations from being triggered. Another possibility is to have the mapping analyse the context. IIRC, in lh-cpp/lh-brackets I only expand < into <|> when I detect #include or template on the same line.


1

The other answer (and suggestions in the comments) didn't work for me, I opted for switching to MouseJiggler instead of Caffeine and the F15 problem is no more! https://github.com/arkane-systems/mousejiggler (I am not the author or anything, I honestly just looked around for something else and found that this really solved my problem well)


1

you can execute command in insert like that <C-o>:echo "test"<cr> : inoremap <leader>k <C-o>:fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': 1 }})<cr>


Top 50 recent answers are included