vim

How to delete the text in a file except the words I needed using VIM

I have an XML file like this: <text> <A>12</A> <B>13</B> </text> <text> <A>14</A> <B>15</B> </text> Now I want delete all the text in the file except the words in tag A. That is, the file should contain: 12 14 How can I achieve this? ...

Only load a plugin when +python is enabled

I have a plugin that will only run if vim has been compiled with +python pythonhelper. I share my .vim with a number of machines, and some of the machines don't have vim compiled with python mode turned on. So, I would want to know: is there a vim command I can put in my vimrc so I can conditionally include the plugin? Something like: ...

How to delete text in a file based on regular expression using vim

I have an XML file like this: <fruit><apple>100</apple><banana>200</banana></fruit> <fruit><apple>150</apple><banana>250</banana></fruit> Now I want delete all the text in the file except the words in tag apple. That is, the file should contain: 100 150 How can I achive this? ...

[MAC|G] VIM: highlight all occurrence of a selected word?

How can I highlight all occurrence of a selected word in gvim? (like notepad++..) ...

Feeds and podcasts for the vim text editor?

Vimcasts is fantastic, and I want more educational, vim-related feeds and podcasts but am having trouble finding any more quality ones. There must be more out there! Please list your favorite vim-related XML feeds and podcasts. ...

Interface texshop with vim

Hello, Any advice on how you would interface texshop on mac osx with vim? I'm using vim quite a lot lately for coding. I find myself now trying to use vim-commands (replace, search, pattern matching, move, etc) when writing documents for latex with texshop and they obviously don't work. However, I don't want to leave texshop altogether,...

How do I use VIM effectively for editing English text?

As a programmer by heart, if not by profession, I increasingly rely on, nay live in VIM for most editing-related tasks. What tips can you offer for using (almost) everyone's favorite editor for editing general-purpose text, say, an article? I mean plain text, with minimal markup using Markdown or RST; I'm not looking for support for LaTe...

How to disable vim's indentation of switch case?

I'm currently fighting with Vim, I can't seem to make the indentation options do what I want. Here are my settings, I put them at the bottom of .vimrc to make sure they take precedence. As you can see I'm going a little crazy, so I tried turning off almost everything: set cindent set cinkeys=o,O set cinoptions= set cinwords= set indent...

In vim how to map "save" to ctrl-s

In vim how to map "save" to ctrl-s . (i am trying "map" command, but xterm freezes when i give ctrl-s. If i give ctrl-v,ctrl-s still i see only a ^, not ^S) ...

VIM recently edited files history

Is there a history of files edited in VIM that persists between vim sessions, e.g. last 20 opened files. I tend to edit the same .conf files and I have to navigate to them each time of course they are spread all over the filesystem. ...

Vim C++ auto complete

How do I enable auto completion in Vim? I tried to do this one, but I'm not proficient with the vimrc file, etc., so it didn't work out. Can you give me step by step instructions on how to do this? Edit I tried installing OmniCppComplete. Followed the instructions, but when I try to use it I get the following error: Error detect...

How to move screen without moving cursor in Vim ?

Hi, I recently discovered Ctrl+E and Ctrl+Y shortcuts for Vim that respectively move the screen up and down with a one line step, without moving the cursor. Do you know any command that leaves the cursor where it is but moves the screen so that the line which has the cursor becomes the first line ? (having a command for the last line w...

vim: disable mswin (turn off windows shortcut keys)

I just installed vim on Windows XP machine. When logged on to another user a little bit ago, I went to C:\program files\vim\_vimrc and commented out the following lines "source $VIMRUNTIME/vimrc_example.vim "source $VIMRUNTIME/mswin.vim "behave mswin and then Ctrl-X didn't cut text -- which is good. However, when I logged in as admi...

Git using non-standard .vimrc?

I've noticed that git seems to use different vim settings any time I'm writing a commit message. I have the git+svn install off Macports, and I've checked the $MYVIMRC variable: it's set to the correct file. Still, every time I go to commit a message I have a restriction on 80 characters per line, case sensitive search, and none of the p...

vim: Using <afile> in an autogroup command

My goal is to highlight <basename>.<extension>.erb files as I would highlight <basename>.<extension> files. As a first pass, I'm fine with supporting <basename>.<filetype>.erb, which I tried to do with au BufNewFile,BufRead *.erb setf <afile>:r:e But this doesn't seem to be working. What should I be doing? ...

Vim: Simple "jump to file" command?

What's the simplest way to "jump to a file somewhere in my source tree by name"? For example, if I'm working with "libfoo" that contains libfoo/foo/foo.py, I'd like to be able to jump to foo.py from anywhere within libfoo/**[0]. Possibly some way to do this with a tags file? [0]: that is, libfoo/ and its subdirectories. ...

visual selection in bash / cli

Is there a way to make bash use visual selections for text replacement? Standard text input conventions don't work: If you press Shift+Left Arrow, the character to the left should be visually selected If you press Ctrl+Left Arrow, the cursor should move to the beginning of the previous word If you press Shift+Ctrl+Left Arrow, the wo...

Overwriting search command in vim

When writing non-code with vim, I often have the need to search for multiple words that might be separated by a newline instead of a space. For example, I may want to search for occurrences of "white house", but some occurrences may have a newline between "white" and "house". I am aware that such multiline search is possible with "\_s"...

How do I make vim open all files matching a pattern in different tabs?

In a given working directory, if I do :tabe **/test*.py vim complains with E77: Too many file names. What if I want it to open every matching file in a separate tab? There must be a way to do it, but I can't find it. ...

How do i fix the indents in my html/php files in vim?

I am (slowly) making the switch to vim. I have added some settings to my .vimrc file (:syntax enable, :fileype plugin on, autoindent, etc.). Everything works great except when I try to indent lines using >. It double indents: <div> ----<p>this line was autoindented </p> </div> <div> --------<p>this line was indented using the > key </p...