New answers tagged

4

The answer you linked is the right direction: ftplugins are made exactly for this purpose, check the doc: (:h ftplugin) If you have things that you want used in both c and cpp ftplugins you could put it in a function in ~/.vim/autoload/cscope.vim and then in ~/.vim/after/ftplugin/c.vim and ~/.vim/after/ftplugin/cpp.vim you can simply call this function. ...


2

You should have a look at :h map-modes and keep in mind that you always want your map command to be mode specific even if occasionally that makes you write a very similar command twice it avoids a lot of issues. From the doc the :map (or :noremap) command only works in Normal, Visual, Select and Operator-pending modes. That's why jk doesn't work in insert ...


1

I’ve got a plugin that does this for maps but only for mappings registered through the plugin.


0

You can get the usual ctrl-backspace Windows behaviour (deleting previous word) following this Vim tip: https://vim.fandom.com/wiki/Map_Ctrl-Backspace_to_delete_previous_word You just have to put these lines on your .vimrc " Map Ctrl-Backspace to delete the previous word in insert mode. imap <C-BS> <C-W> Alternatively, you can put the ...


0

If you don't have a qwerty keyboard and you cannot press <C-[>, simply <C-C> works fine ! And for any mode ! the only sad thing is the prompt when you press <C-C> in normal mode, telling you that you should press :qa to quit vim.


5

Another solution is to use an abbreviation: cnoreabbrev <expr> fzf (getcmdtype() == ':' && getcmdline() =~ '^fzf$')? 'FZF' : 'fzf' You check that the command line type is : and that you only have fzf in your command (to avoid messing with e.g :call fzf#vim#rg(...)) and if it is the case your replace your command with FZF otherwise you keep the ...


3

You need to use an expr mapping: cnoremap <expr> fzf getcmdtype() isnot# ':' ? 'fzf' : 'FZF' You could also (maybe?) use a self-destroying mapping: augroup fzf_mapping autocmd! autocmd CmdlineEnter : cnoremap fzf FZF autocmd CmdlineLeave : cunmap fzf augroup END


0

OK, after some try-and-error I resolved this problem. To get the path to parent dir: %:p:h Notice that the :p is needed to get the full path, without it you might end up with nothing, i.e. it's possible you cannot find the parent folder. For example, my usage: nnoremap <nowait><silent> <Tab> \ :Fern %:h -drawer -...


1

After some try-and-errors I resolved this problem. Btw, if I add to it, would the never be triggered? Yes. Change nnoremap <C-W> <NULL> to: nnoremap <C-W> <ESC> Since normally no key will follow <ESC>. (Remember when you were a newbie and wanted to escape from it) Result, done in 1 second:


1

You are defining a normal mode mapping. Your first ESC is issued in command mode and thus interpreted as always---it stops command mode. Your second ESC can be interpreted as the start of your mapping. Depending on your terminal mouse clicks might be (I don't know for sure) represented as a character sequence starting with ESC. In that case the second ESC on ...


0

For MacOS, this can be fairly easily accomplished using Karabiner-Elements and goku (better config language for karabiner). Here's what the relevant bit in my karabiner.edn that basically maps all those "bad" shift- combos to nothing looks like: ;; Modifiers spec for reference: ;; ! | means mandatory ;; # | means optional ;; C | left_command ;; ...


Top 50 recent answers are included