Questions tagged [vimscript]

A scripting language embedded into Vim. It can be used to customize Vim to suit your needs and to create plugins. Also called VimL.

Filter by
Sorted by
Tagged with
0
votes
0answers
10 views

How to pass arguments to `:map gx <Plug>(SomeFunction)`?

Context I'm evaluating https://github.com/tyru/open-browser.vim which looks really promising. I figured out how to set the default search engine and add a mapping " vim-openbrowser let g:...
0
votes
1answer
18 views

Compile C++ in vim

I want to make a shortcut for compiling C++ file. I use :map <F5> :!g++ % -o app && ./app <CR>. How can I edit it to set output file's name, C++ file's name without .cpp instead of ...
0
votes
1answer
29 views

How to `source` a path stored in a variable in Vimscript

tldr: The title pretty much summarizes the entirety of the question I am trying to make my configuration more adaptable to different machines so that I can use git to keep them in sync between my ...
0
votes
1answer
18 views

How to check if the current tab is the last tab?

As title. I want to check that if current tab is the last (rightmost) tab, how?
0
votes
1answer
16 views

How to check if a buffer hidden in all tabs?

As title. I want to check that a buffer is not shown in any tabs. How to do so?
0
votes
1answer
26 views

How can I switch to the `[No Name]` buffer

As title. Is it possible to change the current buffer by vimscript to the (only) [No Name] buffer? I need these tools: an API to return all (loaded) buffers loop through each of them if the buffer ...
0
votes
2answers
26 views

How could I create a terminal window in the background?

