Tip: vi Configuration
Published on May 25, 2008 (⻠August 17, 2024), filed under Development (RSS feed for all categories).
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) and display of line numbers. In order to do that, go to your home directory (enter cd), create a file called .exrc (or, for Vim, .vimrc) 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, perhaps 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âyes, 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.
About Me
Iâm Jens (long: Jens Oliver Meiert), and Iâm a frontend engineering leader and tech author/publisher. Iâve worked as a technical lead for companies like Google and as an engineering manager for companies like Miro, Iâm a contributor to several web standards, and I write and review books for OâReilly and Frontend Dogma.
I love trying things, not only in web development (and engineering management), but also in other areas like philosophy. Here on meiert.com I share some of my experiences and views. (Please be critical, interpret charitably, and give feedback.)
Comments (Closed)
-
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.
-
On May 27, 2008, 9:42 CEST, Jens Oliver Meiert said:
Jens, yeah, vi is a usability nightmare but still awesome đ Love to see your vim settings!
-
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.
-
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 brief addition, to use n spaces for indentation (instead of Tab), add the following lines (here using 2 spaces):
:set expandtab :set tabstop=2
Read More
Maybe of interest to you, too:
- Next: Ăber-Semantics
- Previous: Less Is Still More
- More under Development
- More from 2008
- Most popular posts
Looking for a way to comment? Comments have been disabled, unfortunately.
Get a good look at web development? Try WebGlossary.infoâand The Web Development Glossary 3K. With explanations and definitions for thousands of terms of web development, web design, and related fields, building on Wikipedia as well as MDN Web Docs. Available at Apple Books, Kobo, Google Play Books, and Leanpub.