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

Questions tagged [vimscript]

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

0
votes
1answer
47 views

how can I open a terminal split in vim 8.1 without switching to it or going back to the previous split inside a vimscript

Basicly I want the following functionality: Using vims new terminal functionality, I want to be able to press a button, that opens a new terminal window, without stealing focus from the file I'm ...
0
votes
1answer
28 views

Vim: Operator pending mode remaps not working

I'm trying to build a vimscript can be used with the Dvorak Simplified Layout. I.e., given that the keys on the keyboard plugged into the computer are laid out in the Dovark Simplified Layout (and the ...
1
vote
1answer
227 views

Vim highlight all text after multiple “#”

I am trying to make text bold if it appears after a series of # hashes. This is the line in my .vimrc: au BufRead,BufNewFile *.txt hi header cterm=cyan ctermbg=red and my attempted regular ...
1
vote
1answer
419 views

ability to switch between panes has broken in tmux with vim

Ok, so I run vim inside of tmux and recently (today in fact) I suddenly can't use ctrl+hjkl to switch between panes in tmux and vim, instead it just makes the bell sound and refuses to switch. If I ...
1
vote
2answers
56 views

Import previous commands to edited command

I'm playing with zsh to change image modification time according to the 'Date/Time Original' exif attribute. For this I one command I do: PDATE=$(exiftool -p '$DateTimeOriginal' $PIC | sed 's/[: ]//...
1
vote
1answer
119 views

How can I unconditionally open any fold present, without errors, when invoking from the command-line?

So, this is similar to ‘execute command with range silently’; but that's in a mapping, and so the solution isn't applicable to what I'm trying to do. I'm using the Skim PDF-viewer with LaTeX Sync, ...
1
vote
0answers
861 views

How to setup in `~/.vimrc` a mapping for `colorscheme` to toggle `solarized` between `dark` and `light`?

How to setup in ~/.vimrc a mapping for colorscheme to toggle solarized between dark and light? Both background and colorscheme in ~/.vimrc are badly misbehaving! I have setup solarized to work on ...
-1
votes
1answer
71 views

Print tag folder in vim

I got this line in my .vimrc so that it look i parent directories untill it find a tag file. set tags=./tags; Is there a way to print the directory where vim found the tag file inside vim?
2
votes
1answer
650 views

How can I take control over jumps `Ctrl-O` and `Ctrl-I` in Vimscript?

Is there any way I could use Vimscript to go through the list of jumps Ctrl-O, Ctrl-I and to pick the previous jump buffers/positions? Any suggestion is greatly appreciated.
2
votes
3answers
156 views

Command to “go to end of last line that has content, in insert mode”

With plaintext files, when I reopen them in Vim to add content, I want to go to the end of the last line of content and get to insert mode. In ideal circumstances, a simple GA after opening the file ...
3
votes
1answer
206 views

Check if vim is compiled with +X11 in .vimrc

I have two copies of vim installed. One is installed with macvim and necessarily configured with -X11 (to work with Cocoa), while the other is configured to +X11 (used in terminal, to work with a ...
0
votes
1answer
342 views

vim find buffer by absolute path

How can I find a buffer in vimscript when I have an absolute path, and as you know vim buffer names can be relative path? Is there a function for that?
0
votes
1answer
58 views

Vim: Managing multiple wording alternatives

(After reading this, please suggest another wording for the question, because I couldn't come up with a better one) When writing and editing in Vim, whether texts for humans or texts for humans and ...
1
vote
1answer
2k 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
789 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
660 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
821 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
677 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
2k 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
283 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
624 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 ...
1
vote
1answer
129 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
107 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?
2
votes
1answer
224 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
3answers
459 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
183 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
435 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 ...
3
votes
2answers
853 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
59 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 ...
2
votes
1answer
245 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
244 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 ...