New answers tagged

1

You have a very large and elaborate config. However, it looks like you've copied it from somewhere and never bothered to check what it actually does. Unfortunately, it's a common problem for people who want "to make (Neo)Vim look pretty", but feel too lazy to read a ton of the docs. This is the line number 3 from your "settings.vim": set hidden ...


1

It seems you are confused about the way Vim handles files and buffers. Each file you open is loaded in a buffer. Closing the window (or split) where a buffer is displayed will not actually close the buffer. It stays in memory for you to reopen on demand. This is why, when you quit a window with :q, you can still see the file name on the top bar (which is a ...


2

Have you tried partials? {'on_exit': function('OnEvent', [parameters])} This is what I do in lh-tags+lh-vim-lib to register things like: delete a temporary file and print a finished message on close_cb with vim -- I've never tried to use neovim.


1

Syntax highlighting is done synchronously in vim, which is why it is slow when dealing with large files. There's a few highlights you can deactivate to speed things up: set nocursorline set nocursorcolumn You can also set the minimum / maximum highlighted lines (:h :syn-sync-maxlines): syntax sync minlines=200 syntax sync maxlines=500 There's a good ...


1

In general that is how tab pages work in vim/neovim: Excerpt from neovim help (:h :tabc and then one pageup): CLOSING A TAB PAGE: Closing the last window of a tab page closes the tab page too, unless there is only one tab page. When you have term as the only window in a tab page and "exit" it you close the last window. I don't know your use case, but ...


2

Syntax for large files is consistently atrociously slow (especially when the language is hugely recursive à la lisp or xml: C fares much better because it has generally has more consecutive structures than recursive ones). I find it best to turn it off when viewing large documents. I don’t have anything technical to back this up (links, discussion, timings,...


1

Turns out that set timeoutlen=100 on my .vimrc configuration file was the culprit it makes prefix gc can't be used for now I'm not sure enough why, and I don't know why. Maybe because I don't type fast enough. Edit : To make clear here turns out that removing set timeoutlen actually make my vim_which_key open later that I could make some key combination ...


0

Are there more? Swap, undo, shada, log... Whatever is found there. I can change where swap files are stored IMO, just set noswapfile and forget it. What about the shada directory? Read :h shada-n Get used to this: when you need something it's in the help. I guess there is no way to prevent Everything is possible. But, at the very least, shada/...


2

If you are using an auto-pairs-style plugin, it is most likely trying to delete the closing "; not finding one, it erroneously deletes further. As mentioned in the comments, these plugins generally cause more headache than they’re worth (YMMV). Snippets provide a more flexible alternative (though the author has very little experience with them).


1

You can put all your personal config under a single directory (use :echo stdpath('config') to see where that directory is on your system). On Linux and Mac, the directory is $HOME/.config/nvim, and on Windows, the directory is C:\Users\USERNAME\AppData\Local\nvim. Under this directory, do whatever you want with Neovim. You might be interested in mine. As ...


1

Neovim supports a sysinit.vim file whose location usually is $VIM/sysinit.vim (see :help sysinit.vim). From Neovim execute :echo $VIM to get it's value, and from there construct the right path. I don't use Windows, but I'm pretty sure it will work if you put the file on e:\Neovim\share\nvim\sysinit.vim


2

I think the simplest thing to do is edit your vimrc/init.vim and test $TERM: if $TERM ==# 'linux' " commands colorscheme ... else " more commands colorscheme ... endif


0

After some workaround, the following mapping can give me the desired : aligned gq format inoremap jj <Esc> nnoremap <silent> gQ :exe "normal ^dmcmcvt:yvt:r\<Space>i\<Space>\<Space>jjgq$g'cdmc0vt:P"<Bar><CR> in which I first use a mark c to remember the location of the * symbol, do the usual gq formatting and then ...


0

The behavior you're seeing is triggered by plug-in plasticboy/vim-markdown, which is installing an indent plug-in which sets: setlocal comments+=b:*,b:+,b:- This lacks the f flag on the * bullets, which means it will repeat them on every line of a formatted block. It looks like you can control this formatting by setting the ...


1

Your 'formatoptions' include q, it allow gq to format comments. Your 'comments' include b:* (b is format rule,* is literal pattern), your line starts with a space and *, vim see it as as comment. vim use b rule of format-comments to format it: b Blank (<Space>, <Tab> or <EOL>) required after {string}. That's why all your lines are ...


1

The hex code of <tab> is 0x09 and is equivalent to <C-i> (displayed as ^I). To insert the word under the cursor in the command line, you need <C-r><C-w>. So you are missing a mapping from <tab> to <C-r><C-w>: cnoremap <tab> <C-r><C-w>


1

This substitution works: :%s/\v^ {4}.*\ze(\n( {4}.*\ze)?)*/\="```".lang."\r".substitute(submatch(0), '\v(^|\n\zs) {4}', '', 'g')."\r```"/ Note that even though the regex is not anchored at the first line that starts with four spaces. But that is fine if we're using it with a :%s command, since that command will not rescan text it has already replaced, so ...


2

In order for a mapping to work, Vim has to recognise the keycodes that your terminal is sending. To find out what your terminal is sending, try typing the following to enter insert mode and insert the keycode into the current buffer: iCtrl-VCtrl-, If a regular comma is inserted, then this is what your terminal is sending to Vim, and there is no way to map &...


2

Simply use :let to set each entry of the dictionary at a time. let text = {} let text['code1'] =<< trim END if ok echo 'done' endif END let text['code2'] =<< trim END if something echo something else endif END echo text This produces the following output: {'code1': ['if ok', ' echo ''done''', 'endif'], 'code2': ['if ...


1

Use "0p to paste in Visual mode Note that the numbered register "0 can be really useful here, since a default yank also goes to the "0 register, but the text replaced with a put in visual mode only goes to the unnamed register and doesn't modify "0. See :help v_p: The previously selected text is put in the unnamed register. If you want to put the same ...


2

There's no single "clipboard" in Vim. These things are called registers. Make sure you read the docs about them, it's essential. This behaviour is documented under :h v_p (as you "put" while being in "visual" mode). "Visual put" consists of two actions: a) put new text from register, and b) delete the old text into a register. Here deleted text is put ...


2

In step 7 you delete the text you selected in step 6, so it is moved to the unnamed register ("clipboard"). This the normal behavior of Vi(m). If you want to copy something multiple times, you should put it into a named register, e.g. into register 'a'. In step 3 you would use "ay and in step 7 you would use "ap. The unnamed register still changes in ...


2

Is the clipboard overwritten in Visual Mode each time? Yes it is. How do I get "sane" behavior? That is make the clipboard persist after the first paste. To get "sane" behavior you can remap p and P with: " now it is possible to paste many times over selected text xnoremap <expr> p 'pgv"'.v:register.'y`>' xnoremap <expr> P 'Pgv"'.v:...


2

You can add this to your init.vim: function! s:termclose() abort let buf = expand('#') if !empty(buf) && buflisted(buf) && bufnr(buf) != bufnr('%') execute 'autocmd BufWinLeave <buffer> split' buf endif endfunction autocmd TermClose *:$SHELL,*:\$SHELL call s:termclose() (It is recommended to use a group for the auto command)...


0

Regarding the final detail: I was starting nvim in Insert mode because one of the UX improvements offered by the Split-Term plugin is that new terminals start in Insert mode. It was unclear that this is what was happening because another plugin was starting after the Term, creating another split, and focus passed to that new split without leaving Insert mode....


2

Since your question is about saving files, here's how I do it. Vim files out of my way if exists('$SUDO_USER') " no files for root user set noswapfile set nobackup set nowritebackup set noundofile set viminfo= else " I created a tmp folder set backupdir=$HOME/.vim/tmp/backup// set directory=$HOME/.vim/tmp/...


0

I decided to use: set noswapfile set autowriteall All of my important work is under git, so recovery is not a problem and while multiple-edits might be a problem, I guess I will just have to be careful.


3

The :Term command you are using does not support the -bar option so it will take | endif as an argument. You can overcome this with :execute autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | execute '10Term' | endif


2

There's a good answer to your question here: https://stackoverflow.com/a/15703188/5031295 In short, ctrl+o or ctrl+Olets you perform one normal mode command while in insert mode. Hence, pressing ctrl+odw while in insert mode deletes one word to the right of cursor (provided the cursor is on the first letter of the word). You can play around with this and ...


2

There is ppa recommended on the project page: sudo add-apt-repository ppa:neovim-ppa/stable sudo apt-get update sudo apt-get install neovim You'll get v0.4.3: $ nvim --version NVIM v0.4.3 Build type: Release LuaJIT 2....


1

Ubuntu 18.04 (Bionic) ships Neovim 0.2.2, so that explains why you'll get that version by default. You can use a PPA from the “Neovim PPA” team to install the latest Neovim stable on your Ubuntu 18.04 (also available for 16.04 and 19.10) Use these commands to configure your system to always include this PPA in updates: sudo add-apt-repository ppa:neovim-...


1

For Windows I propose the following solution: Add the following line to you ginit.vim file: silent execute "!echo " . v:servername . " > servername.txt" Remark: The ginit.vim file is to be found or created in %LocalAppData%\nvim (e.g.: on Windows 10 for John Doo: C:\Users\JDoo\AppData\Local\nvim Start nvim-qt using the following batch file: @setlocal ...


2

You can use 3Rf0<Esc>. The R command is similar to r, but it replaces multiple characters and not just a single one. It takes an <Esc> to leave Insert (Replace) mode. You can also use . to repeat a Replace action, and you can repeat it with a count. For example, you can use Rf0<Esc> to replace the first instance, followed by l2. if you ...


3

You can and add this to your init.vim: augroup RestoreCursorShapeOnExit autocmd! autocmd VimLeave * set guicursor=a:hor20 augroup END See :h guicursor for details. The reason it isn't done automatically is there's no way to query the terminal cursor shape


2

:se backup? backupdir? backupext? Use this comand to find the folder used for backups. Then create the backup folder: mkdir ~/.vim-tmp


2

CoC assumes that a directory containing .git/ is the root of your project. According to the CoC docs: Unlike VSCode vim doesn't have workspace support. The solution is resolve workspace folders from opened files. This means that CoC uses a list of filenames which, if present in a particular directory, indicate that it might be the project's root. If ...


1

An alternative to creating a mapping for this single Readline command, is to install the rsi.vim plugin, which emulates all (or at least, many) of Readline's standard shortcuts in insert and command-line modes. Future readers may also be interested in readline.vim, which purports to provide a more faithful set of mappings, but only in command line mode.


5

I've the following mappings for this noremap <C-Del> dw inoremap <C-Del> <space><esc>ce noremap <C-S-Del> dW inoremap <C-S-Del> <esc>lcW As you can see, there are several ways to do it (and handle single letters). and I'm quite certain there has been other Q/A|tips on the topic elsewhere. NB: unlike <c-o&...


1

Turned out rg command for some reason behaves a certain way when called from the following: Window cmd bash vim :! Ubuntu jobstart() Differently to when called from Windows jobstart() The solution is simply to define what to search: let cmd = ['rg', '--vimgrep', 'endfunction', './']


3

Make sure your locale contains the full UTF8 specification to a language; i.e. not something like en_US, but en_US.UTF-8. See this issue.


1

The v:lua interface was only introduced to NeoVim in PR #11338, which has a milestone of 0.5, so it looks like it's not generally available in released versions of NeoVim just yet. (NeoVim 0.5 is still in Beta as of early May 2020.) You should use the luaeval() Vimscript function to evaluate a Lua expression (such as a function call) and use the returned ...


1

TL;DR use <C-v> instead of V The cause in that you use S-v instead of <C-v>(V) before S-i(I) Block insert works only for Vertical blocks, not for selected lines. Difference between V and C-v V (<S-v>) is for selecting whole line$ <C-v> starts selecting Visual block: With CTRL-V (blockwise Visual mode) the highlighted text will ...


Top 50 recent answers are included