New answers tagged

2

After talking to my friend in Discord about Vim. I found out that my clipboard is disabled. :version shows -clipboard. I did some research and found the vim-gnome package that fixes it. However, since I hadn't installed gnome, I found an alternative called vim-gtk3. I installed it, and now I can copy to the system clipboard.


2

Use :finish: if hasNoDependency() finish endif " all dependencies are met, good to go " ... I use it for minpac plugin manager (not only here of course): if !exists('*minpac#init') | finish | endif call minpac#init() call minpac#add('k-takata/minpac', {'type': 'opt'}) "" My plugins call minpac#add('git@github.com:habamax/vim-...


2

If your Vim contains the patch 8.2.0924, then try to use getreginfo(): function Foo() let save_cb = &cb let regInfo = getreginfo('"') try norm! y{motion} do something finally let &cb = save_cb call setreg('"', regInfo) endtry endfunction The latter function returns a dictionary providing ...


1

With the help of @Matt, we were able to get my new plugins loaded, and markdown folds working. Open vim with the session file vim -S Session.vim Modify sessionoptions by removing options and folds from the sesion options -- :set sessionoptions=blank,buffers,curdir,folds,help,options,tabpages,winsize,terminal ++ :set sessionoptions=blank,buffers,curdir,...


0

The standard way to do this is to set 'makeprg' and 'errorformat' to appropriate values, and then do :make. Output is loaded into the quickfix list, which you navigate with the usual commands. Further, putting these settings in a compiler plugin allows faster use: if you create ~/.vim/compiler/textidote.vim with the right contents, you can do compiler ...


0

The expression you're looking for is 0x0d, which is a Number that evaluates to the hexadecimal value equivalent to 13. if a == 0x0d | echo "Match 13" | else | echo "Not 13" | endif " => Match 13 The other expressions you used don't really work because they're strings and in some of them you're using the syntax to match ...


0

Add filetype plugin indent on at the start of the main ~/.vimrc Note that filetype plugin indent on is the default for Neovim; also it's in Vim's defaults.vim, so if you already have runtime defaults.vim (or vimrc is missing) you don't need it either. If you're unsure you can check the current setting by typing :filetype without any other parameters. If it'...


1

It's mainly a pre-plugin manager era thing that permits to prevent a plugin file from being loaded. For people that still install those files directly into ~/.vim/plugin, it still makes sense. It could still make sense if you distribute a plugin (in the new sense:) made of several files that defines different things. But honestly, it'd be simpler in that ...


1

As of Vim 8.2.0997, line continuations will now work correctly in this scenario. Thanks to Yegappan Lakshmanan for writing the patch and for letting me know about it.


0

I was looking for a robust way to toggle a terminal and ended up building something that meets my expectations. Off: any visible terminal is hidden On: terminal as a bottom panel (restore first hidden terminal or create new one) Works with already open terminal Arguments: size and side of the terminal, defaults to 6 lines at the bottom It seems pretty ...


0

I found, that despite that the pedit command accepts a file name, it doesn't have to be an existing file. So with pedit some-dummy-name.txt one can use the currently opened preview window automatically and its buffer will be replaced with 'dummy-name.txt', so that the script can safely change it. Then it's necessary to populate it with lines of the "prompt" ...


1

nnoremap <silent><F9> :call <SID>qfnext(v:false)<CR> nnoremap <silent><F10> :call <SID>qfnext(v:true)<CR> function! s:qfnext(next) abort " find all 'quickfix'-type windows on the current tab let qfwin = filter(getwininfo(), {_, v -> v.quickfix && v.tabnr == tabpagenr()}) if !empty(qfwin) ...


3

Classical issues, addressed in another Q/A I could copy paste a few feedbacks I gave in another Q/A: https://vi.stackexchange.com/a/11329/626 use guards (this used to be used to permit to inhibit a plugin from being loaded, this is less critical with package/plugin managers nowadays) don't forget the licence avoid global functions -- here everything but ...


1

You'd need to include the whole sequence, including the opposite of <C-E>, which is <C-Y>, and also the :sleep. map <F8> <C-E>:sleep 100m<CR>j<C-Y>:sleep 100m<CR>k<F8>


0

Ok, so i got the answer. Noremap does the work. Also, when in vim if something like this is there, 1 2 3 4 5 even with remapping and nothing, the both times cursor go from 1,2,3,4,5.


1

Vim :debug sessions are modal. When started we are prisoner of this non ergonomic mode. We could try to send anything we want to a buffer or a window, that window will never get refreshed and properly displayed. I guess Vim core would need to be multithreaded to support this, which is not the case. This issue was quickly mentioned during a poll on what ...


1

Even in v8.1, the short answer is no; you cannot positional-statically display the content of a variable without a plugin ... OR additional vim scripting. Alternatively However, Decho plugin does allow you to write info into another screen/buffer in a live manner using function calls. And DBGp is a debugger GUI for Vim debugging session (written in Python ...


0

There were two problems: Don't usea: for any local variables, as Luc Hermitte pointed out. When using the command execute you should use |expr-string| and to insert \ it should be \\. And so, the right way of writing it is like this function! Begin() call inputsave() let env = input("env: ") call inputrestore() execute "normal! i\\begin{".env."...


1

a: is for arguments. Don't use any prefix for local variables. PS: you'll have a better experience with a single new line and O instead of k


0

Solved by editing the part calling ToggleNetrw() From: augroup ProjectDrawer autocmd! autocmd VimEnter * :call ToggleNetrw() autocmd VimEnter * wincmd p augroup END To: augroup ProjectDrawer autocmd! if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") silent exe "bwipeout " . bufnr("$") exe '...


1

When I need to do that, I do it within the function: I assume that I'm not writing a re-entrant function. I prefer the mapping to be as simple as possible. Also, I use: script local variables (s:) to store global data -- i.e. independently of the current buffer. buffer local variables (b:), or a script local dictionary (s:) indexed by buffer numbers when ...


2

This is what happens: i - enter insert mode a - call func -> var = 1, but you left insert mode! a - executed in normal mode -> append -> you are back in insert mode a - call func -> var = 2, but you left insert mode! a - executed in normal mode -> append -> you are back in insert mode ... You might want to try inoremap a <c-o>:let b:var = Foo(b:var)...


Top 50 recent answers are included