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.

105 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
202 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! # ...
4
votes
0answers
185 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' '*...
3
votes
0answers
116 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 ...
3
votes
0answers
68 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 ...
3
votes
0answers
469 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 ...
3
votes
0answers
139 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 ...
2
votes
0answers
25 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 ...
2
votes
0answers
43 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 ...
2
votes
0answers
31 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 ...
2
votes
1answer
98 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 ...
2
votes
0answers
118 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: ...
2
votes
0answers
28 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 ...
2
votes
0answers
418 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 ...
2
votes
0answers
78 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?
2
votes
0answers
133 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 * ...
2
votes
0answers
82 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>...
2
votes
0answers
169 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 ...
2
votes
1answer
98 views

How do I pass a full filepath to a function in a Vim plug-in?

I have an exe program that checks for certain errors in a text file. I want to create a shortcut (like \+M) to run that exe file against the text file. My exe file's path is C:\Users\xyz\Documents\...
2
votes
0answers
41 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 ...
2
votes
0answers
73 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 ...
2
votes
0answers
67 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" ...
2
votes
0answers
73 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 ...
2
votes
0answers
67 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 ...
2
votes
0answers
142 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 ...
2
votes
0answers
154 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 ...
2
votes
0answers
108 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 ...
2
votes
0answers
76 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&...
2
votes
0answers
87 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 ...
2
votes
0answers
46 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 ...
1
vote
0answers
46 views

Local “statusline” override problem

I'm currently writing a plugin, and got stuck with this problem. My plugin opens a new window with all local options I want, but also sets the statusline option to display some useful information. Vim ...
1
vote
0answers
27 views

embed one text file in another and edit the embedded file from the file it's embedded in

Is there any existing plugin or gist somewhere that would allow you to embed one text file inside another? Ideally it'd also allow editing the embedded file from the file in which it is embedded. ...
1
vote
1answer
28 views

How to populate the preview window?

Let me give a bit of context to the question: I need to show a 'prompt' in the preview window when the user makes a selection of an item in a popup window, which is similar to the way the tern-for-...
1
vote
0answers
14 views

Design guideline for doing both autocompletion and highlighting?

For Vim, are there any design guidelines for simultaneously doing autocompletion and syntax highlighting? For the NFTABLES command line (and file) syntaxes, I see lots of recurring but partial syntax ...
1
vote
1answer
69 views

How to use TexMathZones in Markdown Syntax, for Snippets?

I am a recent and very happy Vim User. I write Mathematics and Computer Science Lecture Notes in Markdown Files, organized in a Vimwiki. I use the UltiSnips Snippet Plugin. This plugin provides me ...
1
vote
0answers
38 views

How can I send a visual selection to another file, at a line with a certain pattern?

I'd like to be able to yank a visual selection and then append it to another file at a certain line (according to a pattern). In particular (as shown in the attached screenshot), as an example i'd ...
1
vote
0answers
56 views

Provide arbitrary arguments to a snippet in UltiSnips

There are numerous occasions where you might want to have another optional argument in your snippet. Lets say I want to have a numbered list for example. Preferably I'd call something like enum3 which ...
1
vote
0answers
112 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 ...
1
vote
0answers
91 views

Neovim highlight syntax region inside typescript tagged template literal

I am having trouble fixing a syntax plugin for Vim. I've found a bug in a plugin that has not been touched in a fair amount of time. I want to address it myself but I believe I am lacking in a lot of ...
1
vote
0answers
54 views

How to use actual window size to control vim settings?

Background: neovim with tagbar plugin installed Goal: when starting nvim, if current window size is larger than 100, open tagbar and set auto-open for new buffers. Currently I use the settings below ...
1
vote
0answers
43 views

How to set the language for the user interface using vimscript?

I know I can change the language of the Vim user interface using :language en_US.UTF-8, but how can I do that using vimscript? set language=en_US.UTF-8 is invalid, and the Vim documentation says that ...
1
vote
0answers
160 views

How to flush job output in vim8?

Trying to do something with job output in exit_cb or close_cb, but it's all buffered, how to flush it. e.g.: function! s:exit_cb(job, status) echom getbufline(s:bufnr, '$') endfunction function! s:...
1
vote
0answers
66 views

Live search in temporary buffer

Faced a problem that I cannot force the buffer with results and the input field to work together, but not in turn (like in CtrlP) function! s:SearchByListFiles(all_files, query) let searched = [] ...
1
vote
0answers
121 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 ...
1
vote
0answers
103 views

Vimscript infinite loop

I'm trying to combine fzf-bibtex with UltiSnips so that I can search my bibliography file and insert a BibTeX key automatically. I use the following function from fzf-bibtex (which calls the binaries ...
1
vote
0answers
78 views

How to use visual mode in python/dyn?

Vim documentation states how to run command and normal mode commands (source): vim.command(str) python-command Executes the vim (ex-mode) command str. ...
1
vote
0answers
162 views

Where could I find documentation of python/dyn or python3/dyn?

I guess that :py command is executed by some kind of extended Python interpreter. This extended Python has vim package available: :py import vim; print(dir(vim)); print(vim.__package__, vim.__name__) ...
1
vote
0answers
67 views

Syntax highlighting - help me find the bug

I have a bug and I can't figure out the solution. Perhaps you esteemed folk can be of aid. I want to extend a syntax file (julia syntax in polyglot package). I want to include the following patterns ...
1
vote
1answer
1k views

Integrating autocomplete and snippets

I'm trying to set up an autocompletion/snippet workflow that's a bit complicated. This is stemming from needing a better workflow for latex. Right now I'm using coc.nvim and UltiSnippets but I am ...
1
vote
0answers
38 views

May I let `titlestring` tell whether I am in command-line mode?

Following from this post, I can happily "project" character n to the titlestring when Vim is in Normal-mode, and "project" character i to the titlestring when Vim is in Insert-mode. This almost ...
1
vote
0answers
79 views

Why does this autocommand works on neovim but not on vim?

I have this little augroup that contains a simple autocommand that hides the /home/devs/ text on top of nerdtree: augroup HideHOME autocmd! FileType nerdtree autocmd FileType nerdtree syntax ...