NetworkingFiles
SecurityProNews
ITmanagement




Custom VIM Settings In A Multi-user Environment

By: Michael Marr
Expert Author
2010-08-04

Vim is handy text editor, which improves upon the included editor in Unix, vi. With so many plugins and scripts available for VIM, many developers consider this application their number one source for editing and developing code. With all the available customization, vim can be finely tuned to exactly what you need. The ability to finely tune, however, can become a problem when you are sharing a vim instance with other developers.

Say, for instance, you have a dev account on a web server, for which you share the account with all the other developers in your organization. This account has all the necessary credentials to get your developing done. So you SSH into a web server and use vim to develop on the remote server. Simply changing the settings files on the machine and/or for the user dev to match your local vim configuration won't do the trick, as it will force your co-workers into using your settings. If they don't like your choices, you'll find them quickly changing things back, and create a tug-of-war scenario over the settings and tweaks in vim.

So how can resolve this situation? Using the -s option in vim and an alias, we can have our vim and customize it too!

First, you'll want to create a file that will have all the commands you want to execute when loading vim. Often, these are things like how big the tab space is, or showing line numbers. Obviously, depending on the current default settings of vim, and the settings you prefer, this file will drastically change. For simplicity, we'll use this short example:


:set ts=3
:set numer
:vs


After saving this file, you can use the -s option in vim to load and execute the lines in this file verbatim.


vim -s /path/to/your/filename


Obviously, typing that command every time is just as annoying as going through a list of customization command in vim as you need them, so we'll shorten up the vim runtime with an alias.


alias vimine="vim -s /path/to/your/filename"


Adding this alias will allow you to type vimine filename to execute vim with your settings file while loading the specified file.

The last step is to preserve this alias, as the alias will be lost when your session ends (and not even available if you open an additional concurrent session). In many distros, you can add this alias command to the end of a ~/.bash_aliases or ~/.bash_rc file, and they will initiated every time you start a new instance as that user.


About the Author:
Michael Marr is a IT staff Writer for WebProNews.
Newsletter Archive | Submit Article | Advertising Information | About Us| Contact

LinuxDeveloperNews is an iEntry, Inc.® publication © All Rights Reserved Privacy Policy and Legal
iEntry Contact Advertise iEntry Jayde WebProWorld Forums Downloads News Article Archive About iEntry LinuxDeveloperNews Home Page LinuxDeveloperNews News