New answers tagged

0

In vim, nvi, vi, and so forth (all of the terminal vi clones, to be precise), no. A terminal session doesn't transmit the modifier key presses separate from the keys they're modifying. It's true that terminal emulators have come a long way since when they were first made, and they have a lot more capabilities now. But that's something that's pretty ...


2

This situation is frustrating. Technically speaking, the CSV file you describe is within MicroSoft's CSV spec - the double-quotes escape the comma, so it's not considered a separator. However, there's a lot of programs out there that don't honor any method of saying the comma isn't a value separator, or don't honor that one. If you only have a single ...


0

The vim pattern "[^"]*\zs,\ze[^"]*" should match only the comma. However, if you have data like "abc","ab,c" it will match both commas. The pattern matches a quote ("), followed by a bunch of "not-quotes" ([^"]*), followed by a comma (,), but we only keep the comma as the match (\zs,\ze), followed by more "not-quotes" ([^"]*), followed by a quote (") We ...


0

Customize fzf search command You can pass a dict with custom source to fzf functions: nnoremap <c-p> :call fzf#vim#files('', {'source': g:fzf_project_source})<cr> let g:fzf_project_source = 'find . \( -name ".hg" -o -name ".git" -o -name "build" \ -o -name ".vscode" -o -name ".clangd" \) -prune -o -type f -print' Customize fzf ...


3

It's not possible to achieve this with regular mappings of K and KK. If the K mapping fires then Vim is necessarily no longer waiting to see if KK is typed, and there are no configuration options that can change this behaviour. There are ways to workaround this, however. filbranden suggested one possible method in the comments which D. Ben Knoble has ...


2

I think something like this would do: let s:pressed = 0 function KFunc() abort let s:pressed += 1 if s:pressed == 1 " do one else if s:pressed == 2 " do two let s:pressed = 0 endif endfunction augroup ResetPressed au! au CursorMoved,CursorMovedI,CursorHold,CursorHoldI * let s:pressed = 0 augroup END nnoremap K :call KFunc()<CR&...


2

It seems you've already found a working solution, but I wanted to address the issues with your attempted approaches. But when I press /, instead of running the function and then starting the search prompt, I get this text inserted to my buffer: rm! / You're getting this result because you're using <BAR> in your mapping after you already left ...


1

This looks as expected. Airline is a statusline plugin (read :help statusline). To set the editor's colorscheme, use :colorscheme [name].


1

Figured out the the <silent> was hiding the search prompt, and also the mapping can be done just like this: nnoremap / :call <SID>FooFunction()<CR>/


3

A general recommendation when debugging an issue is to start with -u NONE, which skips all initialization. If you just want to start vim without plugins and with a custom .vimrc file start vim with the following command: vim --noplugin -u <test_vimrc_file> <your_file_name> then issue the command :packadd <package_name> to load the plugin ...


0

Inside my vimrc I have a line that loads my plugins like this source ~/.vim/rc/bundles.vim Then inside my bundles.vim I do the following: call plug#begin('~/.vim/bundle') Plug 'foo/vim-someplugin' source ~/.vim/rc/plugins/someplugin.vim call plug#end() if you don't want to use hard coded paths I recommend something like this execute 'source' ...


2

Try this: set rtp-=~/.vim set rtp-=~/.vim/after set rtp^=/path/to/some-plugin set rtp+=/path/to/some-plugin/after set vif=NONE filetype plugin indent on syntax enable Write the code in a file, e.g. /tmp/vimrc, then start Vim with this shell command: vim -Nu /tmp/vimrc The -u argument specifies the path to a custom vimrc, while the -N argument resets '...


4

Well, actually it works, but probably not the way you think. Autocommands are invoked in sequence. It's BufNewFile and/or BufRead that are used by ftplugin to set filetype which results in FileType autocommand which, in turn, does source all your stuff. So you've already missed BufNewFile for that particualr buffer. Nonetheless, autocmd without <buffer&...


1

I couldn't resist golfing this one, and came up with the following: 3itable[row][col]<Esc>i+1<Esc>F].;a, other_<Esc>3;a = std::max(<Esc>A)<Esc> This works by inserting three copies of table[row][col] by using a [count] with the i command and then jumping backwards to fill in the missing parts of the statement —&#...


0

What about just remap ctrl-v in insert mode to paste from system clipboard? inoremap <c-v> <esc>"+p Does this work for you?


3

You can check if your vim runs in gui: if has("gui_running") colo koehler else colo darkblue endif You can also use gvimrc file (:h gvimrc) instead. The drawback is that you would have colorscheme run twice (one in vimrc, another in gvimrc) for gVim unless you guard it in vimrc, again, with has("gui_running"): vimrc if !has("gui_running") ...


1

You can get a workflow that's close to what you want without configuring vim at all. You can jump to the nth buffer using <C-^> (ctrl + 6). If you type a digit while viewing the output of ls, then that digit is stored and can be passed to the next command. In order to produce the fake vim screenshots, I increased the font size so I can only see a ...


0

Consider using snipmate and defining snippets for these operations.


2

Setting wildignore can have quite a few side effects (especially if done globally). So I would do: let s:prefix = '/path/to/folder' let files = filter(glob(prefix . '/**/*.bak', 1, 1), "fnamemodify(v:val, ':e') != 'bak'") for fname in files execute 'source' fname endfor


1

You can only 'source' a file at a time. Therefore, build the list of files first, and then source them one by one. set wildignore=*.bak let s:prefix = '/path/to/folder' for s:fname in glob(s:prefix . '/**', 0, 1) execute 'source' s:fname endfor However, normally you should only source *.vim files, so then it becomes let s:prefix = '/path/to/folder' ...


2

I had another binding that <leader>h was a prefix and I had forgotten about; it was <leader>html. Removing it solved the problem.


0

From Hotschke in the comments: Please read :help load-plugins: In step (4) basically :runtime! plugin/**/*.vim happens which is before your gvimrc is sourced (step (8)) and runtimepath has been changed by vim-plug. You can remove the error by appending to your gvimrc runtime! plugin/**/*.vim. However, I recommend to use vimrc and stick to the given source ...


2

I figured this out, and decided to just remove the mapping. It's happening because (at least in my environment, using vim in a terminal over SSH) there's no distinction between <C-m> and <CR>, they're one and the same to vim. If I remap <C-m> in normal mode, I'm also remapping <CR> in normal mode. I don't tend to press enter in ...


1

The sentence Set 'verbose' to get a message about that when opening a file. Refers to the option verbose—you can tell because it's enclosed in single-quotes, and if you place your cursor on it and press Ctrl-], you jump to the same section as :help 'verbose' would. It's not clear what level of verbosity you would need, but try set verbose=1 and then ...


1

Starting from Patch 7.4.1384 Vim has 'packpath' option for searching plugins. By default 'packpath' is equal to 'runtimepath' (until 'runtimepath' finally gets inflated by the plugins loaded), so you must keep them sync in your vimrc. For Vim 8, I'm calling it like this: /usr/local/bin/vim8 -u "${HOME}/.vim8/vimrc". You can add the following lines on top ...


3

The specific path you're using (pack/vendor/start/nerdtree) is using the "packages" feature, which is a new Vim 8 feature that automates manipulation of 'runtimepath' in a way similar to how plug-in managers have been implemented. That's why your attempt setting 'runtimepath' from --cmd doesn't work, since packages actually use a separate 'packpath' setting....


Top 50 recent answers are included