VIM setup for ISIS

From Remeis-Wiki
Jump to navigation Jump to search

Listed below are a few useful VIM setup commands for the use of ISIS. The shortcuts need to be added to the .vimrc file in order to work.

Warning: Only use comments you understand! Some of the below commands execute shell commands which have the potential to do things you don't want to do!

General settings

Use jk instead of <ESC> to exit insert mode:

inoremap jk <ESC>

Turn on syntax highlighting:

syntax on

Turn on line number displaying:

set number

Highlight all search results when searching through code:

set hlsearch

Personal choice: ignore case when searching

set ignorecase

Also show search results already while typing

set incsearch

Automatically copy current indentation to newlines

set autoindent

Allows backspace key to remove auto-indentation (see above command), characters left to the cursor and newline characters

set backspace=indent,eol,start

Display the cursor position in the lower right corner

set ruler

Show partial commands entered in the lower right corner (e.g. 10dd for deleting the next 10 lines would be displayed as you type it)

set showcmd

ISIS specific settings

This creates a specific command :RunIsis, which executes isis ./{filename} on the command line. Very useful for executing scripts directly from VIM.

command! RunIsis :execute '!isis ./' . expand('%:t')

When writing a .sl file to the disk (e.g. using :w), the file is automatically made executable, i.e. can be called with ./file.sl instead of isis file.sl .

au BufWritePost,BufFilePost *.sl call system("chmod +x ".expand("%"))

Once again only for .sl files, when typing { it gets automatically replaced to {}; with proper indentation and putting the cursor at the correct position.

au BufNewFile,BufRead *.sl inoremap { {<CR>};<up><end><CR>

Escape command for the above remapping: when typing \{ it gets replaced to { and doesn't auto-complete to {};

au BufNewFile,BufRead *.sl inoremap \{ {}<left>

Useful for creating new .sl files from scratch: inputs whatever is in ~/.vim/templates/template.sl into the newly created file

au BufNewFile *.sl 0r ~/.vim/templates/template.sl


The file template.sl could look like this:

 1 #!/usr/bin/env isis
 2 
 3 require("isisscripts");
 4 require("tikz");                         


This page gets updated irregularly. Contact: Nico