Using Vim
Using Vim to Edit Ada (or other languages) programs
- To get syntax editing, you need to execute the following command in vim:
- :syntax enable
- Executing this command will immediately cause the program to be highlighted.
-
To get indenting you need to execute these commands,
but you need them to take effect BEFORE you edit your file.
- :filetype indent on
- :filetype plugin on
- To make the commands available before you edit your file
(and to save yourself the trouble of typing these commands each time you edit a file)
put the commands in your vim startup file.
- You can also do these commands from within vim, and then edit the file using the comand :vi foo.adb, but this is more clumsy than putting them into the vimrc startup.
Vim Startup Files
- On rucs, the vim startup file should be called .vimrc and it
should be placed in your h: drive
- On a lab machine, H:\.vimrc should also work as your vim
startup file (although I have not tested it).
- On a home machine, your vim startup file will probably already exist under the name _vimrc and it will be found in the directory in which you installed vim
Example Vim Startup File
- Here is a sample vim startup file (ie .vimrc) that includes some
of my preferences
syntax enable " Set up syntax highlighting, etc
filetype indent on " Set up automatic indentation
filetype plugin on " Set up loading filetype plugins when certain files are edited
" Set up the command :make to do ada compilation
set makeprg=gnatmake\ %
" 4 character tabs and indents
set tabstop=4 " 8 is too much
set shiftwidth=4 " 8 is too much
" Tabs to be expanded to spaces
set expandtab " expand tabs
" Cause backspace to backspace over expanded tabs
set smarttab
" Set case sensitivity on searches
set ignorecase " Ignore case when searching
set smartcase " but, if case is used in the pattern, DON'T ignore it
set ruler " Show line and column numbers, as well as percent of file
set showcmd " Show partial command in status line
Notice that the character ':' is not needed for commands in the vimrc file
Vim On Your Home Machine
- Download and install vim from vim.org
- Edit vim startup file as shown above (on windows, _vimrc in the directory where
you installed vim)
- Ada mode in vim 7.1 has some bugs so you should install the
Vim Ada bundle which contains new versions of the broken files
- Install the ada bundle vimball by editing it and executing
the command ":source %".
- Let me know if this does not seem to work