I want vim to launch rails console(it's like relp) within terminal windows when vim is launched on my project directory. To launch rails console, I need to run three commands like below and it's ...
0
votes
1answer
37 views

Re-Select Previous Visual Selection with Command

As title. I want to create a function that facilitate this behaviour. I have tried this but it didn't work: exe 'gv' I tried from this direction because this works: exe 'c!'
0
votes
1answer
21 views

Place visual selection inside of a variable inside of a command

I want to write a command that works with a visual selection, so I wrote something like this: command! -range Foo \ exec "norm \"ay" | \ echo "[" . @a . "]" ...
4
votes
2answers
55 views

Advice on the use of :exe "norm!" vs. built in functions when writing vimscipt and plugins

I've been using vim for about 3 years and am starting to write my first plugin. I've noticed when looking at the code of other popular plugins that the functions very rarely seem to achieve their aim ...
0
votes
1answer
18 views

NeoVim: How to move the cursor to a window by its window number?

As title. After doing windo it seems like Vim forgot where it started.
1
vote
2answers
46 views

How to count the total number of windows excluding some buftype?

As title. Some floating windows will have buffer type (buftype) value nofile, I don't want to count them! How?
0
votes
1answer
20 views

How to count the total number of splits opened in the current tab?

As title. I want to detect the case when there is only one split in the current tab.
0
votes
0answers
26 views

vim execute not working in script

I am using a plugin that expands the word template by a template but only if the word template is followed by a tab. I am trying to write the word new then in insert mode jump to the end of the line ...
0
votes
0answers
20 views

activate vim-lsp on single JavaScript files

vim-lsp's typescript-language-server doesn't seem to work or get activated when working on single JavaScript files or projects that are (I think) under version control. Is there a way to configure ...
0
votes
1answer
99 views

Neovim 0.5+ setup as Rust IDE

So I am trying to set up neovim 0.5+ as a rust IDE. I am following this guide. Except, as shown in the guide, there is not completion even after doing <c-x><c-o>. I have kept the config in ...
0
votes
1answer
30 views

Vimscript - Loading function(s) from another .vim file

I'm forking an old vim plugin (effectively dead since 2018) that needed some love. Once I got to the .vim file, I noticed that the functions were all defined in there, which made the file unreasonably ...
1
vote
1answer
21 views

How to center the current line to 80% height of the current window, in NeoVim?

As title. Since no one wants to become a turtle, I want to setup a behavior like M but instead pin the current line to 80% height (0% start from bottom) of the current window, not to center.
0
votes
2answers
39 views

Use command to move cursor like `^` and `$`, in NeoVim?

As title. How to move the cursor with vim command :...? I want to make a toggle that achieves this behavior but I didn't find anywhere this is explained :(
2
votes
0answers
41 views

Make Lightspeed work with Repmo

I'm trying to make the EasyMotion-like (cursor jumping) Lightspeed plugin work with Repmo which repeats a previous motion. So far, (and after many hours), I've come up with the following: let g:...
1
vote
1answer
32 views

How to cancel quitting in a QuitPre autocmd

I want to write an autocmd that prompts the user when the user tries to quit Vim. Based on the user's response, Vim should either quit, or cancel the quit. Is this possible using QuitPre? If not, how ...
3
votes
1answer
78 views

Sort tab-completion suggestions (files first, then directories) in vim command line

When i go to command mode, type :e and press tab, i get like this Excuse the file, directory writings on the right side (used for explanation) A.cpp file Adamwathan/ directory ...
3
votes
1answer
46 views

What values are truthy and falsey?

What are the truthy and falsey values in classic vimscript (not vim9script)? What is the canonical list, and where do I find it in :help?
0
votes
1answer
18 views

Set all highlight groups starting with a certain name?

Basically I have a long list of highlight groups that start with DevIcon (DevIconPng, DevIconJs etc.), they all come with their own ctermfg and guifg and I would like to change them to a single color. ...
0
votes
0answers
35 views

The dilemma of using both space-tab and tab

Now I have to learn some makefile. I only need to use the plain-old tab in this file. In other ones I want to happily keep my 4-space-tab. My current idea is to find a way/script so that I can toggle ...
2
votes
1answer
55 views

How to overlap searching result?

Given that I have string AABBAABBAA. I cannot find two AABBAA with the / that vim provides. Is there any option to enable this behaviour or I need a script/plugin?
0
votes
0answers
28 views

How to determine the cursor is close to the last line of the file?

As title. I have the following script and I want to set scrolloff to 0 when the cursor is approaching the last line of the current file. vim.cmd [[ augroup switchScrolloffTopBottom autocmd! ...
3
votes
1answer
58 views

How to check if value is v:null?

What is the proper way to check if a particular variable is null? I use v:null as a special value to indicate something in a custom function's return value. I have tried: let l:v = v:null echom l:v == ...
1
vote
1answer
28 views

BufDelete running after window is closed

For some reason, the BufDelete autocommand is being executed right after a window is created, instead before, and i think it shouldn't be like that, according to the docs: Before deleting a buffer ...
1
vote
1answer
36 views

Is it possible to set scrolloff to top and bottom with different values?

As title. For example, say I imagine there is something like scrolloffTop and scrolloffBottom and I can set each with different values. If there is no such options, I would like to know is it possible ...
1
vote
2answers
34 views

-complete=file without extra processing of the arguments

Without -complete=file: command! -nargs=* C1 echo <q-args> C1 fzf#vim#grep /home/yuri/.vim/pack/foo/start/fzf.vim " fzf#vim#grep /home/yuri/.vim/pack/foo/start/fzf.vim With -complete=file: ...
0
votes
0answers
37 views

Auto update a buffer opend in a split when it changed?

I'm writing TypeScript and there is a command npx tsc --watch that will (over)write to an output file every time the source file is changed. I open one split for each of these files. But when I save ...
0
votes
1answer
39 views

vim. How do you replace 'x' with 'y' and 'y' with 'x'? [duplicate]

I don't want to do this manually, and I'm sure there is a way for vim to do it. I probably am not googling the correct question to find the result I want, but here is what I want to do. I have this ...
1
vote
1answer
23 views

`:call append!` -- how vim insert line (append or setline) while respecting indentation

I want to put a string function output in my vim when press xx. My current working example is: nnoremap <silent> xx :call append('.', 'string_output')<CR> However, this put a line without ...
1
vote
2answers
59 views

How do I suppress beginning newline added by put()?

I've got this simple function: " generates a link in markdown using an extern script function! WebLink() put =system('~/bin/taskwiki_helper.pl markdown_link_from_url') endfunction It works ...
3
votes
1answer
138 views

Can the arguments to a custom Vim command be grouped by quotes?

I would like to define a custom Vim command that takes arguments grouped by single or double quotes. For example, if my arguments are a "b c" then I want a to be considered the first ...
1
vote
0answers
42 views

ALE project root for Python

I use ALE to run linters while editing Python code in vim. When working on code in a package, I can't get ALE to respect the pylint configuration in the project root. I've had it in .pylintrc as well ...
0
votes
1answer
42 views

Generate relatively unique "cache filename" for given file path (like swap files do)

For each filename, Vim generates (relatively) unique filename for it's swap cache directory. Let's say I would like to store some information for each file (like swap files do), e.g. with : silent ...
0
votes
1answer
29 views

Display extra column before/after line numbers and modify using Vimscript

How to display extra column before/after line numbers , and modify , programmatically, using Vimscript? Maybe some examples of existing plugins doing so, that I could base of? (this could be great ...
1
vote
1answer
43 views

Echo filename before deleting buffer

I would like to echo the filename before deleting any buffer (:bd, :q). I wanted to achieve this by using auto-commands like this: augroup DummyCodeGroup autocmd! autocmd BufDelete * lua print(...
0
votes
2answers
18 views

Insert mode <S-Tab> to delete one <Tab>-indent?

I want to use <S-Tab> to do the reverse of <Tab> in insert mode in Lua. (If this is complicated in Lua then VimScript is OK) How?
2
votes
0answers
45 views

Constant-update Words Per Minute in Vim?

I'm interested (mostly just for fun) in seeing my typing speed while working in Vim. I saw this post but this requires starting and stopping a function. I would prefer this to be a constantly updating ...
1
vote
1answer
21 views

How to get activated current `b:keymap_name` value

I have a below line set keymap = russian-jcukenwin.vim in .vimrc. When I press C-^ I get indicator in mode line , like INSERT (RU). I'd like to output it in lightline vim config, and there is %k flag ...
0
votes
1answer
49 views

Is there a vim that uses python instead of vimscript throughout?

There is a vim plugin that allows even the .vimrc to be composed in lua. But I would prefer python. Does anyone know of such a plugin or version of vim that uses python throughout the internals, ...
4
votes
1answer
826 views

What is the difference between "==" and "is" for checking the equality of strings?

What is the difference between == and is; ==# and is#; ==? and is? when checking whether or not two strings are equal? Sometimes I see foo is# 'bar', and I wonder whether or not it is always ...
0
votes
1answer
40 views

How to replace selected text T with some function(T), using a keyboard shortcut?

I want to annotate words /sentences for a "named entity recognition" purpose; inside a text file, I want to annotating words or sentences with this format [pattern](label): [a word where the ...
0
votes
1answer
92 views

Vim editor entities tagging/annotation tool

I'm looking for a word/sentence annotation tool/plugin to be used INSIDE vim editor. Specifically I'm looking for a cli tool NER (named entity) tagging. Any idea/suggestion/tip? By example, I would ...
0
votes
0answers
28 views

in vimscript how to write the code a CTRL-C to be executed

I run a sourced vimscript like this: exec 'g#' . WE_var_searchmode . ' ' . WE_var_pattertosearch . '#exec " A | B | C | make_CTRL-C | ... | LAST " ' The outer execute '...' is needed to ...
0
votes
1answer
26 views

Is there a way for Vim to re-source all the startup files without quitting and re-starting?

I write a lot of Vim plugins. When I make an edit to a plugin's .vim file, I'll often just quit Vim and restart it to test it. In some cases, I would like to avoid quitting and restarting Vim. I ...
0
votes
0answers
48 views

vim problem when in "try" ... "catch" an "if" is between

When a vim script is to be watched for errors and interrupts, try is put somewhere near the beginning and catch after a long sequence of code. In this sequence of code it is very probable to have some ...

1
2 3 4 5
27