vimrc

Vim: moving the cursor to a string in a source file without error messages if it doesn't exist

When I use vi to open a file *.c, I would like the cursor to move to the string "main" automatically. If there is no "main", I want the cursor to go to "void" without an error prompt. In my .vimrc I have set :autocmd BufRead *.c 1;/main but this cannot implement all my requirements. Specifically, if there exists no "main" in some ...

How to write a function or macro to send a parameter to a system call in gVim for Windows?

The useful command :r!date is not so useful in gVim for Windows (not cygwin's gVim) because Windows has its own date function which does not do what I want. so, something like :r!c:\cygwin\bin\date would be great. But that's a lot to type. And considering that I might want to call a few things this way, it would be nice to write a f...

vimrc configuration

I'm sorry if my title seems vague. I wasn't sure how to make a succinct title. I have 2 questions: 1) For tab movement in vim, when I map ctrl+pgup to ctrl+p and ctrl+pgdown to ctrl+n, it works fine moving between tabs but each time I move from a tab to different tabs and come back to said tab, the cursor moves one space to the right (...

How do I automatically open a file for edit in perforce, if writing a read-only file in vim?

This is very similar to: http://stackoverflow.com/questions/1681058/vim-auto-commands-writing-a-read-only-file Except that in addition to the solution presented there, I want vim to only ask for confirmation if the file is still read-only. In other words, if I do :w, I do not want vim to say that the file is read-only. It should autom...

Why tabs is 3 columns when I am asking it to be 2 columns

I am using macvim. Here is my settings. if I am in a JavaScript file and if put my cursor at the left most position. Now if I do tab then I move two columns. If I do the same in a ruby file then I move three columns. How do I fix that. As you can see in my vimrc I am asking everything to be 2 columns. Thanks. This is driving me craz...

Prevent vim :make from changing the current working directory?

Synopsis: When calling vim's make command, it changes the current working directory (cwd) to the directory of the current file. It then runs the makeprg from there. I want to prevent the make command from changing the cwd, and instead call the makeprg from the directory of the parent vim instance Example: I have the following standa...

getting started with vim scripting with perl

I'd like to create a vim function/command to insert an XSD style timestamp. Currently, I use the following in my vimrc file: nmap <F5> a<C-R>=strftime("%Y-%m-%dT%H:%M:%S-07:00")<CR><Esc> I'd like to use the Perl code: use DateTime; use DateTime::Format::XSD; print DateTime->now(formatter => 'DateTime::Format::XSD', time_zone => 'Amer...

How do I use variables in my .vimrc?

Hi I have a small problem with "tab size" and different project, some like 2 or 4 and the Linux kernel like 8 spaces per tab. And this is not a big problem since I can just change a couple of settings in my .vimrc set tabstop=4 set shiftwidth=4 set softtabstop=4 But that is 3 lines I need to change... It would be nice to have one...

VIM: how to add search/replace command to vimrc and map to a shortcut

I have two search/replace commands that I find myself running in vim fairly often to clean up html code so I can copy/paste it online. The commands are: :%s!<!\&lt;!g :%s!>!\&gt;!g I wanted a way I could map both of these commands to be run together ... I did some searching for how to use the :map commands in vimrc, however, I can't ...

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. ...

I need to test something by changing vimrc

However already opened mvim windows do not load changed done to vimrc until I close all mvim windows and start fresh. Is there a way I can tell existing mvim windows to load new vimrc file without closing and opening all windows every time. ...

vim indenting a block of code inward and outward

I am using mvim . I am trying to map keys so that I could visually select elements then I could indent the code inward or outward. However while doing outward work after every keystroke one more line at the bottom get selected. What is the fix. " Ctrl-x - move the block of visually selected code one tab right and keep visual mode alive ...

Opening files in Vim using Fuzzy Search

I'm looking for a way to make Vim have the ability to open a file by fuzzy-searching its name. Basically, I want to be able to define a project once, and then have a shortcut which will give me a place to type a file name, and will match if any letters match up. This kind of functionality exists in most editors I've seen, but for the l...

Is it possible to apply vim configurations without restarting?

I want to edit .vimrc file from Vim and apply them without restarting Vim. Is that possible? Thank you. ...

jVi in NetBeans

Hi guys. I'm choosing what to use: Eclipse or NetBeans. NetBeans has better vim plugin - jVi, but, as I see, it doesn't work with my own ~/.vimrc file. But in eclipse and VimPlugin for it everything is perfect. So are there any ways to use my vimrc settings for NetBeans with jVi? ...

Can someone help fix my vimrc config?

set nohlsearch set ai set bg=dark set showmatch highlight SpecialKey ctermfg=DarkGray set listchars=tab:>-,trail:~ set list autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class set tabstop=4 set shiftwidth=4 set expandtab set autoindent set smartindent syntax on set listchars=tab:>- set listch...

how to write a vimrc file that (automatically) applies only to a specific folder

say that i have a project which lies in a folder called 'bin', and i want some specific vim configuration automatically loaded when i edit any file inside the project folder. how can i do that? ...

Whitespace under the cursor in vim

I recently saw this demo. My question is: how is it possible in vim to show whitespace characters under the cursor as dots (in red for example). ...

Mapping <C-Tab> in my vimrc fails in Ubuntu

I want to map ctrl-tab to :tabn, and ctrl-shift-tab to :tabp. I had it working for gVim in Windows XP, but moved it to my .vimrc in Ubuntu 9.10 and it doesn't work (vim 7.2). Here's the relevant section of my .vimrc: nmap <C-Tab> :tabn<CR> nmap <C-S-Tab> :tabp<CR> nmap <C-t> :tabnew<CR> <C-t> works fine, so mapping the ctrl key does...

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...