Q: How do I change my vim settings?

You may change your vim settings. For example, to turn on auto-numbering, you may enter the following in the command mode:

:set number
Or you may enter the following to toggle the auto-numbering on and off:
:set number!

For example, to change the colour scheme, you may enter this to find out what are the colour schemes available:

:colorscheme followed by space and ctrl-d

The following shows the output:

You may then change the colour scheme by choosing one of the available schemes, for example:

:colorscheme morning

However, note that the above setting is lost once you exit from vim.

(Google to find out more about the various settings.)

Q: Then how do I make my vim settings permanent?

To do this, you need to keep all the settings in a special file called .vimrc and put this file in your home directory. This is the configuration file for vim.

When you did the setup in your first lecture or the Intro Workshop, this .vimrc file was created and loaded into your home directory. The file can be downloaded here and its content is shown below:

:syntax enable
syntax on
set number
set ruler
set nocompatible
set bs=2
fixdel
set nowrap
set tabstop=4
set autoindent
set term=linux
set smartindent
set showmode showcmd
set shiftwidth=4
set backspace=indent,eol,start
colorscheme delek

For example, to turn auto-numbering off permanently, you may remove the line set number from the file .vimrc.
Or you may change the tab stop to 6, by changing the line set tabstop=4 to set tabstop=6.
Or you may change the colour scheme, for example: colorscheme morning.

Q: How do I add abbreviations?

Abbreviations are handy especially for frequently used text that appears in C programs. For example, this line

int main(void) {
appears in almost every C program. You may want to create an abbreviation for it. For instance, add this line in your .vimrc file:
ab main- int main(void) { 
This adds the abbreviation "main-". When you type main- followed by a white-space, it will be expanded into int main(void) { automatically.

Other Links on vim

Go to CS1010 website Resources - Online page.


Aaron
Sunday, August 17, 2014 02:21:25 PM SGT