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.

145 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
0answers
308 views

Vim-Airline TabLine not displaying with arrows

I have set up Vim-Airline, but Vim-Airline-Tabline's tab seperator is showing vertically rather than as arrows. My tabline: Expected tabline: init.vim relating to airline: let g:...
0
votes
0answers
42 views

Tool for convert multi files vimrc into single file

i try to collect my .vimrc files into single file is there anyway to generate single file using vimscript depending on source vimscript keyword or python code example of my .vimrc if isdirectory($HOME....
0
votes
0answers
58 views

inoremap doesn't work

Question summary Currently I'm writing a pull request for this vim plugin which should set commas and semicolons automatically. At the moment it looks if it should set a comma/semicolon/double point ...
0
votes
0answers
129 views

E716: Key not present in dictionary: "3"

I have this global at the top of my .vimrc: let DevEnv = { 'enabled' : 0, 'open_dirs' : 0, 'term_bufnr' : 0 } One of my .vimrc functions calls: exec 'bd! ' . g:DevEnv.term_bufnr Note that g:DevEnv....
0
votes
0answers
62 views

Print command output on terminal on vim exit

I am trying to run shellcheck upon exiting vim, however I do not get the output of the command I run. I've tested running something like touch foo instead, and I managed to see the file being created, ...
0
votes
0answers
23 views

How can I know when a real file is closed/opened from/into a visiable window?

What I'm trying to do is, when a window is closed(bw,bunload)/opened (NOT fzf, quickfix q:, buftype=nofile, etc..) resize all the other windows. This code works but I was wondering if there was a ...
0
votes
1answer
107 views

Solving issue with clang-format-vim.py saving new buffer

Summary I configured vim to call clang-format.py following the steps in the clang documentation for vim integration. But when I save a new buffer the plugin fails. I'm new to vimscript and trying to ...
0
votes
0answers
110 views

How to set statusline for specific buffer

I want to use netrwm instead of nerdtree. I have my own statusline but I don't want it to be displayed in netrw. Nerdtree had it's own option for it (let NERDTreeStatusline="") which made it ...
0
votes
1answer
113 views

regex and matchstr to get final directory and file in path

I am wondering about a regex that would enable me to get the final "directory/file" from a path. I'll explain the reason why. After using vim for 20+ years, I've finally had cause to edit &...
0
votes
0answers
124 views

vim: is possible to use mouse to move lines around

Question: Is possible to use mouse to move lines around? Requirements & Clarification I do know keyboard solutions. normal mode ddp d2j'}p dapggp alike. cmdline commands, :co. '<,'>m'a etc....
0
votes
0answers
20 views

Want template files pre-populated based on keystrokes

So based on the keystrokes I enter I want to copy the full file templates into the new file and begin editing them. This is my vimscript and I have tried a couple of different ways, from using :r :e ...
0
votes
0answers
136 views

Load scripts one after another

I have a syntax highlight, that is presumably overwritten by another script. When I execute :scriptnames, it shows ~90 scripts. The syntax script is around number 40. Is it possible to manually load ...
0
votes
0answers
51 views

How to determine including file in includeexpr

I've tried to convince vim to parse my import statements in EcmaScript modules. My goal is to use vim's native include-search (and definition search) tools without tags with vanilla EcmaScript. Though ...
0
votes
1answer
41 views

Changing cpoptions only work in commandline

So i tried to change the setting from cpoptions, so i did: set cpoptions=aABceF on the commandline, where s for the star is missing (on purpose) and it seems to work fine but only if i do it in the ...
0
votes
0answers
48 views

Execute vimscript without saving first?

From my two previous questions, I learned about using :source %, @", and other tricks to execute vimscript. But as I noticed, :source % needs the file to be saved first, furthermore, @" and ...
0
votes
0answers
78 views

How to hide a buffer thru vimscript, with buffer number or buffer name

I'm trying to make a plugin that hide and show a terminal window on the bottom of the window, but i can't find a reliable way to hide a specific buffer, i tried using hide but you only can hide by ...
0
votes
0answers
38 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:...
0
votes
0answers
59 views

How to clear and write current buffer in a function

New to vimscript. I'm writing a function that I want to be able to clear the contents of the current buffer and write this to the corresponding file (or alternatively, clear the contents of the file ...
0
votes
0answers
28 views

How can I display text differently from how it is actually stored?

I am making a custom syntax partially based on Markdown. I want to display links differently from how they are stored in the file. For example, [About me](about.md) in the file should be displayed as ...
0
votes
0answers
18 views

hlexists() for hilight group name or syntax groupname, or both?

My understanding of how hlexists() work is that it checks for groupname. I am assuming that there are two kinds of groupnames: highlight syntax Does it work not only on groupname provided by the hi ...
0
votes
1answer
117 views

How to bind these keys to prevent recursive binding in Vim?

I have been trying to do :noremap j k and :noremap k j which works but instead of going up it goes slanted up and down. I want j to move up and k to move down which is opposite in vim. I also tried :...
0
votes
0answers
15 views

redirect doesnt save error

Errors, ie python errors, appear in :messages. And yet, they are not present in the file generate by redir >> fil. I wish they would be added too. Any chance? For example, these lines aren't ...
0
votes
0answers
83 views

vimscript: Efficient way to extract portion from line of text

I have a plugin that does syntax highlighting and folding for a kind of data file. The syntax and folding are both dependent on textual values in specific places (columns) of current line of text. ...
0
votes
0answers
15 views

Trouble creating a remap that compiles the current open latex file along with one other latex file in the current directory

I am working with latex files. I want to have a normal mode remapping which compiles my current file and a latex file named main.tex (both in my current working directory). The command to compile is:...
0
votes
0answers
38 views

"Invalid expression" setting 'foldtext', what is wrong?

I am trying to set 'foldtext', but it seems I misunderstand expressions, types, etc. of Vim fundamentally. Why does the following refuse to work? set foldtext=v:folddashes."TEST" Whereas this works?...
0
votes
0answers
30 views

Lose hlsearch when using with vim-fuzzysearch

I'm using this plugin: vim-fuzzysearch. When I have long file (I need to press ctrl-f/ctrl-b to scroll) Steps to produces: 1. Turn on `hlsearch` + vim-fuzzysearch and search for a keyword 2. ...
0
votes
0answers
154 views

Send keystrokes and string to gdb terminal

I started debugging a c program inside vim with: :packadd termdebug :Termdebug with vim 8 and and gdb > 8.3 installed. In order to set a breakpoint, I would like to send the following string while ...
0
votes
0answers
56 views

Find out last used text object

I'm trying to figure out a way to make a repeatable operator insert. To do so I'm trying to make use of tpope/repeat. My idea is to set a repeatable call that repeats the last operation, repeating the ...
0
votes
0answers
84 views

Is there a SafeState equivalent in neovim?

I have the following function that I'm porting to neovim: " --------------- " Auto record visual mode " --------------- " Allows executing operators with a different syntax. " First we go to visual ...
0
votes
0answers
207 views

Is it possible to replace tildes representing empty lines with another character?

I'm writing a plugin which needs to replace the empty line tildes with with a '.' character in a single window split. Is this possible to do with Vimscript?
0
votes
0answers
36 views

Is there a particular name for when you pre-set a bunch of registers used for a specific task at hand?

For example one could have many of these for different tasks (with different values for different registers based on the task): function !RegisterTemplateTest() # Set contents of said register ...
0
votes
0answers
118 views

How to stop a function when <esc> is pressed? OR how to catch a <esc> signal in vimscript?

I have a function which calls another function that reads user input from input(). function! fun1() call fun2() endfunction function! fun2() let temp = input("Please input:") endfunction What I ...
0
votes
0answers
81 views

Can I script VIM to process a list of diffs?

I often need to keep several directories synchronized across two or three machines. I will periodically run diff -qr local/path mounted/remote/path > diff-list.txt to get a list of what is ...
0
votes
0answers
55 views

highlight link with condition file does not exist

For a wiki syntax plugin, i'd like to have two highlighting colors for links. Links already having a destination file should be green and links with no destination yet should be red. [[This file ...
0
votes
0answers
329 views

how does t_AB and t_Sb option difference in vim?

I see three sets of options for terminal colors on the vim documentation. The first set of options: t_AB set background color (ANSI) *t_AB* *'t_AB'* t_AF set foreground color (ANSI) ...
0
votes
0answers
103 views

How to pass '\v\C[pattern]' into the built-in match() VimScript function

I am attempting custom fold logic as my first VimScript. What works for me: USING VERY MAGIC (\v) and explicit CASE SENSITIVE (\C), find python comments in foo.py that begin with hash, then Roman ...
0
votes
2answers
521 views

Set cursor in quickfix on autocmd event

I need to set cursor position when opening quickfix window. I have tried autocmd BufEnter * call cursor(2, 2) It doesn't set cursor for quickfix buffer immediately after I have opened it. UPD: I am ...
0
votes
0answers
298 views

How to get the current word starting from the cursor?

In vimscript expand('<cword>') gives me the word under the cursor. How can I get the word under the cursor starting at he current cursor location (skipping the word start).
0
votes
1answer
89 views

How to get the same message and error behavior as normal `n` when calling `normal n` in function

I wrote a vimscript function that prevents the cursor from changing its location on the screen when I press n: function! s:my_n() let l:start=line("w0") let end = line("w$")...
0
votes
0answers
51 views

Is there a C++ format plugin just like Visual Studio

Coding C++ in Visual Studio, if you type ;, this line will be formatted. For example, typing a ; after int i= 1+ 2 will make this line as int i = 1 + 2;, which means that each operator is surrounded ...
0
votes
0answers
278 views

command: how to avoid "Press ENTER or type command to continue"

In my .vimrc, I set a shortcut: command Q call delete('.ycm_extra_conf.py')|call delete('.tags')|qa Now I can type :Q + [enter] to delete the two files and quit all plugins and vim. However, if I ...
0
votes
0answers
57 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
0answers
134 views

How to fold lines above the current unless it has less indentation than the current

My intention is to facilitate investigation of deeply buried code. For example, an error is thrown with message "ABC Error" and if | is where the cursor is: function handleRequest(req) { let param ...
0
votes
0answers
278 views

Window close event

For my vim plugin I try to catch an event when quickfix window is closed. I did it with BufWinLeave event. But it does not work when I have quickfix open on multiple tabs, because of 'Not when it's ...
0
votes
1answer
20 views

force close windows and last empty buffer

when i open multi windows like bellow: vim foo.txt bar.txt then , if i'm closing foo.txt by :bw then ,i'm closing bar.txt by :bw vim still open ! , i must close by :q i don't want vim open if last ...

1 2
3