Contents

Vim recognizes three file formats (unix, dos, mac) that determine what line ending characters (LF, CRLF, CR) are removed from each line when a file is read, or are added to each line when a file is written. A file format problem can display ^M characters, or can prevent scripts from running correctly.

Our featured tip shows how to remove unwanted ^M characters, and explains how to convert from one file format to another.

Inserting a line break (newline) before or after each occurrence of specified text is easy.

Our featured tip shows how to insert newlines using a simple substitute command. It also presents a small script that defines a command to make the job even easier. The script has an explanation that may be helpful for anyone wanting to see how Vim scripts work.

Have you ever wanted to insert the same text in the same position in multiple lines? That is easy with visual block mode: press I to have text inserted on each line in the selection. If the block visual selection used $ to select end-of-line, you can also press A to have the same text appended to each line.

Our featured tip has the details. It also shows how to use the substitute command to insert or append text.

We all know what a tab page is – each tab holds a different file. Actually, Vim tabs are not like that. Instead, tab pages in Vim offer much more flexibility, and provide many features that are unavailable with standard editors.

Our featured tip discusses ideas for how to make the most of tab pages in Vim: one tab can show windows for files you are currently working on, while other tabs display diffs, or x-ray or folded views, and more.

We have lots of good information on searching. One special requirement, when writing a program, is to limit the scope of what you search, such as by searching only within the current function, or only within the current code block.

Our featured tip provides a script so you can easily search within a specified scope in program languages such as C and C++ that use braces ({...}) to delimit blocks.

On Windows systems, Vim can easily run an external program asynchronously without irritating "Press Enter" messages. You can run a GUI program with a command like :!start calc, and you can run a console-mode program with a command like :!start cmd /c myapp.exe & pause. Both examples run the program but immediately return to Vim, allowing you to continue editing while the invoked program runs.

It is also possible use this method with Vim's clientserver features to run a program (like grep) for a long period without interrupting your editing, and notify Vim to take action (like loading the search results) when the program has finished. Our featured tip has the details.