Vim script is the scripting language incorporated into the `vim` editor. It is based on the `ex` line editor of `vi`.

learn more… | top users | synonyms

0
votes
1answer
32 views

`:cw` command in Vim: how to avoid auto jumping to first error?

In Vim, :cw command shows the quickfix window if there are any errors and let the cursor jump to the first recognized error in the quickfix window (not in the buffer where there is an error). Is there ...
0
votes
1answer
24 views

Vim inserting C style comments

:command Linecomment :normal ^i/*<ESC>$a*/<ESC> The above command is one that I came up with in order to comment out an entire line in C, normally for debugging purposes and whatnot. I ...
1
vote
1answer
32 views

Vimscript: how can I call a function but wait for user input before executing it?

In the right-hand-side of a keymapping, you can do something like :call FileTypeToggle("")<Left><Left> to start a function call at the command line, move the cursor in between the quotes, ...
1
vote
1answer
44 views

Movement command inside vim functions

I want to display the C function to which current line belongs. I don't want to use any plugin because I work on multiple operating systems with different machine capabilities and configurations. I ...
6
votes
4answers
188 views

Vim Visual mode: Select current block under cursor

Considering we have the current data: ID NAME AGE 1 Joan 29 2 Peterson 16 3 Hunt 47 4 Wenche 12 5 Kennedy 29 6 Lottie ...
0
votes
1answer
161 views

Vimscript: Error while checking for substring

I am currently trying to tie together a function to do something depending on current file path, triggered whenever I change the current buffer with autocmd BufEnter In my .vimrc autocmd BufEnter * ...
0
votes
1answer
46 views

How do I highlight the beginning of the block in vim?

My current vim config (YADR) shows the beginning bracket highlighted (only) when I am on the ending one and vice versa. Is there a way to get the same functionality for block beginning and endings, ...
1
vote
1answer
62 views

Vim region with keywords in syntax patterns

I need to create a custom vim region with determines classes and structs. The code, for example, syn region myCxxClass start="\(class\|struct\)\_[ \t]\+" end="}[^;]*;" transparent The patterns for ...
0
votes
1answer
39 views

VIM: How to check whether the current script is running in a macro?

In a number of cases I have some vim script that I only want to execute when it is not being run in a macro. For example, in some cases I blink the cursor to remind myself where it is now (which is ...
2
votes
2answers
46 views

Vim: How do you get the change list in script?

I know that you can print the changelist by running :changes. Is there a way to get this information in vimscript? Even by parsing the print somehow?
1
vote
1answer
81 views

Vim Script: Is it possible to make a custom motion non-repeatable?

I'm trying to write a custom yank function but am unable to figure out how to make it non-repeatable (like the normal yank). I have something similar to the following: function! s:YankMotion(type) ...
0
votes
2answers
91 views

Vim: How do you highlight a search pattern from script?

I would not have thought that this would be hard to do, but it's not working. What I'm trying to do is enable the search highlight from script. I've tried the following: function! g:TestFunc() ...
0
votes
1answer
54 views

write and read from command line

How I can write something to vim command line and then read some input from it to plugin? For example, I want to write choose "Choose search patter (1, 2, ... 0):". Then user presses "2", the plugin ...
1
vote
2answers
65 views

How to conditionally handle a vim remap?

This is related to/a continuation of How do I replace-paste yanked text in vim without yanking the deleted lines? In summary, vnoremap p "_dP is used to paste over visually selected text without ...
1
vote
1answer
111 views

Vim Script: Is it possible to refer to script-local variables in mappings?

I know that you can refer to script-local functions using <SID> but what about script-local variables? I tried the following, and hitting <c-space> fails: let s:testVar = "foo" function! ...
2
votes
3answers
37 views

VIM: Is it possible to add custom behavior when using /c with the substitute command?

There's been a few cases where it would be convenient to hook into the search and replace behavior for certain things. For example, I have the following mapping in my vimrc: nnoremap n nzzzv Which ...
0
votes
1answer
69 views

Vim: print lines from hidden buffers

I'd like echo line from a hidden buffer without moving my cursor. Something like this: :redir! > /tmp/myfile :1,$print 3 :redir end (I want to inspect hidden buffers without changing the window ...
1
vote
1answer
74 views

Testing vimscript

I'm hacking on a test framework for vimscript (an exercise in futility, I know; humor me). Some vim plugins make calls out to the shell (with the system() function or the ! command). I want the test ...