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.

Filter by
Sorted by
Tagged with
0
votes
1answer
14 views

How to replace selected text T with some function(T), using a keyboard shortcut?

I want to annotate words /sentences for a "named entity recognition" purpose; inside a text file, I want to annotating words or sentences with this format [pattern](label): [a word where the ...
0
votes
0answers
35 views

Vim editor entities tagging/annotation tool

I'm looking for a word/sentence annotation tool/plugin to be used INSIDE vim editor. Specifically I'm looking for a cli tool NER (named entity) tagging. Any idea/suggestion/tip? By example, I would ...
0
votes
0answers
17 views

in vimscript how to write the code a CTRL-C to be executed

I run a sourced vimscript like this: exec 'g#' . WE_var_searchmode . ' ' . WE_var_pattertosearch . '#exec " A | B | C | make_CTRL-C | ... | LAST " ' The outer execute '...' is needed to ...
0
votes
1answer
20 views

Is there a way for Vim to re-source all the startup files without quitting and re-starting?

I write a lot of Vim plugins. When I make an edit to a plugin's .vim file, I'll often just quit Vim and restart it to test it. In some cases, I would like to avoid quitting and restarting Vim. I ...
0
votes
0answers
32 views

vim problem when in "try" ... "catch" an "if" is between

When a vim script is to be watched for errors and interrupts, try is put somewhere near the beginning and catch after a long sequence of code. In this sequence of code it is very probable to have some ...
0
votes
1answer
21 views

How can I execute a piece of selected lines on terminal with a mapped command?

I've created the following script on my vimrc file: function! ExecuteOnTerminal() if (&ft=='javascript') :%terminal node elseif (&ft=='sh') :%terminal bash elseif (...
0
votes
1answer
19 views

how to install this? NerdTree visual selection

I've been trying to install this package called nerdTree-visual-selection. It is a package that 'defines key mappings that will work on nodes contained in a Visual selection in NERDTree'. It was weird ...
0
votes
1answer
25 views

How to (1) get depth of execute-nesting and (2) interrupt the global command?

From a sourced file I am running my vim script. The aim of the script is to run :global. I am searching for \\%(pattern1.*/)\@<!pattern2 The patterns are variables, so I use execute; for the work ...
2
votes
1answer
51 views

How to async run vimscript system calls

I have a vimscript function which uses a combination of vimscript functions and also some calls to :call system(). The vimscript and the system() calls can be 5-10 seconds slow, during which time, Vim ...
1
vote
1answer
20 views

How to glob the buffer-list?

Having a command: command! -nargs=+ Foo call s:my_fun(<f-args>) How can I get a glob-match when user say: Foo *met*.c ?
0
votes
1answer
23 views

Executing settings based on directory during startup

I am trying to execute some custom settings based on the directory on startup. For this I am trying: autocmd VimEnter /path/to/dir/* :source /custom.vim When I now execute: cd /path/to/dir vim I ...
0
votes
0answers
13 views

Handling softlink directories in Windows

I'll edit the title as soon as I think of a way to succinctly word my question. I have the following for my statusline: set stl=%{expand('%:~:.') It gets the current filename's fullpath and truncate ...
0
votes
0answers
38 views

Vim :redir + :execute prepends the executed command and blank lines to the output

I have the following function and command, which is supposed to save the output of a command to a scratch buffer: function! ScratchCapture(cmd) abort echo a:cmd " Run and capture output in l:...
0
votes
0answers
28 views

Inserting Visual Blank Space Without Modifying Buffer

Question In vim 8, is it possible to insert visually blank regions into a window without modifying the underlying buffer? Backstory I am writing a plugin (my first!) to assist me in updating patch ...
1
vote
0answers
44 views

error: there was a problem with the editor "vi" -- while trying to change deployment file

Facing this error error: there was a problem with the editor "vi" when trying to change a deployment file in the Kubernetes cluster (AKS) kubectl edit deploy xxxxx -o yaml upon exiting the ...
0
votes
0answers
18 views

Shell filters to a part of a line [duplicate]

In Vim, we can visually select text and filter it using (pipe it into) shell commands. The output of the command then replace the lines selected. But this applies to the whole line. For example, ...
0
votes
0answers
45 views

Is it possible to execute a vimscript from the command line?

I don't know very well how to work with vimscript... Because of that, I'd like to find a way where I can easily test what I'm trying to accomplish on my vimrc file, with some prints like on other ...
0
votes
3answers
42 views

List/navigate specific syntax elements in a file?

I would like to jump through specific syntax elements in a file. For example, quickly navigate to the next string element. In a .vim file strings are defined as vimString syntax elements. For ...
-1
votes
1answer
30 views

What's the meaning of `^=` in vimscript?

What's the meaning of ^= in the following line? set runtimepath^=~/.vim This should be a simple one but I've searched and found nothing. Thanks for your help.
0
votes
0answers
13 views

Mouse navigation not working in VIM

I started using VIM today and I found out that we could use the mouse pointer to go to a line in vim using set mouse=a But unfortunately, it is not working here is the config file https://pastebin.com/...
1
vote
0answers
21 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 ...
0
votes
1answer
29 views

Using a vim syntax file, I would like some Keywords, such as ??, to be colored

I have been trying to get through the syntax file documentation on vim help, https://vimhelp.org/syntax.txt.html#%3Asyn-files but it's quite the read and I figured someone here may know how to go ...
1
vote
1answer
53 views

Write a custom linter for ale to consume the output of command line utility

I am trying to write an ale linter for the norminette program. How can I make it work ? It's a program that checks if C source code files follow the coding norm of the 42 school network and it would ...
0
votes
1answer
34 views

How do I send the output of an :r! command to another Vim command?

I would like to edit some text before dumping it into the Vim buffer. I retrieve the content of a webpage with :r! w3m -dump someurl.com. I would like to delete everything in the returned text from ...
1
vote
1answer
40 views

choose template option for newfiles in vim

I have different templates in this directory ~/Documents/Library/ like: Template.cpp, normal.cpp, advanced.cpp normally i use this autocmd BufNewFile *.cpp 0r ~/Documents/Library/Template.cpp I want ...
0
votes
1answer
19 views

Spaces in mappings: where to put them and where not?

The question is actually rather short, don't be afraid. :-) I'm Russian, and so to tweak Vim in a way it will understand its commands even if a Russian language is currently active, I have the ...
0
votes
1answer
19 views

difference between `wildignore=` and `wildignore+=` in vim

I have seen many vimrc's which have wildignore+= and i don't know what it refers compared to wildignore= others like: clipboard= and clipboard+= some configs have also like clipboard-= Can anyone ...
0
votes
2answers
39 views

how to make a word turn into certain commands in vim command line?

I want :cup in vim command line to turn into :tabdo call MapRunCmd()<CR> Hope that somebody can help me out PS: I've tried this nnoremap :cup :tabdo call MapRunCmd()<CR> but didn't like ...
2
votes
1answer
40 views

What is the purpose to use "==#" with empty string?

The following is from vim-sensible plugin: set incsearch " Use <C-L> to clear the highlighting of :set hlsearch. if maparg('<C-L>', 'n') ==# '' nnoremap <silent> <C-L> :...
0
votes
1answer
35 views

Need help to make a by-default `:RunWithFile` of this toggle function

related to this post, How to make a toggle function in .vimrc that toggles multiple configs of almost same type? @BLayer's code func! MapRunCmd() abort if exists("b:rwfcmd1") && ...
0
votes
1answer
55 views

How to make a toggle function in .vimrc that toggles multiple configs of almost same type?

My .vimrc code autocmd FileType cpp nnoremap <F4> :RunWithFile autocmd FileType cpp nnoremap <F4> :RunWithFile ~/Downloads/ > output.txt && cat output.txt<s-left><s-...
1
vote
1answer
73 views

Explore command not working in Terminal normal mode

In vim, I open a terminal using :term and enter the normal mode using <C-w> <N>. Then, :Explore does not open the vim's file navigation view, but creates a another split window of the ...
1
vote
1answer
58 views

silent vs. silent! - What is the difference?

This might be a silly question, or someone may say it lacks research, but I really cannot understand what does the exclamation mark after silent mean. For example, in the following function that ...
0
votes
1answer
40 views

Why vim creates an extra last line when importing a template?

My init.vim code: autocmd BufNewFile *.cpp 0r C:\Users\User\Desktop\cp\Template.cpp When i create a .cpp file, Template.cpp code is imported in that cpp file. upto this point, everything is fine. ...
0
votes
1answer
56 views

Non-interactively call a user defined vim script function and pass the buffer?

How do I non-interactively call a user defined vimscript function, and pass it the buffer? My best guess is below, but it doesn't work: echo "110511093 some dude" | vim -es ':call ...
2
votes
2answers
51 views

Create a new matching-tag-pair textobject?

Vim provides a builtin textobject t that captures a matched pair of HTML tags — so e.g. if you start with this <i>that█ <b>those</b></i>, then typing dat in normal mode leaves ...
1
vote
1answer
21 views

How to check if a dict has a specific key?

In Vimscript, how can one check whether the dictionary my_dict has the key abc? Something like this: echo 'abc' in my_dict " The above naive approach gives "E121: Undefined variable: in"...
0
votes
1answer
15 views

system(cmd) fails if cmd includes # character

I have been trying the https://github.com/ngemily/vim-vp4 plugin for integrating Perforce version control commands into Vim. The Vp4Diff command fails for me. I tracked it down to a step where a ...
0
votes
1answer
20 views

How to separate the negative and positive values from 3rd column in vim file?

I am dealing with a long data in the vim file. I want to separate the positive values and negative values in the 3rd column in separate files. Example: 1.000 3.889 4.666 4.889 2.809 -8.687 3.896 4....
0
votes
1answer
17 views

Unable to resume backgrounded Neovim-terminal-emulator-process using `kill -CONT`

So, I'm trying to find an actual solution to another question on here that doesn't really have one. However, I'm running into a problem with backgrounding/foregrounding behaviour. I need to background ...
1
vote
1answer
128 views

How can I expand a:000 list in order to pass through all varargs parameters to another function?

I have a varargs function, which I want to refactor to include a separate 'argument handling function' first, so that that becomes separately callable. I've read :help function-argument but was unable ...
0
votes
1answer
40 views
2
votes
2answers
134 views

Vim 8.2 no user defined functions

Yesterday I updated Vim to version 8.2 thru my Linux distro repositories (Fedora). And now I noticed that no user defined functions exist. They worked just yesterday, before the update. I define ...
3
votes
1answer
67 views

Inserting strings with `<plug>` inside `<cmd>`

When using <cmd>...<cr>, there are some special keys such as <plug> or <cmd> that are not allowed to be contained inside the block. Trying to execute the command will result in:...
1
vote
1answer
33 views

How to copy contents of wl-clipboard into a Vim register?

I would like to swap content between my system clipboard and a Vim register. I am missing one last piece of the puzzle, indicated below. Any thoughts? map <Leader>" :call SwapBuffer()<CR&...
2
votes
1answer
64 views

How to quickly search for today's date in a file?

Question How does one effectively find today's date in a file? The format of the date is given by GNU's date(1)'s command as: $ date '+%a %d-%m-%Y' Mon 16-08-2021 What I already tried This is how I ...
1
vote
2answers
57 views

Moving to special marks inside opfunc

I'm trying to write a opfunc which surrounds selected motion with two stars (bold in Markdown): nnoremap <localleader>b :set opfunc=BoldIt<CR>g@ function! BoldIt(type, ...) execute &...
1
vote
1answer
43 views

How I can add <C-6> to a mapping

I am trying to create a mapping that will close the current buffer and replaced by the previous buffer. I tried this noremap <silent><Leader>bd :<C-6><Bar>bd #<CR> But ...
0
votes
1answer
31 views

How to get the union/merge of dictionaries?

I'd like to combine two nested dictionaries following these rules: if value is not a dictionary, override the key in resulting dictionary if value is a dictionary, compute union of the two. Example: ...
1
vote
2answers
89 views

Is it possible to detect if shiftwidth/tabstop/etc was set in modeline

I have my own detection of the file indent settings based on the file contents. All good and works ok for my needs but... When I open a c source file of the vim itself it overrides options set by ...

1
2 3 4 5
26