autocmd

Vim: Combining autocmd?

I need to do the logical-and of two autocmd events in vim. Basically, the command has to run on an InsertLeave when the FileType is tex. It seems like this should work (in a .vimrc): autocmd FileType tex :autocmd InsertLeave :w But it doesn't. The nested option doesn't seem to help either, even though the manual indicates it should. ...

Call a function in Vim’s `autocmd` command

I want to use the expand function in an autocmd. In particular, I am adapting a tip by Paul Biggar and I wanted to use the following auto command in my .gvimrc: autocmd FileType tex set makeprg=rubber-info\ expand("%:t:r").log – Which of course doesn’t work. So what I actually want this to mean is that upon opening a tex file, the mak...

Vim autocmd based on file contents

I'm trying to set up Vim to detect when a .tex file contains the command '\usepackage{sagemath}', and run a command accordingly. I've gotten to :au BufReadPost,BufWritePost *.tex TTarget sagepdf but that will fire for all .tex files, which isn't what I want. ...

vim + c++: insert a uuid in a guard clause

I'm trying to automate file comment headers. I'm stuck trying to figure out how to insert the result of the uuidgen command into my header using vim's autocmd. Inside the header, the placeholder text is present, like this: #ifndef _UUID_ #define _UUID_ // Code goes here! #endif // _UUID_ The autocmd line to populate _UUID_ in .vimr...

Run the CommandTFlush command when a new file is written

Hi, I'm trying to make Vim run the command 'CommandTFlush' whenever a new file is writte. For those not using the Command-T plugin, the 'CommandTFlush' command is used to rebuild an index of files in the current directory. What I want to do is run the command after the file is written to disk, so that CommandTFlush will find the file ...

Insert vim variables into text for comment shortcut.

I have a simple goal: Map Ctrl-C, a command I don't think I've ever used to kill vim, to automatically insert at the beginning of a line the correct character(s) to comment out that line according to the file's filetype. I figured I could use an autocommand the recognize the file type and set a vim variable to the correct comment charac...

Vim: Use shorter textwidth in comments and docstrings

From the mighty PEP 8: [P]lease limit all lines to a maximum of 79 characters. For flowing long blocks of text (docstrings or comments), limiting the length to 72 characters is recommended. When editing Python code in Vim, I set my textwidth to 79, and Vim automatically wraps long lines of Python code for me when I hit the charact...