Difference between revisions of "VIM setup for ISIS"

From Remeis-Wiki
Jump to navigation Jump to search
(Created page with "Listed below are a few useful VIM shortcuts for the use of ISIS. The shortcuts need to be added to the .vimrc file in order to work. ''' General useful commands:''' Use jk...")
 
Line 1: Line 1:
 
Listed below are a few useful VIM shortcuts for the use of ISIS. The shortcuts need to be added to the .vimrc file in order to work.
 
Listed below are a few useful VIM shortcuts for the use of ISIS. The shortcuts need to be added to the .vimrc file in order to work.
  
 +
'''Warning: Only use comments which you understand. Some of the below commands execute shell commands which have the potential to do things you don't want to do!'''
  
''' General useful commands:'''
+
 
 +
==General useful commands ==
  
 
Use jk instead of <ESC> to exit insert mode:
 
Use jk instead of <ESC> to exit insert mode:
 +
 
<code>inoremap jk <ESC> </code>
 
<code>inoremap jk <ESC> </code>
  
 
Turn on syntax highlighting:
 
Turn on syntax highlighting:
 +
 
<code> syntax on</code>
 
<code> syntax on</code>
  
 
Turn on line number displaying:
 
Turn on line number displaying:
 +
 
<code>set number </code>
 
<code>set number </code>
  
 
Highlight all search results when searching through code:
 
Highlight all search results when searching through code:
 +
 
<code>set hlsearch </code>
 
<code>set hlsearch </code>
  
 
Personal choice: ignore case when searching
 
Personal choice: ignore case when searching
 +
 
<code>set ignorecase </code>
 
<code>set ignorecase </code>
  
Also show search results already while typing:
+
Also show search results already while typing
 +
 
 
<code> set incsearch</code>
 
<code> set incsearch</code>
  
 
Automatically copy current indentation to newlines
 
Automatically copy current indentation to newlines
 +
 
<code>set autoindent </code>
 
<code>set autoindent </code>
  
 +
Allows backspace key to remove auto-indentation (see above command), characters left to the cursor and newline characters
 +
 +
<code>  set backspace=indent,eol,start</code>
 +
 +
Display the cursor position in the lower right corner
 +
 +
<code> set ruler</code>
 +
 +
Show partial commands entered in the lower right corner (e.g. <code> 10dd </code> for deleting the next 10 lines would be displayed as you type it)
 +
 +
<code> set showcmd </code>
 +
 +
 +
== ISIS specific settings ==
 +
 +
This creates a specific command :RunIsis, which executes isis ./{filename} in the command line. Very useful for executing scripts directly from VIM.
 +
 +
<code> command! RunIsis :execute '!isis ./' . expand('%:t') </code>
 +
 +
When writing a .sl file to the disk (e.g. using :w), the file is automatically made executable, i.e. can be called with <code> ./file.sl </code> instead of <code> isis file.sl </code>.
 +
 +
<code> au BufWritePost,BufFilePost *.sl call system("chmod +x ".expand("%")) </code>
 +
 +
Once again only for .sl files, when typing { it gets automatically replaced to {}; with proper indentation and putting the cursor at the correct position.
 +
 +
<code> au BufNewFile,BufRead *.sl inoremap { {<CR>};<up><end><CR> </code>
 +
 +
Escape command for the above remapping: when typing \{ it gets replaced to { and doesn't auto-complete to {};
 +
 +
<code> au BufNewFile,BufRead *.sl inoremap \{ {}<left> </code>
 +
 +
Useful for creating new .sl files from scratch: inputs whatever is in template.sl into the newly created file
 +
 +
<code>  au BufNewFile *.sl 0r ~/.vim/templates/template.sl </code>
  
 +
The file <code> template.sl</code> ''could'' look like this:
  
''' ISIS specific settings:'''
+
  1 #!/usr/bin/env isis
 +
  2
 +
  3 require("isisscripts");
 +
  4 require("tikz");                       
  
<code> </code>
 
<code> </code>
 
<code> </code>
 
<code> </code>
 
  
 +
This page gets updated irregularly.. questions go here: [mailto:nicolas.zalot@fau.de Nico]
  
 
[[Category:Isis / Slang]]
 
[[Category:Isis / Slang]]

Revision as of 09:50, 9 February 2024

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

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


General useful commands

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} in 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 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.. questions go here: Nico