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.

180 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
0 answers
453 views

How do I call functions and commands from .vim files in Vader tests?

I am trying to write tests using Vader plugin but unfortunately, every time I try to invoke a command/function in Execute/Do block it doesn't see seems to work on the text provided in Given block! # ...
avimehenwal's user avatar
5 votes
0 answers
225 views

Issue when moving Vim9script plugin's functions to autoload

I've read :help write-plugin to understand a bit more about how to write a plugin in Vim9script, but there aspects of that that puzzle me. Here's a very simplified, working version of the example ...
Enlico's user avatar
  • 2,184
5 votes
1 answer
278 views

How can I decide whether a file can be opened in Vim or not?

I want to make a script with FZF (Fuzzy Finder) and I want to show only those file which can be opened with Vim. So, I don't want to list mp4, jpg, pdf etc files in FZF. So, is there any way to decide ...
Ujjwal Gupta's user avatar
5 votes
0 answers
618 views

Syntax highlighting: what is the difference between :syntax match and :match?

Simple question -- what is the difference between the two? When I try, for example, to highlight characters on every line after the 80th with highlight link OverLength Error (OverLength being an ...
Luke Davis's user avatar
  • 1,397
5 votes
0 answers
176 views

How can I display multiple lines in the same compiler error when using :cn?

I am using Vim for Rust development. I have a custom error format that works very well, except that newline characters in error messages are suppressed when scrolling through errors with :cn. This ...
Demi's user avatar
  • 151
5 votes
0 answers
242 views

Set line breaks, word wraps and word searching for Thai and other non-latin languages

I can set the text width and can manually line break imported paragraphs with the following as an example. set textwidth=72 gqq I can also navigate English text files with the standard 'w' 'b' 'e' '*...
BrianWilson's user avatar
4 votes
1 answer
118 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 ...
kipawaa's user avatar
  • 41
4 votes
0 answers
507 views

vimscript - copy a file from one path to another

How do I rewrite this line of code call system("cp /tmp/foo.txt /tmp/bar.txt") into a vim command which is more portable and OS-independent? I've been looking around but checking for "...
ColinKennedy's user avatar
3 votes
0 answers
66 views

When editing vim script files (*.vim), line continuations are not highlighted properly

When I edit VIM syntax highlighting definitions or any other VIM script file (*.vim), I lose syntax highlighting on lines that are continued from the previous one. For example, syntax region ...
karlh's user avatar
  • 405
3 votes
0 answers
536 views

How can I use let `g:netrw_keepdir = 0` for folders and `autochdir` for files?

Normally I want to use autochdir to change to the directory containing the file which was opened or selected However, in netrw, there's a warning However, the autochdir option: :set acd is ...
user202729's user avatar
3 votes
0 answers
663 views

How to escape paths for findfile() and finddir()?

I have run into an escaping problem with the path argument to findfile({name}, {path}) / finddir({name}, {path}). In my code path is a directory, obtained via fnamemodify(<file>, ':h'). Until ...
Andy Stewart's user avatar
  • 1,349
3 votes
0 answers
221 views

Why does vim CursorMoved event triggered in this script?

I'm writing a vim script. When fun() is called, I want a new window of 3 lines height is opened, with the content of register h displayed. And then, when the user moved the cursor, like hjkl, the ...
byhc's user avatar
  • 31
3 votes
0 answers
126 views

Completly silencing commands like `dd`, `:delete` of old vim versions (7.4.152)

Discl. I'm perfectly aware of :silent :delete or silent :normal dd, I'm also aware of execute(). My context is that I run unit tests with vimrunner on travis, with the version of Vim currently ...
Luc Hermitte's user avatar
  • 17.3k
2 votes
0 answers
33 views

How do search's b and z flags interact?

I'm using searchpos instead of search is I can echo the column where the match happens, which, with example file below coincides with the matched character. 123456789 ^ | +-- cursor is ...
Enlico's user avatar
  • 2,184
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
2 votes
0 answers
174 views

How to split view all buffers in vim with equal distribution vertical horizontal

How can I split view all buffers in vim with a distribution between vertical and horizontal? Is there a plugin? I know how to make all buffers appear in either horizontal or vertical splits: :ball :...
Polo's user avatar
  • 41
2 votes
0 answers
66 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:...
Tom Hale's user avatar
  • 2,631
2 votes
0 answers
138 views

Conditional mapping for two plugins (UltiSnips and Vimwiki)

Vimwiki table default mappings include <tab> for moving to the next table column in insert mode. Also UltiSnips default mappings include <tab> for expanding snippets in insert mode. Here ...
mahbubweb's user avatar
  • 592
2 votes
0 answers
75 views

Can you read the value of `showcmd` in a vimscript function?

I don't know how to make any vimscript I'm writing or running aware of what my pending command is! Specifically: When I hit ^W in preparation to change the window I'm selecting, I'd like to have my ...
Ari Sweedler's user avatar
2 votes
0 answers
82 views

How to delete the previous buffer when loading new result from quick-fix window?

In the quick-fix window, if I'm loading new results, the previous buffers stay which I don't want. I want only those buffers to stay which I open intentionally (e.g. to write new code, do diff of ...
Haris Muzaffar's user avatar
2 votes
0 answers
57 views

Tagbar line numberings being overwritten

I'm trying to use the Tagbar line numbers: " Show line numbers (0 = none, 1 = absolute, 2 = relative) " note: this doesn't work well and is often overwritten by rnu settings let g:...
David542's user avatar
  • 2,415
2 votes
0 answers
223 views

Check valid values of an option (e.g. check if completeopt+=popup is valid)

I want to know if I can use the popup option for my completeopt in the running version of vim/neovim. The example is just for clarity, I'm looking for a solution that is generic. I know I can check ...
silico-biomancer's user avatar
2 votes
0 answers
285 views

Resource for highlight syntax debugging

I’ve been developing a Vim syntax file for ISC Bind 9.15+ The stock named.vim that came with Vim is quite outdated (V9.4) About 89 syntaxes out of 498 have been completed so far to catch up. But ...
John Greene's user avatar
2 votes
0 answers
398 views

get current vim mode inside vimscript code

I would like to be able to get the current usual mode of vim inside a vim script (and not only inside the statusline). I need this functionality to build a vim script linked with ruby script to be ...
jerome___'s user avatar
2 votes
0 answers
285 views

What happens when error occurs during cdo?

:h :cdo says: When an error is detected execution stops. The last buffer (or where an error occurred) becomes the current buffer. Let's see what really happens: ...
dedowsdi's user avatar
  • 6,238
2 votes
0 answers
56 views

How to identify the last DiffUpdated event?

The DiffUpdated event has been added in patch-8.1.0397. Sometimes the event occurs a few times in a session. For example, when 2 files are opened in diff mode, ":e!" generates the event 3 times. As ...
Rick Howe's user avatar
  • 353
2 votes
0 answers
1k views

Vim+Tmux: How to switch between Tmux Windows and Vim Tab Pages Seamlessly using the Alt Key?

In Vim I can switch between tab pages with :tabnext- to go left and tabnext+ to go right, simulating the tabs on an IDE. In Tmux I can switch between windows using <prefix>p and <prefix>n ...
Incalculon's user avatar
2 votes
0 answers
597 views

What is the correct character for splitting a string on line breaks in Vimscript?

Consider the following text file. line1f line1n line2 Suppose I visual select this, yank it into register a, and then pass it to the following vimscript function: function TestSplit(block) for x ...
merlin2011's user avatar
2 votes
0 answers
211 views

Is it possible to call searchpair or searchpairpos on string instead of current buffer?

searchpair or searchpairpos works only on current buffer. Are there similar functions work on string instead of buffer?
dedowsdi's user avatar
  • 6,238
2 votes
0 answers
367 views

Jump to last position when using vim netrw to open a file

I am looking to jump automatically to the last position in any file that I open. I have in my ~/.vimrc file: autocmd BufReadPost * ...
anti-destin's user avatar
2 votes
0 answers
152 views

display list of buffers `ls` without scrolling down

Is there a way to display output at the bottom of the screen like ls does, but without scrolling down to accomodate the output? The Vim Wiki (no https) has the following snippet :nnoremap <A-n>...
Greg Nisbet's user avatar
  • 1,839
2 votes
0 answers
118 views

Monkey-patch plugin function

Is it possible to override an autoloaded plugin-function? I want to customize an airline-internal function just like this: diff --git a/autoload/airline/extensions/default.vim b/autoload/airline/...
der_flo's user avatar
  • 21
2 votes
0 answers
53 views

How to make YouCompleteMe work with cgo

In C, YouCompleteMe could autocomplte the function if I include the header file in code: I want it work like C, when I write Go code and include the C header file in cgo: So, how should I config ...
solomon_wzs's user avatar
2 votes
0 answers
82 views

Is it possible to develop decent plugins using Ruby?

I've been playing around trying to learn VimL and to do so, I'm toying with the Evernote Ruby SDK to do basic stuff. Is there a reference manual where to find a full Ruby bindings guide or something ...
Stoic Alchemist's user avatar
2 votes
0 answers
149 views

Implement "Press any key to close" in neovim terminal buffer

When running shell commands in a terminal buffer I often just want to examine the output, and then close the buffer. Let's say I call :term ls. How would I implement a simple "Press any key to close" ...
sieste's user avatar
  • 123
2 votes
0 answers
2k views

Calling vimscript functions from inside functions?

Could somebody explain me what happens here? I want to get my plugin update the airline at the MpcAdd function call. Yet, no calls seem to work from inside the function. The MpcAdd function call is ...
Rápli András's user avatar
2 votes
0 answers
145 views

vim cpp syntax contained region

I define four key words and two regions in vim scripts syn keyword KeywordA A nextgroup=rangeA skipwhite skipnl skipempty syn keyword KeywordB B contained containedin=rangeA nextgroup=rangeB ...
Arolia's user avatar
  • 141
2 votes
0 answers
90 views

custom tab completion with whitespaces

I'm trying to write a custom completion function for filenames and sometimes they can have whitespaces. So far I've been using this command! -nargs=1 -complete=customlist,MyComplete MyFunc execute ...
DaftWooly's user avatar
  • 121
2 votes
0 answers
292 views

How can I view all of the vimscript run by a command? (neovim)

I want something similar to what I get when I enter debug mode and type "step", then enter and up, enter and up, ten thousand times... But without having to do all that work, allows it to be done ...
phicr's user avatar
  • 693
2 votes
0 answers
212 views

Autocorrect spelling mistakes using Google?

I found an automation script written in AutoHotKey very inspiring. It relies on the search result from Google to correct the wrongly spelled words. The script: ; Ctrl+Alt+c autocorrect selected text ...
llinfeng's user avatar
  • 352
2 votes
0 answers
145 views

Avoid ending up in mode from onoremap

When I'm on an empty line and press cfa, nothing happens, whereas on a line with an a, it will go into insert mode. E.g. I have this: onoremap <silent> a :normal! Favfz Whether I am on an ...
hgiesel's user avatar
  • 1,934
2 votes
0 answers
181 views

How to compare two positions in a buffer?

Suppose i've got two different positions in a buffer returned by getpos() function: p1 = getpos("v") p2 = getpos(".") Is there a simple or elegant way to find out which one is before the other in ...
Alexey's user avatar
  • 521
2 votes
0 answers
93 views

How do I resolve Error E108: No such variable: "b:eclim_tab_id" in textfmt plugin v3.0?

I manually installed the txtfmt plugin (Brett Stahlman's The Vim Highlighter) ver 3.0. After trying to run :MakeTestPage, I get the following error: Error detected while processing function <SNR&...
Annis Monadjem's user avatar
2 votes
0 answers
151 views

escaping a character included in a conceal command vimscript

I'm playing with conceal in help files to highlight / colour specific text strings which was working fine until I added the :print: example below. Using this concealed all the : as expected so I ...
Steve's user avatar
  • 276
2 votes
0 answers
47 views

How to implement a check-in test for omni completion script?

I've been working in an omni-completion script for Vim that is becoming more and more complex. At this point I'm interested in implementing some kind of check-in regression test for the script. Any ...
Vitor's user avatar
  • 1,732
1 vote
0 answers
29 views

How can I handle whitespace of the path with nvim_buf_get_name?

I am using Neovim and I use this code to get the full path of the current file. local currnetPath=vim.api.nvim_buf_get_name(0) I want to use this variable for opening the current HTML file, so I need ...
mohamadi_arch's user avatar
1 vote
1 answer
98 views

How Do I Turn a String into URL Encoded String?

I'm trying to turn a JSON format string into parsable URL encoded string. Here's my process: " Read the contents of the file separated into lines let lines = join(getline(1, '$'), '\n') " ...
Samuel Bacay's user avatar
1 vote
1 answer
277 views

How to pass an argument for glob in fzf.vim Rg to support searching in specific files?

I am using fzf.vim plugin with ripgrep. Fzf comes with the command :RG and :Rgright out of the box that lets me to search for keywords in files. However, often I need to search for keywords in ...
Iggy's user avatar
  • 175
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
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