5

In the :help cmdline-completion section, see this paragraph discusses suffixes *c_CTRL-D* CTRL-D List names that match the pattern in front of the cursor. When showing file names, directories are highlighted (see 'highlight' option). Names where 'suffixes' matches are moved to the end. The '...


3

Is this possible using QuitPre? "Quit" means quitting a buffer as in :quit. You probably want ExitPre instead. can I implement such functionality using Vimscript? No, AFAIK, the action cannot be aborted by autocmd. Based on the user's response, Vim should either quit, or cancel the quit Simply :set confirm and no worries.


3

In no particular order. Readability Any sequence of normals, except a very short one, is nearly impossible to read and understand. Vimgolf can't lie. Clobbering registers etc. Quite often there is more things to change than one can even remember of. For example, your code sets at least four(!) registers and six(!) marks. Plus :h changelist and :h jumplist. ...


3

TL;DR: Truthy: Non-0 Numbers (any integer but 0) Strings that convert to a non-zero number All strings starting with a digit which is not '0' Numbers not starting with '0', eg: -123 0x10 0177 0o177 0b1011 Falsey: 0 in integer form only -- float 0.0 gives E805: Using a Float as a Number v:false, v:none and v:null Any string that evaluates as 0 when 0 ...


2

Just use the tabpagenr() function, which returns the number of the current tab page when called without any arguments, or the last tab page number when called with a '$'. The following expression should tell you whether you're on the last tab: tabpagenr() == tabpagenr('$')


2

Buffer is called "hidden" if it's Loaded Not shown in any window :echo bufloaded(N) && win_findbuf(N)->empty() or :echo bufexists(N) && getbufinfo(N)[0].hidden


2

an API to return all (loaded) buffers :h getbufinfo() loop through each of them :h filter() if the buffer is a No Name-buffer :echo empty(bufname(N)) :echo empty(getbufinfo(N)[0].name) an API to edit that buffer on the current window (split) by that buffer number :h :buffer


2

To run normal mode commands as ex command use :normal! as in normal! gv Note, exclamation mark is for running non-mapped "built-in" functionality: :nnoremap l :echo "hello"<CR> " this would echo hello :normal l " this would move cursor right :normal! l


1

:h expand() your string with environment variable, concatenate it the rest and use :h :execute to source it: :execute "source " . expand(prefix) . "/whatever.vim"


1

I see now the :normal command will exit the visual selection mode temporarily, so if you wanted to get the visual selection, you have to reselect it in the command by using gv, as in :execute "normal gv\"ay". This would require the command be used when there's a visual selection active; if you used it with the default range, it would select ...


1

You can use the getcompletion() function to resolve all highlights starting with a specific prefix. For example: :echo getcompletion('DevIcon', 'highlight') ['DevIconPng', 'DevIconJs', ...] You can then use that in a for loop to act on them. :for hl in getcompletion('DevIcon', 'highlight') | execute 'hi '.hl.' guifg=#123456 ctermfg=25' | endfor See :help :...


1

I took Luc Hermitte's helpful answer and improved it somewhat. It was returning unlisted (previously deleted) buffers, which isn't what I wanted. It now filters on buflisted(v:val), rather than on !empty(v:val). I've added two commands: Lssave: saves the unsorted buffer list as-is LSsave: saves a sorted version of the buffer list mkdir the output file's ...


1

Usage example: function! PrintMyName() echomsg 'My name is: ' . FnName() endfunction call PrintMyName() Output: My name is: PrintMyName Behind the scenes: " Stacktrace - return array of function names " Eg, to get calling function name: Stacktrace(expand('<sfile>'))[0] " Based on: https://stackoverflow.com/a/33094990/5353461 ...


1

Not an answer, but I think you'll appreciate it. let saved_pos = getcurpos() call search('mysearch') normal! 0c$better call setpos('.', saved_pos) I used "better" functions ("better" - maybe not. Up to you). And mixed/matched normals with scripts. What do you think? Read this: Master Wq and the Markdown acolyte from https://blog.sanctum....


1

I just found that NeoVim provides some functions to do so easily: local cur_win = vim.api.nvim_get_current_win() -- do your windo, for example: vim.cmd("windo if &buftype != 'nofile' | let g:non_float_total += 1 | endif") vim.api.nvim_set_current_win(cur_win) And since my problem was originally asked in context of Vim before edit(yeah, it's ...


1

Here's a way that doesn't use :windo :echo tabpagebuflist()->filter({_, v -> getbufvar(v, '&buftype') isnot# 'nofile' })->len() (My original solution used map() to get the buftype and then filter() on that list; the advantage of combining them is that, if you were interested in other things than len(), you would still have the buffer numbers ...


1

There may be a more efficient way to do it but this should work: " initialize count variable let g:cnt = 0 " run test for each window incrementing count when appropriate windo if &buftype !=# 'nofile' | let g:cnt += 1 | endif " then, for example, we could display the count echo g:cnt


1

Start with: echo tabpagewinnr(tabpagenr(), '$') tabpagenr() gives you the number of the current tab page. Use '$' as the second param to tabpagewinnr() and that function will return the number of windows contained in the specified tab page. So you can test for single window (no splits) with something like: if tabpagewinnr(tabpagenr(), '$') == 1 " ...


1

Any of :normal! ^ (or 0, or $) the functions setpos, cursor, or setcursorcharpos should do it. OTOH, on the : line you need things like <C-b> and <C-e> (see :help cmdline-editing), or press <C-f> and use normal motions.


Only top voted, non community-wiki answers of a minimum length are eligible