Vim Tips Wiki
  • Please discuss proposals for new Featured Tips on the talk page.
  • The home page highlights the current featured tip.
  • Add comments on the current featured tip to the comments section on the current tip page.

Now THAT's a Good Tip![]

While most of the tips on this wiki are very helpful, every now and then, you'll stumble on a tip that shines above all the rest. Such a tip is a tip that changes the way you do a basic task, a tip that you try immediately and then use all the time, a tip that makes Vim integrate SO much better with your setup, or a tip that you just wish somebody gave to you when you started using Vim. We here on the Vim Tips Wiki recognize this, and therefore will on occasion feature a new tip that we feel is among the best of the best. So keep an eye on this page for life-altering (or at least mildly interesting) tips to add to your repertoire.

Previously featured tips[]

This is an archive of the Featured tip section on the home page. We may not feature these tips again, however they remain great tips!

June 2012[]

When writing a program it can be convenient if closing brackets are automatically inserted. For example, after typing { it can be handy if the closing } is added automatically.

Our featured tip discusses solutions for this problem: some simple mappings are provided and their shortcomings outlined. More advanced solutions require a plugin, and a list of scripts for the automatic insertion of matching brackets is provided.

June 2011[]

Vim can work with all the major line-ending formats but sometimes does not load a file in the format you want. Usually this is because a different text editor saved a file with mixed line-ending styles. It can be very annoying to load a file in Vim, which reads in with a Unix file format, when only a few lines lack this carriage return. It is worse when you cannot modify it because of strict revision control.

Our featured tip automatically reloads such files using DOS format if any DOS-style line endings are found. This will automatically "correct" the file if you save it, so an enhanced version will also tell you how many line endings are in each style so you can decide for yourself which format to use on a save.

April 2011[]

For a long time now, Vim has had the ability to work with files in a very large set of character encodings. Using a character encoding with a very large range of characters, such as the Unicode encodings, can provide many benefits to any Vim user. Whether you need to work with multiple languages, or just want to use fancy box-drawing characters and arrows in your 'listchars' option or a plugin, using a Unicode encoding can make editing in Vim even more pleasant than it already is.

There are a lot of options that impact encoding in Vim, and it can be intimidating to someone not familiar with them. (And who really is?) Our featured tip discusses the various options you will need to start using Unicode successfully. Use the included example as a starting point or a drop-in addition to your vimrc to start editing in Unicode today!

February 2011[]

Vim is made to work well with other tools, which means that whenever Vim saves a file, it correctly adds a line ending of the correct format for your system to the end of every line. When the file already existed, this is usually done whether the original file had a line ending on the final line or not. Nevertheless, Vim does keep track of whether the file originally had a line ending on the last line in the 'eol' option, so that when writing binary files Vim does not introduce any new bytes.

Our featured tip takes advantage of this 'eol' option, to preserve the missing end-of-line on the last line of files which are read in without one.

This can be useful if you work on a project with very strict policies against needless changes to files, or which specifically require no EOL on the final line.

January 2011[]

The ability to undo mistakes and redo them if you change your mind is a basic feature of any advanced editing program. Vim expands on this, keeping track of every change made in one or more "undo branches", so that you can return to any state your buffer was in even after undoing those changes and making different changes. Vim 7.3 adds the "persistent undo" feature, which saves this undo tree between editing sessions to make it even more powerful.

Our featured tip will introduce you to Vim's undo tree, and even show you some plugins that make it simple to use.

Previous years[]