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
2 answers
53 views

How can I use 'while' and 'if' in Vim script properly to turn off highlight automatically?

Consider: This is my code in Vim. As the code comment describes, I want to remove highlight when the cursor moved. Currently, I highlight will remove when entering insert mode, but it can still be ...
Solarisending's user avatar
0 votes
1 answer
62 views

Vim: mapping tab to ctrl space only if the cursor is in front of a non whitespace character

I am using the jedi-vim extension and really don't like pressing ctrl-space to bring up auto-complete. I would like to use tab, but also obviously when coding I need tab for indentation as well. I ...
hshah's user avatar
  • 1
0 votes
1 answer
56 views

Pass local variables in a vimscript function to python

For example, I want to use default arguments: function! MakeOrgTable(...) let l:num_col = a:0 > 0? (a:0) : 0; python << EOF import vim vim.current.buffer[:]=make_table(vim.current.buffer, ...
Tokubara's user avatar
  • 167
0 votes
1 answer
127 views

Is there any invisible string character that can be ignored by "set fillchars", in the status line?

Currently, I'm trying to make a pretty minimal custom status line that suits my needs. One element of it, however, is a diagnostics report that depends on another plugin (coc.nvim). With a function, I ...
Idervas's user avatar
2 votes
1 answer
466 views

Cannot open terminal ini nvim

I installed Plugin terminal using the vim-terminal plugin and try to execute :TerminalSplit bash but before the terminal open I got a warning message. Python 2 interface is not installed, using Python ...
Muhammad Fhadli's user avatar
1 vote
2 answers
140 views

Detect Editing of Directory

How do you detect if a directory is opened(with :edit) in Vimscript? I am lazy loading a file explorer and need it to load it before I open a directory. One approach I tried using an autocommand that ...
unrealapex's user avatar
2 votes
1 answer
40 views

Can you select and execute VimL / VimScript inside another file?

Update: It is possible with '<,'>source. I figured it out right after writing this question, no need for the complicated workaround. I am gonna still let this question here and not delete it, ...
Bog's user avatar
  • 457
1 vote
1 answer
338 views

How to check if the lua function is available in vim script?

On nvim, we can use 'v:lua' prefix to call a lua function in vim script. But can we check if the lua function is available, like exists('*funcname')?
Rick Howe's user avatar
  • 353
0 votes
2 answers
198 views

VimScript: Substitute string variable content for string variable name

I would like to the present working directory (:pwd) be changed across all tabs and subwindows at the same time. I tried: let PreferredPWD=expand('%:p:h') " The desired working directory " ...
user2153235's user avatar
1 vote
1 answer
33 views

Highlight a single word that would be encountered after a specific word

I want to highlight the next word encountered after a specific word (e.g.: "class"). In other terms, the next word after "class" should be highlighted with the highlight group that ...
SuperNoob's user avatar
0 votes
0 answers
26 views

Remove words from comments in vim autocompletion

I have looked for similar questions but I was quite surprised to not find anything similar... either I am the first person on this planet to have this issue, or I have searched using bad keywords. ...
Tropilio's user avatar
  • 109
0 votes
2 answers
102 views

How to use a variable from register in command mode?

I have a list of cities London Madrid Paris Brasil I want to write a macro, that will add a ul tag and wrap each city in to an li. I think, i need to create a variable like: let i = 4 Than to write ...
serii 's user avatar
  • 77
0 votes
1 answer
61 views

How do I use variables with the delete command? (i.e., how to expand/reference variables for command arguments?)

I'm using variables for line numbers, and I want to delete a range of lines using these variables. How do I do that? let x = 5 let y = 20 " I want to delete the range of lines from x ...
Rob Bednark's user avatar
0 votes
1 answer
71 views

Stop flushing the last command when hitting enter

Suppose I wrote this command: command! -nargs=1 E echo ' -> <args>' and when user feeds an argument, :E abc I intend to see the following effect as they hit Enter: :E abc -> abc Of ...
Futarimiti's user avatar
0 votes
1 answer
200 views

Go to file with gf from :terminal

I often keep a :terminal open on the right of a vertical split, and on the left keep a window open for files: ------------------------------ | | | | file buffers | :terminal ...
apostl3pol's user avatar
1 vote
1 answer
80 views

Use contents of copy-paste buffer in command

I would like to use the content that reside in the current copy-paste buffer in a Vim command. For example: nnoremap <leader>hi <cmd>echo "copy-paste-buffer-content"<CR> ...
felrock's user avatar
  • 13
0 votes
1 answer
75 views

vnoremap to sort highlighted lines by length not working as expected

I found a command that would sort highlighted lines by their length and wanted to make a mapping for it so that I could avoid typing it every time. vnoremap ,s :<C-U>'<,'> ! awk '{ print ...
Shreevathsa GP's user avatar
0 votes
1 answer
36 views

How to define default values for variables defined in ftplugin?

Say that I have defined two files python.vim let b:foo="py" let b:bar="thon" cobol.vim let b:foo="co" let b:bar="bol" and that I placed both of them in ~/.vim/...
Barzi2001's user avatar
  • 516
1 vote
1 answer
49 views

User function unexpectedly returns the same output every call

UPDATE As @Matt pointed out g:jsonTemplate is a list that needs to be copied. I originally thought that multiline strings were strings and overlooked the varible assignment detail after debugging. The ...
a_baguette's user avatar
-1 votes
1 answer
76 views

What's the corresponding command of `CTRL-Y` and `CTRL-E`?

As title. I know that I can just press CTRL-Y/E to scroll, but now I need to use a script to execute them. What are the commands?
NeoZoom.lua's user avatar
  • 1,392
0 votes
1 answer
266 views

How to know that neovim is started by zsh command "git commit" from my terminal emulator?

As title. I'm building a plugin and this is the last step. I've configured my .zshrc so that git will use neovim as its texteditor program to enter commit messages in interactive mode. The on-going ...
NeoZoom.lua's user avatar
  • 1,392
0 votes
2 answers
105 views

How to apply a command to all tabs?

As title. I want to call a command to all existing tabs to close all windows of specific filetype. How to do so efficiently?
NeoZoom.lua's user avatar
  • 1,392
0 votes
1 answer
48 views

How do I override indent/html.vim's attribute indent behavior

Stated Purpose I'm trying to override Vim's HTML attribute indent behavior. This question is specific to ft=html. Vim has always inserted too many spaces when indenting HTML: <div> <div ...
amphetamachine's user avatar
0 votes
1 answer
53 views

Is it possible to disable showing `-- VISUAL LINE --` hint in the command line?

As title: I have a plugin that needs to show something in cmdline but now the space is occupied by: -- VISUAL LINE -- Any hint to get rid of it?
NeoZoom.lua's user avatar
  • 1,392
0 votes
1 answer
474 views

How to move buffer between tabs?

As title. And I also need to know how to specify a tab to move to. So I expect the syntax would look like this: :movebuf <buffer_id> <tab_id>
NeoZoom.lua's user avatar
  • 1,392
0 votes
0 answers
12 views

Why `<C-h>` is mapped to backspace even if I remove all the insert-mode keymaps of `<C-h>`? [duplicate]

As title. I'm using NeoVim and there is a syntax to remove all mappings of specific key-comb. in specified mode: vim.keymap.del('i', '<C-h>') But after the call :imap <C-h> shows: i <C-...
NeoZoom.lua's user avatar
  • 1,392
0 votes
2 answers
2k views

How to select all text and delete in vi?

Is it possible to select all the text and delete it it in vi other than hitting backspace?
kraber's user avatar
  • 1
1 vote
2 answers
416 views

Insert Result of an Internal Vim Command into Text/Buffer (e.g. vims echo command)

Question I want to have basically the same as :read ![external command], but instead the external command I want to read the output from an internal command. Example Shells echo / external command: :...
Bog's user avatar
  • 457
0 votes
1 answer
303 views

Is it possible to detect key-release event in NeoVim?

As title. I want to simulate the App-switching feature of macOS cmd+tab. To do so I need to detect the release of some key to trigger my lua function. Any idea?
NeoZoom.lua's user avatar
  • 1,392
0 votes
0 answers
33 views

understanding and modifying an include-search map command

I found a useful map at the include-search ([I) help. map <leader>1 [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR> This opens the ...
barak.o's user avatar
0 votes
0 answers
23 views

in vim: how to transfer the contents of one .swp to another swapfile

I have very often following incidence: I begin a new program to edit in vim. After a time I have with this name the current file, the current swap file and many backups with filename-suffixes .WE-01 .....
Anton Wessel's user avatar
1 vote
0 answers
33 views

Is there a way to map remap 0<C-d> in insert mode

I'm doing a plugin which modify how shift works and remap <C-d> in insert mode. Every thing works well but I have a problem with 0<C-d>. It is a built-in mapping which reset the ...
mb14's user avatar
  • 156
0 votes
2 answers
394 views

How to execute all autocmds of a specific augroup?

As title. I just randomly come up with this question. To do so one would need to iterate over all autocmds in the augroup. Is this possible?
NeoZoom.lua's user avatar
  • 1,392
0 votes
2 answers
78 views

Is there a way to get vim to print human-readable output of type()?

How to convert the output of the type() function, which is a number, into a verbal format, e.g. as described in help v:t_...? To write my own mappings seems to be too cumbersome. Presumably there ...
Anton Wessel's user avatar
2 votes
1 answer
403 views

How to find LUA method for VIM Command

I am in the process of converting my .vimrc to init.lua. Several of my lines end up containing vimscript inside a call to vim.cmd, such as vim.cmd("highlight Normal guibg=none ctermbg=none") ...
Benj's user avatar
  • 155
0 votes
1 answer
88 views

How can I make 'quickfixtextfunc' work with cfilter using a vim9's "def" function?

On Windows 10, using gvim, when editing a file like the following example: foo foobar baz As long as I use a function and not a def, I can do the following and Cfilter will work as expected: :...
Minh-Tâm TRAN's user avatar
0 votes
0 answers
44 views

^@ added when calling system in cmd.exe [duplicate]

Here is an excerpt of my vimrc let g:conda_activate = 'myenv' function Condaenv(env) return trim(system("conda activate ". a:env. " && call echo %CONDA_DEFAULT_ENV%")) ...
Barzi2001's user avatar
  • 516
3 votes
2 answers
253 views

Recursion in lambda expressions

Alright, so I have two recursion functions with the exact same purpose: let Fac = { n -> n == 0 ? 1 : n * Fac(n - 1) } function! Fact(n) return a:n == 0 ? 1 : a:n * Fact(a:n - 1) endfunction ...
Futarimiti's user avatar
0 votes
0 answers
28 views

directly copying from `vim` to `mariadb` shell causing error

I have a file https://0x0.st/oYoB.com_5zfu After opening it with vim I tried to copy some portion of code and paste it in the mariadb shell. But it looked like mariadb was giving error. MariaDB [...
altair00's user avatar
3 votes
1 answer
95 views

Keep X-rows below current cursor position if fewer than Y-rows are left

I recently started using Vim to write my notes after moving away from VS Codium for this. I'm really enjoying the speed and the ability to navigate keyboard only, but there is one thing that is ...
pSYoniK's user avatar
  • 33
1 vote
1 answer
26 views

Inconsistent string handling [duplicate]

I've been assembling strings in vimscript using a . as the join command. But when I try and use the same command to join a string when setting an option, such as: :setlocal foldtext=v:folddashes . &...
markling's user avatar
  • 319
1 vote
2 answers
101 views

How to substitute text in vimscript?

I want to replace b by a in visual selection. I have vimscript like this: execute("normal! vip:s/a/b/g") It works in command line mode. But not work in vimscript. How to fix it? How to ...
lizhe's user avatar
  • 137
1 vote
1 answer
28 views

Why my second line of "normal command" not work?

here is my vimscript function, the first line of code is fine. Add a " at begin of line. But the second line of code is not work. The third line is shorter than the second line and it worked. Why ...
lizhe's user avatar
  • 137
1 vote
0 answers
42 views

How to to get commmand completions for selection from a keymap?

The idea is to have a keybinding, which executes a lua/vimscript function to paste yanked text into the command line and then have the command completion showing suggestions or directly get the ...
Jay-Pi's user avatar
  • 123
1 vote
2 answers
659 views

How do I hightlight the gutter in vim/nvim?

As you can see in the image below, I have this weird highlight on my gutter. I'd be great if I could make that transparent. How can I do it? EDIT: I just found out that I can do :higlight SignColumn ...
Diwas10's user avatar
  • 115
2 votes
2 answers
207 views

How to define a do-nothing event?

As title. I want to define an event via autocmd User MyEvent .... Then when some internal state of my plugin is reached, I will trigger the event with doautocmd User MyEvent. So, how to write the part ...
NeoZoom.lua's user avatar
  • 1,392
1 vote
1 answer
76 views

Is it possible to only change the font size of the current window?

As title. Say I have two vertical splits, and I only want to increase the font size of the right split. Is this possible? If so: What's the API to get the current font size? What's the API to set the ...
NeoZoom.lua's user avatar
  • 1,392
1 vote
2 answers
104 views

How to remove the new line in redir command?

I am using a command like this: :redir @+ | set guifont | redir END The output of the command above is: guifont=Source Code Pro:h14 Note the blank line at the beginning. How can I remove it? I ...
lizhe's user avatar
  • 137
1 vote
1 answer
81 views

Is there a ctags option for vimscript?

How to jump to a vimscript file's function definition? (I'm having a hard time searching for this particular functionality, then getting results for using ctags in Vim, and not sure how to phrase that ...
nymo's user avatar
  • 121
0 votes
2 answers
77 views

How can I chain together regular expression substitutions

I am trying to write a command that changes author lists of the form R. L. Rivest, A. Shamir, and L. Adleman Into one nice for BibTeX, namely: Rivest, R. L. and Shamir, A. and Adleman, L I have ...
sdpoll's user avatar
  • 103

1 2
3
4 5
32