vim

How to fold C++-style comments in Vim?

Syntax folding in Vim makes it easy to create folds for regions, the start and end of which can be defined with regular expressions: syn region myRegion start="#region" end="#endregion" transparent keepend extend fold However, I am not sure how I can use syntax folding to define folds for C++-style comments, which are sets of lines...

Adding vertical space between lines in vim.

Summary: I'd like to view my text in vim with a small bit of extra vertical space between some lines. I'm writing latex in vim, and have each sentence on a new line. I'd like to add a little bit of vertical space (a few pixels) between sentences to make them clearer. I don't want to add anything to the buffer, just to how I view it. I ...

Why can't I stop vim from wrapping my code?

I know there must be something obvious I'm missing, but I can't stop vim from wrapping my python code. I enter :set nowrap like a champ, but still it wraps. I can hit J to unite the split lines of code, so it seems like a real carriage return is being inserted, I just don't understand why or how to stop it. ...

VIM: c#_< with ":browse oldfiles"?

The manual hints about the "c#_<" in the context of oldfiles. You can find the point in the help with ":h viminfo-file-marks" and scrolling down. What does the manual mean with c#_< or _< n ? What are the symbols? CTRL, #, _ and number? How do you use the marks-viminfo-oldfiles-c#_ ...

VIM: Highlight positions of the marks?

I am practising '[ and '], and I cannot see the difference. How can you highlight the positions of the marks? ...

Very strange behavior with Vim syntax and filetype detection

I have a file, called WrongFileTypeDetection.R, containing the following text: # This file is sometimes wrongly detected as a conf file I also have two versions of _vimrc, that I would have thought to be absolutely identical. However, when I use the first version, the above file is incorrectly detected as a "conf" file, even though I...

replay a vim macro until end of buffer

I want to run a macro I just recorded in register "x" on every single line of an open buffer, from my cursor to end of the buffer, in vim. How do I do that? I know I can replay the macro n times: 15@x ...or just hold down @ until I reach the the last line, but I want to just hit a few keystrokes and be done with it. Thanks in advanc...

Tilde color in vim?

Hello When VIM starts, it displays '~' symbol for empty lines. Does anyone knows is it way to change this tilde symbol color? ...

Best gVim tricks for programming?

I've used Vim for about 8 years, and I am trying gVim for the first time. What settings do you to be productive? What's in your gvimrc? Note: gVim only. Vim stuff is quite well taken care of in: http://stackoverflow.com/questions/95072/what-are-your-favorite-vim-tricks http://stackoverflow.com/questions/164847/what-is-in-your-vimrc ht...

Quicker way to enter ex mode in vim?

Is there a somewhat orthodox way to enter ex mode faster, like with a single key stroke, instead of hitting shift-; for ':'? Why was that character ever chosen for such a frequently accessed mode? Often enough to be annoying I'll accidentally miss the shift key, start typing an ex command, and find I have a lot to undo. Thanks for you...

How do I get Vim to treat underscores in a string as a word break?

I would like Vim to treat underscores in a string as word-breaks, just like a spaces. For example, if I have: sub foo_bar { return; } With the cursor starting at the far left of the first line, (on the 's' of 'sub'), hitting 'w' will place the cursor on the 'f' in 'foo', a second press of 'w' takes me to the curly, and a third ho...

what does ^A stand for in vim

I need to replace ^A, ^B in a file, the following command is useless :s/^A/ ...

How to "apply" backspace characters within a text file (ideally in vim).

I have a log file with backspace characters in it (^H). I'm looking through the file in Vim and it can be quite hard to see what's going on. Ideally I'd like to be able to "apply" all the ^H on a given line/range so that I can see the final result. I'd much rather do this within Vim on a line-by-line basis, but a solution which convert...

Ruby syntax checking in vim

Hi everyone, I use vim with various plugins for editing ruby code. I have proper syntax highlighting set up but I was wondering if anyone knew of a way to get ruby syntax checking, similar to what you might see in an IDE such as visual studio, radrails, etc? Something that would simply turn stuff red or break highlighting when I'm m...

How can I make my match non greedy?

I have a big HTML file that has lots of markup that looks like this: <p class="MsoNormal" style="margin: 0in 0in 0pt;"> <span style="font-size: small; font-family: Times New Roman;">stuff here</span> </p> I'm trying to do a Vim search-and-replace to get rid of all class="" and style="" but I'm having trouble making the match ungreed...

Vim 7.2 hangs on startup, "killall vim" fixes it

I just compiled vim 7.2 on a Linux server (in my user dir, since the server had vim 6 installed and I wanted to upgrade but do not have root privileges). When I enter "vim", it hangs on startup without any response, but when I call "killall vim" from another ssh window, startup completes and vim seems to work fine after that. Why would ...

What are the typical use cases for vi?

I recently started picking up vi, going through some tutorials and trying to get used to it. But I still have some questions about it. It seems to be nice for small one file changes, but as soon as I start to try doing bigger things it seems to be lacking. For example I'm used to have code formatting, import organizing, simple overview ...

Previewing RestructuredText with firefox while editing in vim on ms-windows

Hi I want to use VIM to edit reStuctured text documents in a number of operating systems. I found this posting http://www.zopyx.com/blog/editing-restructuredtext-with-vim Can you help me come up with the line to achieve the same effect when run on a MS-Windows operating system? Would it also be possible to to use an environment varia...

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

Vim: write back my file on each key press

I'd like vim to automatically write my file as often as possible. The ideal would be every keystroke. I need to save regularly so that my background build process will see it. It's a makefile for a latex document, and I'd like the previewer to show me a nearly up-to-date document when I'm finished typing. Eventual answer (the answers b...