Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

4
votes
0answers
116 views

How can I watch variables when debugging Vimscript?

I would like to have another pane active when debugging a Vimscript function which would show the values of chosen local variables and function arguments dynamically. Currently I have to echo or let ...
4
votes
0answers
138 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
54 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
38 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
123 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! # ...
3
votes
0answers
120 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
39 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
45 views

How to use register in a script without side effect?

I want to create a function like this: function Foo() copy something from buffer into a register do something restore register endfunction Foo must have no side effect, every register ...
2
votes
0answers
38 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
36 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
49 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
70 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
0answers
53 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
27 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
53 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
59 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
60 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
53 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
120 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
50 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
72 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
59 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
43 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
55 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
50 views

How does vim receive f1-f4?

Literal terminal code of <f4> is: ^[OS result of set <f4> is: t_k4 <F4> ^[[14;*~ They are totally different, unlike results of f5-f12 (which are the same except the ...
1
vote
0answers
23 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
27 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
24 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
15 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
40 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
0answers
29 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
51 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 ...
1
vote
0answers
36 views

How to write to a temproary buffer in a plugin

I've started to write my first vim plugin, a simple timer. I want to be able to set a timer for an arbitrary amount of time, and have it notify me once that time has passed. I've got it all working, ...
1
vote
0answers
97 views

Toggle UltiSnips

I have this following mapping in my .vimrc " Toggle search next with blink and without blink let s:enabled = 0 function! NextMatchToggle() if s:enabled unmap <buffer> n ...
1
vote
0answers
57 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/...
1
vote
0answers
410 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 ...
1
vote
0answers
134 views

What encoding does :! use?

I'd like low-level control over exactly what bytes I send and receive from a process spawned from some vimscript. What encoding is used for communications with commands started with :!foo? Can I ...
1
vote
0answers
68 views

Trim/clear new line character from batch script at Windows7 with gvim

I want to put timestamp using Leaderts (\ts) I am using the following script timestamp.bat(Windows 7): @echo off cls echo|set /p=%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%:%time:~3,2% and the ...
1
vote
0answers
145 views

Issues with autocomplete in vim8

I have installed two vim plugins javacomplete2 and vim-emoji successfully but I'm not able to use their auto-prompting feature which enables the user to select an autocomplete suggestion without ...
1
vote
0answers
260 views

Invoking a command with a defined variable results in “undefined variable”

I'm trying to integrate opam-user-setup's output with vim-plug. I've produced the following: let s:opam_share_dir = system("opam config var share") let s:opam_share_dir = substitute(s:opam_share_dir, ...
1
vote
0answers
125 views

Backticks vs. $() in strings/variable assignment

I'm quite new to Vimscript and editing ~/.vimrc, and was tweaking this file after having installed Pathogen and Syntastic to do live syntax checking for JavaScript. However, in my current set-up, I ...
1
vote
0answers
109 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 ...
1
vote
0answers
67 views

Get rid of meta characters in vim's perldoc viewer

If I do :Perldoc version for documents longer than one page, I see output like this: ESC[1mNAMEESC[0m version - Perl extension for Version Objects ESC[1mSYNOPSISESC[0m # Parsing version strings (...
1
vote
0answers
417 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 ...
1
vote
0answers
63 views

How to avoid canceling command that waits for user input

This function function! Gf() execute "normal \<Plug>(easymotion-s2)ab" echo "done" endfunction just prints EasyMotion: Cancelled done when called, but that's not what I want. EasyMotion ...
1
vote
0answers
79 views

How to display a fake text instead of what is being written on the keyboard

Say I am writing confidential document on vim. I want another text to appear instead of the real document. Each time a key of the real confidential text is pressed, the next letter of the fake text ...
1
vote
0answers
565 views

Enter insert to insert mode from function

I want to create function that search for selection and then automatically replace selection with given text. Something like *Ncgn but with custom movement (not exactly word only). My current ...
1
vote
0answers
94 views

syntax highlighting for indentation sensitive multiline comment

I want to create syntax highlighting for indentation sensitive language that I'm designing, my question is how to highlight multiline comment that begins with #! something like this #! xxxxxxxxxxx ...
1
vote
0answers
261 views

NERDTree file extension highlighting issue: c files not highlighted

function! NERDTreeHighlightFile(extension, fg, bg) exec 'autocmd filetype nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#' exec 'autocmd filetype nerdtree highlight ' . a:...
1
vote
0answers
108 views

How to undojoin changes made from neovim remote plugin on TextChanged

I'm writing a remote neovim plugin that automatically inserts parens into the buffer based on http://shaunlebron.github.io/parinfer/ What I'm struggling to figure out is how can I get :undojoin like ...