Stack Exchange Network

Stack Exchange network consists of 174 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
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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

0
votes
0answers
22 views

How can I prevent <CR> from moving the cursor downward? [duplicate]

In the vim help doc, it says: *CTRL-M* *<CR>* [count] lines downward, on the first non-blank character |linewise|. That is, in the normal mode, <CR> has the same ...
0
votes
0answers
25 views

how to write a self-contained color scheme

I'm making a simple colorscheme based on one I found on the vim website. https://www.vim.org/scripts/script.php?script_id=854 I'd like it to be declarative in the sense that the colorscheme is ...
1
vote
0answers
39 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/...
0
votes
1answer
25 views

Match pattern and highlight it in modeline for a specific filetype

I need to match Issue in .conf filetype and highlight it with custom color but set in mode line instead of a fix in syntax/conf.vim file. The use-case is for each kind of document I need to highlight ...
0
votes
1answer
30 views

Statusline – update variables on file change

I'm currently learning Vimscript, but I'm stuck at a particular problem. I'm creating a statusline which shows the full path (~) of the file currently displayed in the buffer. Instead of just using %...
0
votes
1answer
29 views

Vim multi-line substitute/insert once on selected text

I tried to make a function function! WrapSelect (front, back) "puts characters around the selected text. execute '''<, ''>s/\%V\(\_.*\)\%V\(\_.\)/'.a:front.'\1\2'.a:back.'/' nohl ...
2
votes
1answer
29 views

Can't echo messages from inside async functions

CASE 1: Have your autocmd command be setup like this: autocmd User ALELintPost call SayHello() " ALELintPost is async And your SayHello function set up like this function! SayHello() abort ...
1
vote
1answer
25 views

how to know if the current file in the buffer is a (.)dotfile using vimscript?

I changed vim backup directory to be stored on .backup folder in my dotfiles local repo set undodir=$HOME/.dotfiles/backup//. it works well as expected but i want to separate actual dotfiles ...
0
votes
1answer
30 views

How to apply a custom highlight file?

I'm playing with Vim highlight, so I made the following (syntax.vim): hi Comment ctermfg=DarkGray hi LineNR ctermfg=DarkGray hi CursorLineNR ctermfg=Red hi String ctermfg=Gray hi PreProc ctermfg=...
6
votes
2answers
1k views

How do I check if Vim is currently recording a macro?

Is there a way to programmatically check if Vim is currently in the recording mode triggered by q?
0
votes
1answer
31 views

Do nothing in :windo if condition does not apply

Consider following autocommand if exists('##OptionSet') augroup update_netrw_window autocmd! autocmd OptionSet wildignore \ let currwin=winnr() \ | windo ...
0
votes
1answer
18 views

How to insert special keys (like <return>, <m-r>) into macro registers with script?

I tried let @q = '<return>' and it obviously won't work
0
votes
0answers
12 views

Is it possible to set up vim to autocomplete from a file in command mode

