![]() |
|||||||||||||||||||||||||||
|
This page was last modified: July 22 2007 17:10:15 | ||||||||||||||||||||||||||
|
My preferred texteditor is Vim. Why? Because it's the only one I've ever used ;-) - There's probably a lot of other good text editors out there, but I was recommended to use Vim, and just stuck to it, since it gets the job done for me. So if your looking for a "this text editor vs. another text editor" -article, you've definitely come to the wrong place... This document contains: Installing Vimcd /usr/ports/editors/vim/ Note the WITHOUT_X11=yes part. I'm including it since I'm not using a graphical interface on the server, and therefore I don't need support for a GUI. It would just take up unnecessary diskspace. Configuring VimThe configuration file for Vim is named .vimrc (note the dot in the filename) in your home directory. The .vimrc file is sometimes also referred to as the exrc file. They are the same type of file, but "exrc" is what Vi always used, "vimrc" is a Vim specific name.
If you can't see the .vimrc file in your home directory, just create it. It is safe to use Vim at this point .. if there's no user configuration file, the default settings is used instead. Vim has MANY configuration options and I recommend you take a look at Vim documentation: options if you wan't to know more about the settings. All settings can be set both at runtime (while editing a file) and in .vimrc. This is my .vimrc:
if &term =~ "vt100" If you copy and paste the above, there's a few things you have to be aware of. The red parts has to be inserted in a special way. Just delete them and insert them again like this.: ^[ = press [CTRL]+[V] and then [ESC] To be honest I don't know what half of the stuff in my configuration file means... and I don't care as long as everything works as expected. Of course there was a few things I had to look into, since they didn't behave as I wanted. In my case, that was the delete, home and end keys. It took me a while to figure it out, but finally i found a fix for this and added the above three lines. This is what I found in the documentation regarding set bg=dark: Vim guesses the background color that you are using. If it is black (or another dark color) it will use light colors for text. If it is white (or another light color) it will use dark colors for text. If Vim guessed wrong the text will be hard to read. To solve this, set the 'background' option.This means that if your colors seam to light for the background use: set background=dark or set bg=dark They both have the same effect If the opposite is the case, try: set bg=light I found an explanation of the minimal settings for the .vimrc file at http://www.frozen-north-linuxonline.com/Howto/vimsetup.html. Use that link if you wan't a quick and understandable explanation of the lines beginning with set ai nocp and set bs=2 fo=cqrt . Syntax highlightingOne of the things I love most about Vim, is its syntax highlighting and mappings. If unix and Vim is new to you syntax highlighting can be a real hassle to get working. I did everything right, but it still didn't work. Then someone suggested that I change my term to vt100, and then everything worked fine.... here's what I learned from struggling with the settings.: You need to add two things to your configuration file (.vimrc): colorscheme mine tells Vim to use a theme called "mine" for syntax highlighting (more about that below), and syntax on is necessary to enable syntax highlighting. You need a color scheme file - a configuration file for syntax hightlighting. Vim comes with a variaty of examples. Just take a look in /usr/local/share/vim/vim64/colors. Create a new directory in your home dir for the file:
mkdir ~username/.vim Next pick a color scheme you like and copy it to .vim/colors/mine.vim. When the file is in place, open it and change the value of colors_name: let colors_name = "mine" Set as defaultIf you always prefer to use Vim when editing text, you should set it to be your default editor. This is done by changing the EDITOR environment variable, which is located in the shell initialization file, in the users home directory. The name of the file depends on the shell. In the below example the file is .profile, since this user is using the shell named bash. If the file does not exist, just create it. Consult the man pages for your shell, if you are not sure which file to edit.
cd /usr/home/bill The file could contain something like this:
# $FreeBSD: src/share/skel/dot.profile,v 1.19.2.2 2002/07/13 16:29:10 mp Exp $ Just locate the EDITOR environment variable (or insert it if it isn't there) and change its value to vim. The change will take effect at the next login. Tabbing with spacesYou can setup Vim to use spaces when pressing the [TAB] button on your keyboard, instead of inserting a real tab. I always setup Vim to insert 2 spaces whenever I press [TAB]. This is done by inserting this in the .vimrc file:
set tabstop=2
The expandtab option makes Vim use spaces instead of tab. If at some point you want to insert a real tab character, just press [CTRL]+[V]+[TAB]. |
|||||||||||||||||||||||||||