vim

Using % key to find matching brace: how to exclude commented out code ?

1 #include <stdio.h> 2 int main(int argc, char* argv[]) { 3 int i=10; 4 /* } */ 5 return 0; 6 } If the cursor is on line 2 under '{' and I press the '%' key, the cursor shows the matching closing brace on line 4 (which is commented out) and not the matching closing brace on line 6. Is there any workaround for this? Tha...

how to prevent vim from creating (and leaving) temporary files?

Why does vim create <filename>~ files? Is there a way to disable that? If it's for backup (or something), thanks but no thanks, I use git so I don't need your silly backup. Also, these .<filename.with.path.hints>.swp files too. How do I tell vim not to create those? or at the least to cleanup after itself? EDIT wops, duplicate: ...

how to add an extra character at end of each line in vim

I have the following use case, my file contents look like this a b c I want a regular expression to do this a| b| c| Can you recommend a regex in vim? ...

Can I see changes before I save my file in Vim?

I use Vim. I open a file. I edit it and I want to see what I've edited before I save it. How can I do this in Vim? ...

How do I set vim 7's html tidy options for "utf-8" encoding?

I need to run tidy in vim, using the usual: :compile tidy :make However, if I'm on an utf-8 file, I get errors that I don't see if I run tidy outside of vim, i.e., tidy -e -q -utf8 I get what I'm expecting TIA! ...

What is the fastest way to reverse a comma-separated list in vim?

I frequently must correct the following rails code: assert_equal value, expected The two arguments to assert_equal are out of order, and should read: assert_equal expected, value In vim, what is the most efficient way of going from the first line to the second? ...

How can you control folds by an external file in Vim?

I have been searching a solution which puts the fold marks and codes to an external hidden file. This way you could have permanent folds without extra fold signs. How can you control folds by an external file in Vim? ...

How do I make text wrapping match current indentation level in vim?

Does anyone know of a way to get vim to wrap long lines of text such that the position of the wrapped text is based on the indentation of the current line? I don't want to reformat my code, just for it to be displayed prettily. For instance, if I set my settings so that the line: print 'ProcessorError(%r, %r, %r)' % (self.file, self.in...

VIM - Show the diff of last saved version and current unsaved version

Duplicate: Can I see changes before save my file in Vim? Is there a way to see the diff of the saved version and the edited version of the same file in VIM? This is the scenario: I've opened a file, editing something and I went away from the computer due to some work. After sometime I returned back and I forgot what I was editing a...

Extract a string within "> and </ pattern

I am trying to extract the string from a file having following pattern within a line >------ </ The ----- represents can be any variable length string. The start pattern within a line is > and end pattern </. Using regex of VIM is command line search possible? and if so could that be printed? Or will have to write a script? I am a ...

How do I prevent the vim from using the wrong viewport after the :make command?

I often have multiple viewports opened in vim, using the :vsp and :sp commands. After I've been editing for a while, I'll often run the :make command from within vim. When I get errors, vim will then show me the lines that gcc says caused my errors. However, vim will often open the file with errors in another viewport, even if that file ...

How can I automatically fold a long C code in Vim?

I regularly run into C-codes without folding. It is irritating to read them if there is no folding, particularly with long files. How can I fold them? ...

Vim: remap key to toggle line numbering

I've added: set number nnoremap &lt;F2&gt;:set nonumber! to my vimrc file. Basically what it's supposed to do is let me press to toggle line numbering but it's not working. What have I done wrong? Thanks in advance :) ...

Is there a way to emulate ReSharper's "extend selection" feature in Vim?

ReSharper has a nice feature called "extend selection": by pressing CTRL+W (I think this is the default) repeatedly, you select more and more from your current caret location. First it's a word, then more and more words, a line, inner then outer block of lines (for example an if-block), then a function, etc... Basically, by pressing the...

How to interact through vim?

I am writing an editor which has lot of parameters that could be easily interacted with through text. I find it inconvenient to implement a separate text-editor or lots of UI code for every little parameter. Usual buttons, boxes and gadgets would be burdensome and clumsy. I'd much rather let user interact with those parameters through vi...

gVim tabline

In gvim, is it possible to have multiple rows of file tabs? That is, instead of showing left/right arrows to navigate around the tabline (for tabs that don't fit into the tabline), it should "start" a new row of tabs. Thanks in advance. ...

Unable to pbcopy at Vim's ED editor

I have tried unsuccessfully to copy the pwd to pbcopy as follows pwd | !pbcopy How can you copy your path in Vim's ED editor (: -mode)? ...

VIM Key map

HI, Im beginning VIM. I hate pressing the Esc command, which is a little far in T61, in order to return to command mode. How do I map it to F4? ...

Accessing Multiple Files in VIM

The book "Unix in a Nutshell" discusses about accessing multiple files on pages 572-573. There seem to be very useful commands such as ":e", ":e #", ":e new_file", ":n files", ":args", ":prev" and ":n!". The commands confuse me: ":n Edit next file in the list of files." ":args Display list of files to be edited." ":pre...

Unable to search repeated sentences in Vim

I run the following unsuccessfully in Vim's search mode ^(\1) (\2) I am trying to find lines which two first words are the same in my .vimrc. How can you search these lines in Vim? [edit after the first answer] I found the handy tool :sort u How can I compare my 1st version and the subsequent version after the command? ...