vimscript

How do I get the length of a regex match in vim?

If I want to get the length of each match within the parentheses in the following regex, how do I do it?: ^\(\-\+\s\)\+ I'm trying to modify the width of columns in a buffer with data that is laid out as a table. Since the first two rows of the table will look like this DESIGN_ID DESIGN_YEAR SOURCE_REFERENCE ---------- ----------- ...

dumping the source code for an anonymous function

original (update follows) I'm working with a lot of anonymous functions, ie functions declared as part of a dictionary, aka "methods". It's getting pretty painful to debug, because I can't tell what function the errors are happening in. Vim's backtraces look like this: Error detected while processing function NamedFunction..2111..210...

Vim script to compile TeX source and launch PDF only if no errors

Hi, I am switching to using Vim for for my LaTeX editing environment. I would like to be able to tex the source file from within Vim, and launch an external viewing if the compile was successful. I know about the Vim-Latex suite, but, if possible, would prefer to avoid using it: it is pretty heavy-weight, hijacks a lot of my keys, and ...

Vim: wrap text ("gq") without modifying underlined headings

Is there a way of formatting text in Vim that respects underlined headings? In Markdown, there are two ways of representing headings: #Level 1 heading ##Level 2 heading ###Level 3 heading and for level 1 & 2 only: Level 1 heading =============== Level 2 heading --------------- I am fond of the underlining style, as I think it rea...

Vim: change formatting of variables in a script

I am using vim to edit a shell script (did not use the right coding standard). I need to change all of my variables from camel-hum-notation startTime to caps-and-underscore-notation START_TIME. I do not want to change the way method names are represented. I was thinking one way to do this would be to write a function and map it to...

Adding custom highlighting for project's API function names in Vim

Hi How can I add new function names for .c and .h files to be highlighted, similar to this http://stackoverflow.com/questions/2464593/custumizing-syntax-highlighting-in-vim but much easier? (as I don't need to color words in different colors, only in the default color for keywords as defined by my the...

Is there a command in Vimscript to get the current Operating System?

What the title says. I can think of some hackish ways to do it, but is there a correct way to do this? ...

How to use Unicode characters in a vim script?

I'm trying to get vim to display my tabs as ⇥ so they cannot be mistaken for actual characters. I'd hoped the following would work: if has("multi_byte") set lcs=tab:⇥ else set lcs=tab:>- endif However, this gives me E474: Invalid argument: lcs=tab:⇥ The file is UTF-8 encoded and includes a BOM. Googling "vim encoding" or ...

Vim step-by-step: How do you line up arbitrary text by arbitrary delimiter?

Background: There are a lot of great tutorials and "tricks" pages for Vim, but one thing that is very difficult is to find specific instructions on how to do some arbitrary thing that one can easily do in one's own familiar text editor IDE. Therefore I am asking for step by step instructions on how you I would do something in Vim that I...

Vimscript: how to get the current list of user-defined functions and determine the files they are sourced from.

Hello everyone. Is there a way I can query from within Vim information about user-defined vimscript functions and script files that Vim knows about? The things I'd like to know are: Is a particular function defined? Which source file is a given function defined in? What are the vimscript files that have been sourced? Etc. ...

How can I pare down Vim's buffer list to only include active buffers

How can I pare down my buffer list to only include buffers that are currently open in a window/tab? When I've been running Vim for a long time, the list of buffers revealed by the :ls command is too large to work with. Ideally, I would like to delete all of the buffers which are not currently visible in a tab or window by running a cust...

Is there a way to click a link in Firefox and open a file in an existing VIM session?

Hi there, I know it's possible to open links in an html page (let's say, if you're using Firefox) with TextMate if the link has this format: <a href="txmt://open?url=file:///home/.../index.html.haml">View</a> But is it possible to do a similar thing with VIM? Perhaps like so: <a href="vim://open?url=file:///home/.../index.html.haml"...

tools for testing vim plugins

I'm looking for some tools for testing vim scripts. Either vim scripts that do unit/functional testing, or classes for some other library (eg Python's unittest module) that make it convenient to run vim with parameters that cause it to do some tests on its environment, and determine from the output whether or not a given test passed....

Install a vimball from the command line.

As this post points out you can install Vimballs using the normal: vim somevimball.vba :so % :q But if you want to install a from the command line how do you do it? I ran a 'man vim' and it seems like the best "from source install" option was the '-S' option so I tried to install haskellmode with it: wget 'http://projects.haskell.org...

vimscript: How to detect if specific file exists

I'm looking for an elegant way in vimscript to check if file exists in the current directory in a function. I came up with this but not sure if that's the most elegant solution (I'll be setting vim option if it exists) - is there any way of not having to do another comparison of the filename - maybe use different vim built-in function(?...

How can I map a key to execute a program, and show its output in GVim?

On my .gvimrc, I have the following line: map <f4> :!./%< On a source file, I have to press F4 and then enter, but it works correctly, shows the output, and hangs until I press enter again. If I change it for: map <f4> :!./%< <CR> It behaves shows the output, but doesn't wait until I press enter (and so the output becomes imposs...

How to use abbreviations in Vim with arguments?

In Vim, you can make it so each time you write "FF" on insert mode changes to some code by using: :iab FF for ( int i = 0 ; i < n ; i++ ) But is there any way to use this with arguments? Something like C's #defines, so if I write FF(e, 10) It becomes for ( int e = 0 ; e < 10 ; e++ ) ...

How to get a list of files that match some pattern?

How to get a list of files that match some pattern if filenames may contain \n character? Update: I want solution in pure vimscript, so that it will depend on nothing but vim. Update2: Expected output of glob function Consider the following script: :!touch /test ; mkdir /test$'\n' ; touch /test$'\n'/test :echo glob('/**/test') /test...

regex in vimscript

let test = 'a href="http://www.google.com"&gt;www.google.com&lt;/a;' in vimscript, how can i get http://www.google.com out of this using a regexp, and store it in another variable? i can't seem to find any documentation about this. thanks in advance! ...

Opening Vim and using some command in normal mode from the Terminal?

I want to be able to open Vim and automatically make some commands in normal mode (in this case, open two buffers put a mark in one line on one line, fold another line, and go to the bottom of the file). The closest thing I found would be using the -c or + command line switch, however these execute commands in Ex mode. For example, I wo...