vim

Writing a vim function to insert a block of static text

I'd like to be able to do something like this in vim (you can assume v7+ if it helps). Type in a command like this (or something close) :inshtml and have vim dump the following into the current file at the current cursor location <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtm...

How to find '-s' inside a vim search

I use Vim to read man pages. But I'm having trouble searching for variables. For example I use: /\<-s\> to search for '-s', but it doesn't find anything. Grrr. I see it in the file. What am I doing wrong? ...

How to :set spell in Vim only for emails?

Google is not being very helpful here. I'd like to compose emails with :set spell on, but for all other files, :set spell should be off. I am using mutt, and Vim as the editor for composing emails. In fact, I'm curious, how does Vim know that it's an email I'm composing? Is there a command-line parameter of the type of file being edited...

As a grapical IDE user, should I be interested in traditional editors?

I use full blown graphical IDEs such as Eclipse CDT (Linux) and Visual Studio (Windows) which have features like auto completion, built in debugging, etc. These are features that I feel I can't live without. I keep hearing about how many people use emacs/vim on a daily basis. How come people still use console based editors when graphica...

How do you search all source code in Vim?

When using Vim, and given a directory filled with code (e.g. ~/trunk/) with a number of sub-directories, is there a way to grep/search for instances of text/regexes across the entire source code? At the moment I use: :lcd ~/trunk :grep "pattern" *.py */*.py */*/*.py */*/*/*.py (Obviously I'm limiting this to Python files, which is a ...

Text editors with "vim mode"?

I've been looking at trying to learn vim for a while now, I've come across ViEmu through stackoverflow, and I read the very motivating article: Why, oh WHY, do those #?@! nutheads use vi? Anyway, I've come to like the command mode in vim, specially the motions, and I also like the idea behind ViEmu, which is to bring "vim mode" into a ...

VIM: how to color my vim grep result patterns?

When using VIM is there a way that :grep or :vimgrep will color the patterns returned to the buffer? Thanks! ...

Can I transpose a file in vim?

I know I can use awk but I am on a windows box I am making a function for others that may not have awk. I also know I can write a C program but I would love not have to create maintain and compile something for a little vim utility I am making. THe original file might be THE DAY WAS LONG THE WAY WAS FAST and it would become TT H...

Vim: Filename completion in reverse order

To open a file in vim, I usually type ":e " and then hit tab until the file I want appears. However, I always get in a rhythm and inadvertently go ONE past the desired file. Without knowing how to move backwards, I end up tabbing all the way to the end and repeating the whole process. Is there a way to perform the filename completion ...

Is there any way to highlight multiple searches in (g)vim?

I want to search for multiple strings in vim/gvim and have them highlighted in different colours. Is there a way of doing this with out-the-box vim or with a plug-in? ...

Viewing unified diff with meld/vimdiff other tools

Hi, I've got a unified diff file (say my_diff.diff), containing comparison of several files from a project. What would be the best way to review all the code changes in a nice visual format, for example, using meld or vimdiff? I have figured out the way how to do it for a single diff file (ie. containing comparison of just two files)...

Vim delete blank lines

What command can I run to remove blank lines in Vim? ...

Closing files in Vim from directory and its subdirectories

Is there a way in vim to close all files (buffers, let's not get into that) from some directory and its subdirectories? ...

Getting the logical path in VIM when there's a symlink

I have the following setup: mkdir /1 mkdir /1/2 mkdir /1/2/3 ln -s /1/2/3 /1/3 If I do cd /1/3, and then pwd, I get /1/3. If I use pwd -P, I can get /1/2/3, or pwd -L to force /1/3. In VIM, I'm looking for a way to get the /1/3. If I open a file in /1/3/foo.txt, and I use something like fnamemodify(bufname(winbufnr(0)), ':p:h'), it ...

Jump / Position cursor in Vim

How can I move the cursor to, say, position 25 on the current line? ...

How can I use gvim to add a carriage return (aka ENTER) to a pattern?

What's the vi/gvim syntax to replace a pattern with a pattern that includes <ENTER>? I know this is possible but never felt like diving too deep in the documentation to know how to do it. Something like this: :s/\(word\)/\1<ENTER>/ But correctly :) Thanks ...

Vim: need help with a tiny script code to highlight.

Hi. I need a script code to highlight "[Capítulo" and "]" and everything between them. Thank you. I want it to work everytime I open , for example, a .txt file. Just like code highlighting. ...

How to set curly braces'/parentheses'/square brackets'/arithmetic operators' syntax highlight color in VIM?

How do I highlight operators/parentheses/brackets/etc. in VIM? I'm not interested in coloring matching or unmatching parentheses/brackets. I've tried ":hi cBracket/whatnot guifg=something" and ":hi Operator/cOperator guifg=something" but these don't seem to affect anything. ...

What's the point of viEmu plugin for Visual Studio?

This may sound a bit provocative but it actually is a real question. Feel free to edit if you don't like the tone. Now, as much as I understand vi from my short experience with it like 10 years ago, it's a primitive text editor with one editable line at the bottom of the screen created before the scrollbars were invented, with some craz...

What are the dark corners of Vim your mom never told you about?

There is a plethora of questions where people talk about common tricks, notably "Vim+ctags tips and tricks". However, I don't refer to commonly used shortcuts that someone new to Vim would find cool. I am talking about a seasoned Unix user (be she/he a developer, administrator, both, etc.), who thinks (s)he knows something 99% of us ne...