vim

Smart search/replace in Vim

I have a file with the following expressions: something[0] Where instead of 0 there could be different numbers. I want to replace all these occurances with somethingElse0 Where the number should be the same as in the expression I replaced. How do I do that? ...

Ruby refactoring in VIM

Hi, I'm a big fan of Resharper in visual studio. It has some awesome refactoring tools, similar to what you get in Ecplipse for Java. Is there anything like this for Ruby? Better yet, is there a plugin or something into VIM that does refactoring for Ruby code like renaming all instances of a method or variable, renaming classes sitew...

Using vim, how do you quickly refresh a web page you're working on?

I've been using VIM for a few weeks now while messing with various web languages and I'm really enjoying it. I find it cumbersome having to tab or click into my browser and refresh the page to see the effect of a code change. It's even more annoying as I'm using Virtual Box and I tend to be working from PDF files on the host system so I...

Checking whether some object has been already tested

I have a script that is intended to check whether some value (e.g. option or function argument) matches some model. I want my script to be able to check recursive data structures. So the question is: is there more efficient way then iterating over some list that contains references to already checked Lists and Dictionaries. Example code:...

Substitute the n-th occurrence of a word in vim

I saw other questions dealing with the finding the n-th occurrence of a word/pattern, but I couldn't find how you would actually substitute the n-th occurrence of a pattern in vim. There's the obvious way of hard coding all the occurrences like :s/.*\(word\).*\(word\).*\(word\).*/.*\1.*\2.*newWord.*/g Is there a better way of doing ...

How to change the color of the selected code (Vim scheme)?

I can't figure out how to change the color of the selected code (with cursor, either with Visual mode or with the mouse). I think right now the bg is white with black fg. Any suggestions? hi CursorLine guibg=#DDDDDD gui=none hi CursorColumn guibg=#EEEEEE gui=none hi MatchParen guifg=#f6f3e8 guibg=#857b6f gui=none hi Pmenu guif...

Getting the linux error code from make in Vim

I'm trying to get the "0 of success, nonzero if error" return code from make in Vim. Specifically, I am on Ubuntu and using v:shell_error does not work. After digging around and looking at this question, it seems to be because of my shellpipe setting, which is shellpipe=2>&1| tee The tee pipes the make output back into vim. The shel...

How do you open all files in a folder in VIM?

Suppose you'd like to open all the files in your checkout folder under the /trunk subdirectory. Assume the files are called first.c second.r third.cpp. How can you open all the files into vim with a single command. The obvious answer is the following $ vim first.c second.r third.cpp But can you do this more simply? ...

vim remapping the hjkl

I am trying to map the letter hjkl to jkl; in my .vimrc file so that i can have my fingers the way they always are on the keyboard, while writing in vim. the problem is that as i map k to l, it jumps into the l to ;. so k becomes the same as ;. the same off course happens to all of them. so all the keys become one because they copy thr...

Syntax highlight for Sass is not working in Vim.

I just downloaded a Vim plugin for Sass syntax highlight. The instructions say: install details put it into syntax directory and add sass filetype au! BufRead,BufNewFile *.sass setfiletype sass in your filetype.vim I already placed sass.vim in vimfiles/syntax/ (using windows). And created a filetype.vim file with ...

Possible to highlight matching quotes in vim?

With the syntax highlighting in vim, I get the handy feature where the matching paren or bracket will be highlighted when I put the cursor over it. Is it possible to do the same thing for quotes? ...

Syntax highlighting for regular expressions in Vim

Whenever I look at regular expressions of any complexity, my eyes start to water. Is there any existing solution for giving different colors to the different kinds of symbols in a regex expression? Ideally I'd like different highlighting for literal characters, escape sequences, class codes, anchors, modifiers, lookaheads, etc. Obviousl...

Vim project plugin \R not refreshing new directories created

I'm using the vim project plugin to manage a project, and whenever a new file goes in I need to use \R to refresh the project tree. This is fine, but I recently created a new directory in the tree, and \R doesn't update it and put it into the project. What am I doing wrong? ...

Enabling --watch in LESS (Less CSS) makes Vim display read-only warning in the current .less file.

Everytime I enable --watch: lessc style.less --watch Vim displays the following message every time I try to save something in the style.less file: E505 "...style.less is read-only" (add ! to override) So everytime I want to save the file I have to type :w! Any suggestions to eliminate the read-only? ...

Is there any easy way to toggle "do/end" and "{}" in ruby in Vim?

Is there any easy way to toggle "do/end" and "{}" in ruby in Vim? (TextMate does this with ^{.) ...

What are the advantages of using vim to program Ruby (over Notepad++)? (other languages, too, but specifically Ruby)

I've been using Notepad++ for a while; in fact, I've even started using Launchy for that "load this resource into the editor right now" functionality that many fuller IDE's like Eclipse has. It has syntax highlighting, split window view, code collapsing, parentheses (and other delimiter) paring, automatic indent, block commenting. Howe...

Vim will copy the text when I delete it, but how can I disable it?

I don't like automatic copy the deleted text when delete in Vim, how to disable it? ...

What's the difference between :update and :w in Vim?

I realized that in gvim Control+S as the :update command. I always save using Ctrl+S, so I assume that :update is another way of saying "refresh the changes." Is :update basically the same as write :w? Will I have problems if I replace :update for :w!? edit: I wanted to change :update to :w! becauase I have a file that says "ready-only...

How to fold long docstrings in python source code in VIM?

Hi, Does anybody know of a method, or perhaps a plug-in, that will automatically fold long docstrings in python? I have docstrings in my code that span several pages, so it is troublesome to keep paging through them. The other tricky part is that there is embedded python testing code in the docstrings, so that might make parsing the...

What's the use of the exclamation mark ('!') in Vim's command line?

Basically I would like to know the difference between: :w and :w! or :wq and :wq! ...