6

Since Vim 8.1.553, you can simply supply a count to the scriptnames command to have it edited. So in your case, you can simply use: :25scriptnames or :scriptnames 25 to edit the zipPlugin.vim


4

That's a lot of code. ;) What if I said we could compact that whole thing down to a one-line command (and mapping)? Let's take it a step at a time, though. First, the substitution... :s/\u/ \l&/g ...will replace each capital letter in the current line with a space and the lower-cased letter. Same pattern/replacement can be used in substitute(). Let's ...


3

Another option is the Scriptnames command in Tim Pope's vim-scriptease plugin. https://github.com/tpope/vim-scriptease The script names are loaded into a quickfix list. Hitting return opens the script name under the cursor.


3

Yes, of course. function! Outer() abort let l:time = strftime("%c") function! s:inner(param) abort closure echom "Inner closure was created at" l:time echom "Param is" a:param endfunction return funcref("s:inner") endfunction let g:Inner = Outer() call g:Inner(42)


2

Remove :botright as it does: :bo[tright] {cmd} Execute {cmd}. If it contains a command that splits a window, it will appear at the bottom and occupy the full width of the Vim window. When the split is vertical the window appears at the far right and occupies the full height of the Vim window. Doesn't work for |:...


2

The vim.current.buffer list is a list of strings: :pyx import vim; print(type(vim.current.buffer[0])) <class 'str'> and strings are immutable in Python; something like a_str[2] = 'b' doesn't work either. This is just a property of the Python programming language (and many other languages, including VimScript). The general way to do this is to get the ...


2

B Layer answer is on point, that is easier to reader and make use of the right built-in functions. I posted this answer as an illustration of what you could have done to avoid changing your function but I think the other answer is a better option. Your converFromCamelCase takes a string and returns a new one, you can then create a wrapper which takes the ...


2

One way to prevent creation of a global function is to use "dictionary entry funcref syntax." Note that this is distinct, but also useful paired with, functions which are marked dict. function A() let l:container = {} function container.myfunc() echo "I'm going to leak" endfunction call l:container.myfunc() return l:...


1

You can save and restore the current tab around the :tabdo operation. You can use tabpagenr() to get the position of the current tab and later you can pass that number to :tabnext to change back to this tab. This is better done in a function, since you can easily run multiple commands and also use a local variable to store the current tab number. function! ...


1

Another alternative is to load the output of :scriptnames in a buffer like so: :call setline('.', split(execute('scriptnames'), '\n')) This will give you this in the current buffer: 1: ~/.vim/vimrc 2: /usr/share/vim/vim82/syntax/syntax.vim 3: /usr/share/vim/vim82/syntax/synload.vim 4: /usr/share/vim/vim82/syntax/syncolor.vim 5: /usr/share/vim/...


1

As explained here, among other places (better references welcome), NeoVim's ! is implemented using a subprocess with no interactive TTY attached. Use :terminal to run interactive commands inside NeoVim. Change your mappings to nnoremap <f4> :terminal node %<CR> nnoremap <f9> :terminal g++ -std=c++17 % -Wall -g -o %.out && ./%.out<...


1

To make something work in visual mode, you need a visual-mode mapping (usually :x[nore]map). In this case, we need to do these steps Save the register Restore the selection and do the cut (x or d or whatever) Restore the register if whitespace This is reminiscent of your original function, so let's modify it to take a visual arg: if truthy, do gv before ...


1

I use following to open directory where current file is and select it if possible: "" Open explorer where current file is located "" Only for win for now. func! File_manager() abort " Windows only for now if has("win32") if exists("b:netrw_curdir") let path = substitute(b:netrw_curdir, &...


1

Since your command contains a dynamic element (IOW it's not made up entirely of static strings) you'll need to build it with :execute. Assuming 'shell' and 'shellcmdflag' have the defaults for win32 (cmd.exe and /c, respectively) then this will work: exe '!c:\windows\explorer.exe ' . expand("%:p:h") If c:\windows is already in your PATH envvar ...


1

Style You spell out functions/commands/&c., which I think is wonderful. But you didn't spell out &cb. Prefer &clipboard. It appears you mixed spaces and tabs. Prefer one or the other (I use 2 spaces for vimscript). You're missing abort on your functions. function! is not strictly necessary according to :help E127, but this changed—I believe its ...


1

Using statox's wrapper function, here's what I wound up with, that works perfectly for the word under the cursor (made it a little more useful also): function! s:changeWordUnderCursor(new) normal "geb" let l:lastPos = getpos(".") let l:start = getcurpos()[2] normal "ee" let l:end = getcurpos()[2] + 1 ...


1

Here's a fully inline solution using register hacks and the expression register to insert the transformed string in place of the old string: nnoremap <leader>ccc ""ciw<C-r>=substitute(@", '\u', ' \l&', 'g')<cr> <leader>ccc is an arbitrary choice for ease of use while figuring out the signature - it doesn't have any ...


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