Jens Oliver Meiert

Tip: vi Configuration

Post from May 25, 2008 (↻ June 12, 2021), filed under .

This and many other posts are also available as a pretty, well-behaved ebook: On Web Development.

Long story short: It’s easy to modify the vi editor’s standard configuration. The most useful changes probably relate to encoding (UTF-8 preferred) and display of line numbers. In order to do that, go to your home directory (enter cd), create a file called .exrc unless it already exists (enter vi .exrc, press i or a, paste the following, and save by pressing esc and entering :wq):

:set encoding=utf-8
:set number

That’s it. If you’re interested in additional options, have a look at a vi cheatsheet (PDF). It includes additional :set parameters (you can enter these in command mode, too). Or check out a book about vi—the editor infamously, “unofficially pronounced ‘six’ because of the feeling one gets when using vi that it may be the text editor of the antichrist.”

Update (February 17, 2013)

Here’s my vi configuration, a few years later:

:set encoding=utf-8
:set number
:syntax on

This also enables syntax highlighting.

Tweet this? (If it changed your life, you delight me with a coffee.)

About Me

Jens Oliver Meiert, on April 29, 2020.

I’m Jens Oliver Meiert, and I’m an engineering manager and author. I’ve worked as a technical lead for Google, I’m close to the W3C and the WHATWG, and I write and review books for O’Reilly. Other than that, I love trying things, sometimes including philosophy, art, and adventure. Here on meiert.com I share some of my views and experiences.

If you have questions or suggestions about what I write, please leave a comment (if available) or a message.

Comments (Closed)

  1. On May 25, 2008, 20:36 CEST, Jens Nedal said:

    So there we have another vi user 😎
    In our current work configuration which involves a team of 4 in the programming department, mostly PHP but also some Java and ofcourse the usual standards and accessbility compliant frontend output in HTML, CSS and Javascript/AJAX, 3 of us use vim as our chosen editor in a Windows environment and ofcourse also when working form the console.

    We do have a heavily configured .vimrc with various settings, like some autocompletion for function commentaries, which help keeping the phpdoc tree nice and clean and some other nifty stuff.

    Before i ever used vi i usually tagged along with some editors that had decent highlighting.

    vi is just very powerful and once you get around the “quirk” of only using keyboard commands for everything but marking text with your mouse, it is absolutly worthwhile and i would never move away from it again ever.

  2. On May 27, 2008, 9:42 CEST, Jens Oliver Meiert said:

    Jens, yah, vi is a usability nightmare but still awesome 😊 Love to see your vim settings!

  3. On June 8, 2008, 18:58 CEST, Martin said:

    Why not use vim, that’s basically the same, just with more features, such as tabbed editing, etc.

    In that case, the configuration file’s called .vimrc.

  4. On June 9, 2008, 19:39 CEST, Jens Oliver Meiert said:

    Martin, please correct me but it seems vi is available on more systems than vim. (I like that it’s so widespread.)

    A little addition, to use n spaces for indentation (instead of Tab), add the following lines (here using 2 spaces for indentation):

    :set expandtab
    :set tabstop=2

Read More

Have a look at the most popular posts, possibly including:

Looking for a way to comment? Comments have been disabled, unfortunately.

Cover: The Web Development Glossary.

Perhaps my most comprehensive book: The Web Development Glossary (2020). With explanations and definitions for literally thousands of terms from Web Development and related fields, building on Wikipedia as well as the MDN Web Docs. Available at Apple Books, Kobo, Google Play Books, and Leanpub.

Stay up-to-date? Follow me by feed or on Twitter.

Found a mistake? Email me, jens@meiert.com.

You are here: HomeArchive2008 → Tip: vi Configuration

Last update: June 12, 2021

Professional frontend developers produce valid HTML and CSS.