vim

How can I replace a word all the files within a folder in Vim?

I know that by typing the following: :%s/iwanthis/replacedbythis/g will change all the matching words of the file. How can I do the same for all the files within a folder? (actually replacing a lot of words like this: padding-bottom:5px;) ...

remove the <++> in the Vim-Latex

Hi all I am using the Vim-Latex now. But I have a question, when everytime I type the {*}, it would append <++> automatically? How can I disable it? Best Regards, ...

How to add a piece of code in the same pace in all the files within a folder in Vim?

I want to add this code: <link rel="stylesheet" type="text/css" href="css/global.css" /> <!--[if lt IE 8]> <link rel="stylesheet" type="text/css" href="css/iehacks.css" /> <![endif]--> to all the files in a folder right before the </head> tag ...

Making Vim auto-indent PHP/HTML using alternative syntax

I edit PHP in Vim and have enjoyed the auto-indenting, but PHP's alternative syntax doesn't auto-indent how I would like. For instance, in an HTML template, Vim doesn't recognize the open control structure in the same way it does when using braces. Example: <html> <body> <p> <?php if (1==1): ?> This line should be inde...

How to fold a class which is declared inside a class in ruby code

I am using mvim and I would like to fold the class Experiment. How do I do that? class Lab def method1 end class Experiment def method2 end end # end of class Experiment end # end of class Lab ...

Vim syntax highlighting not working (but works in gvim?)

I've followed all instructions given on this site with an empty .vim folder, but for some reason, python highlighting is not working on my system. It only highlights the comments and a few variables - nothing like the picture. http://concisionandconcinnity.blogspot.com/2009/07/vim-part-i-improved-python-syntax.html Is there some other ...

vim-latex config

Hello: I have installed vim-latex package using my ubuntu's synaptic package manager. I followed the instructions here to edit my .vimrc file. However, when I open up a .tex file in vim, nonw of the new menu options appear and I can't seem to compile documents using \ll. What did I do wrong? ...

vim default syntax for files with no extension

How do I set up a default syntax for files that have no extension in vim? ...

Prepending character N followed by line numbers

Hi, I'm hand editing CNC Gcode text files and need a way to reference locations in the file and on the toolpath. I want to modify each line in the text file so that it begins with the the upper case N character followed by line numbers which increment in tens for every successive line, then a whitespace,followed by the original text file...

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

How do i insert a blank line before every comment (eg "#") in VIM?

Hi In Gvim I need to insert a blank line or two before every comment in the file. Eg #comment 1 #comment 2 statement 1 statement 2 #comment 3 After running the comamnd it should be #comment 1 #comment 2 statement 1 statement 2 #comment 3 How do i do this? Thanks Update: Thanks for the answers But if the comments are contin...

editing a file with vim that has no EOL marker on the last line but has CRLF line endings

I often have to edit script files, the interpreter for which treats files that have an EOL marker on the last line of the file as an error (i.e. the file is treating CRLF as "newlines", not as "line endings"). Currently, I open these files in Vim using binary mode (-b on the command line). It autodetects the lack of EOL on the final li...

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

Escape characters during paste in vim

I copy stuff from output buffers into C++ code I'm working on in vim. Often this output gets stuck into strings. And it'd be nice to be able to escape all the control characters automatically rather than going back and hand editing the pasted fragment. As an example I might copy something like this: error in file "foo.dat" And need t...

Changing text appearence in vim

Suppose I have a file, whose entire contents is: \u1234 and suppose 1234 is the code for \alpha is there a way to, in vim, have the "\1234" show up as a single \alpha symbol (and be treated as an \alpha symbol) ? Thanks! [This problem arises since I want to to use unicode names in g++] ...

vim unicode bufread/bufwrite script

Problem: I want my unicode characters to be stored on disk as (rather tan utf8/16 encoding) \u#### However, I want them dispalyed as unicode characters when opened up in vim. I think the easiest way to acheive this is some bufopen/bufwrite script that automatically: on opening, convert \u#### to unicode character on writing, conve...

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

How to sort UTF-8 lines in Vim?

I have these lines in Vim: a c b e é f g and when I do :%sort, I get this: a b c e f g é Obviously, the "é" line should not be at the end, it should be after the "e" line. Is it possible to get Vim to sort these lines correctly? Not using the ASCCI key for the characters but the actual character. I also tried with :!sort (to use G...

Vim search in C/C++ code lines

Hello. Is there any way to search a string in a C/C++ source file while skipping commented lines? ...

How to keep same substrings in vim regex

Hi everyone. I'd ideally like a vim answer to this: I want to change [*, 1, *, *] to [*, 2, *, *] Here the stars refer to individual characters in the substring, which I would like to keep unchanged. For example [0, 1, 0, 1] to [0, 2, 0, 1] [1, 1, 1, 1] to [1, 2, 1, 1] If people know how to do this in perl or python or whatever, t...