I have the following function: function s:Test() { let l:build_dir = $HOME.'/path/to/repo/.build' let l:node_modules = l:build_dir.'/node_modules' let l:bin_dir = l:node_modules.'/.bin' ...
-1
votes
0answers
40 views

Highlight value of a vimL variable

A function in vimrc that contains expansionString variable: let l:expansionString = repeat(' ', l:space) How can I highlight this string of spaces contained in expansionString? This is whole ...
0
votes
1answer
24 views

Open and Close Syntastic window with one mapping

I have :SyntasticCheck mapped to F8 in my .vimrc. map <F8> :SyntasticCheck<CR> This open the Syntastic window on a split. I would like to close it with the same mapping. Closing is done ...
0
votes
0answers
26 views

Is there anyway to look at the implementation of default commnads in vim

Talking about the default vim commands, I imagine that most basic commands are implemented in C++, but some are simply vimscript functions that use other commands. For example, ci" might be using T"...
1
vote
1answer
33 views

Show external command output in preview window

Lets say I have the following cmake file (with | being the cursor). cmake_minimum_required(3.2) project(myapp) add_exe|cutable(myapp main.cpp) Now if I go to terminal and consult cmake documentation ...
0
votes
0answers
20 views

In Vim 8.0, how to jump to virtual column in a script?

I used to be able to use cursor(lnum, 1, vcol) to jump to line lnum and virtual column vcol. For some reason, now, in Vim 8.0, this no longer works; the cursor always jumps to the start of the line. ...
1
vote
2answers
62 views

How to check if a shell command exists

I'm now using silent! let l:status = system(l:command . ' > /dev/null') if match(l:status, '\cunknown') != -1 || match(l:status, '\cnot') != -1 echo 'command not found' return 0`enter ...
0
votes
0answers
24 views

Change color of character covered by cursor

I'm using xfce4-terminal and the cursor is green, which means that green text behind the cursor is not visible or is hard to see. Is there a way to force the etext behind the cursor to be some ...
0
votes
0answers
18 views

Make viminfo file marks [0-9] only have 1 mark per file?

I plan to use the ~/.viminfo file marks (the ones that record the ten most recent lines and files) with fuzzy searching via grep so I don't have to type vim /full/path/that/is/very/nested/to/certain/...
0
votes
0answers
11 views

`vim.eval('a:items')` fails if 'a:items' contain `BOM HEADERs`

I am using a pluging ctrlp-py-matcher, which is using the python interface to vim. My VIM is compiled with python3 support VIM - Vi IMproved 8.1 (2018 May 17, compiled Jul 1 2018 10:45:10) Included ...
0
votes
1answer
60 views

What does g'\“” mean?

Also, how can I go about finding out what a sequence means? Lets say I see a command au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif and I ...
0
votes
2answers
40 views

String comparison not working as expected!

So I want to figure out the Operating System and execute a piece of code based on the operating system in my .vimrc. However, I'm not able to understand where I'm going wrong. let operating_system = ...
1
vote
2answers
62 views

Vim autocommand based on username - print message

I have a function in my bashrc that checks if a file is writable with [ -w "$1" ]. If it is, I open it with vim normally. If it's not, I open with sudo via sudo env HOME="$HOME" vim -u ~/.vimrc "$1" ...
0
votes
1answer
30 views

How to use a value stored in a variable in the command mode?

Consider the following function function! AbbreviationsOpen() "go to the first word of the last line normal G "store the word in the register named a let @a = expand('<cword>') ...
1
vote
1answer
137 views

How to print an option's value to standard output?

I'd like to know if a file uses LF or CRLF line endings. I'm on Windows with vim installed. I don't want to convert the files, just know which line endings they use. I know I can get the file format (...
1
vote
1answer
49 views

Toggle comments

I'm trying to cerate a function who toggle a block of code into comments. I did this: " Commenting blocks of code. filetype on augroup commentgroup autocmd FileType c,cpp,java,scala let b:...
0
votes
1answer
42 views

VimL functions to differentiate between File Exists and File Readable

Because on Linux, there is possible that file exists but is not readable by the user (I rather don't think it is feasible on Windows, but...), I seek for VimL functions to differentiate between those ...
0
votes
2answers
75 views

Operate on a visual selection by looping through the lines

I'm looking for an approach, in Vimscript, to operate on the text lines of a buffer by looping through lines of a visual selection. Specifically, my goal is very simple: I have a (vertical) list of ...
0
votes
1answer
30 views

How to invoke mapped `i_CTRL-W` in function

First I will describe what I am trying to achieve: In general I use set iskeyword+=- as I see this more usable (one should always put spaces around operators when needed). This is quite helpful, but ...
1
vote
1answer
24 views

Filter list of jobs (started with job_start()) by status

I have built a list containing the "job" object as returned by job_start. The code populating the list is: let g:sc_instances = get(g:, 'sc_instances', []) let l:job = job_start('my command and args')...
1
vote
1answer
40 views

Get <Leader> value as <Space> and not ' '

Given that I defined let mapleader="\<Space>", I would like to get in the vimscript the value of the leader as <Space> and not as ' '. The latter may be obtained by using get(g:,"mapleader"...
0
votes
0answers
38 views

Any alternative to vimdoc to automatically generate help file from plugin code?

To my understanding, automation of document generation can greatly simplify the maintenance of a plugin as it allows you to keep your code and its documents together and renders the desired formats ...
2
votes
0answers
27 views

How to pass a full filepath to a function in a Vim plug

This is what I am trying to do: I have a .exe program that checks for certain errors in a text file. I want to create a shortcut (like \+M) to run the .exe file against the text file. My .exe file's ...
1
vote
2answers
41 views

How to get all/global match results for a string?

With vim script I can do let found = matchstr("abbaba", 'a') and get back "a" as a result. How would I matchstr to get back a list of all matches for the string? found == ["a", "a", "a"] as in g/a/
2
votes
1answer
34 views

How to determine the bit-width of the Number type in Vimscript?

I want to figure out the bit-width of the built-in Number (integer actually) of Vimscript . In particular, I want to tell whether a 32-bit or 64-bit integer is in use. Currently I test whether the ...
1
vote
1answer
22 views

jobsend sends no data even though return code is 1?

So I am trying to send some json text to a python script with jobsend in neovim like this: let l:json_msg = json_encode(a:msg) call jobsend(s:vimwatcher_job, l:json_msg) If i echo l:json_msg I can ...
5
votes
1answer
55 views

Can I block vim from saving a file that isn't validated using an outside tool?

I'm trying to find out if it's possible to make the write ":w" command perform a forced validation for certain file types. My use case is that I want to prevent small typos and idention errors in ...
2
votes
1answer
44 views

VimScript “unknown function” on a lot of functions

So I have been writing a vim extension but it simply does not make sense to me. I am using nvim and clearly see the function chansend in the documentation yet I get "Unknown function: chansend" when ...
2
votes
1answer
47 views

Convert a search and replace to a function

Given this search and replace expression, which works fine on one or multiple visually selected lines: :'<,'>s/\v.{-}(`.{-}`).{-}(\\'.{-}\\').*/$this->execSQL('DELETE FROM \1 WHERE id = \2;')...
1
vote
1answer
44 views

BufNewFile doesn't work from ftplugin

I have below autocmd in my cobol.vim ftplugin file in ~/.vim/ftplugin/ augroup cobmods autocmd! autocmd BufNewFile * call s:CleanStart() augroup END This doesn't work when I open a file ...
2
votes
1answer
41 views

Is loadview conflicted with readonly mode?

When i used following code to keep my folder view, it seemed that vim -R and view don't work at all (Only [readonly] was shown but it didn't work at all). Is there any misunderstanding about it? " ...
2
votes
0answers
22 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 ...
0
votes
1answer
57 views

Call vimscript function on first keypress

Is there a way to call arbitrary vimscript functions when the first keypress is made by the user? I am looking to lazily start-up plug-in when the user starts using vim. This is to save resources ...
1
vote
1answer
28 views

How can I determine if *any* window in the current tabpage is in diff-mode?

So, I found this useful answer about iterating buffers; but due to the tabpage-specific duality of windows in Vim, I failed at adapting it to my needs. Thus: how can I construct a boolean expression, ...
0
votes
1answer
35 views

Command Ordering

I made a user command called Type and would like it to appear first in the list of available commands when I type :t and then hit tab. Currently, the first command is TOhtml, which I've never used. ...
2
votes
0answers
32 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
2answers
49 views

Use current filename register in bash command ran from VIM

I'm making a command that runs tests and opens coverage report for the currently opened file. nnoremap cov :!vendor/phpunit/phpunit/phpunit --coverage-html \ /tmp/coverage/ test/ && google-...
2
votes
1answer
37 views

Execution of nnoremap takes significant time

I am developing a vim plugin and I have set a default mapping this way. if !hasmapto('<Plug>DumpDebugString') nmap <unique> <Leader>ds <Plug>DumpDebugString nmap <...