Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts

Aug 30, 2012

VIM for Mathematica


The very first thing to do is a Mathematica Syntax File : Syntax highlighting file for Mathematica code and a Mathematica Indent File : Indentation file for Mathematica code.

There is one more trouble, both Mathematica and Matlab use .m file extensions, so if you are editing Mathematica .m files, you need to either manually :set ft=mma or edit your filetype.vim file.
au! BufRead,BufNewFile *.m set ft=mma sw=2

Jul 31, 2012

vim for FORTRAN


This page contains useful configuration of vim for FORTRAN.

I summarize several useful configurations:
  • style of source file (the default is fixed style):
:let fortran_free_source=1
:let fortran_fixed_source=1
add them prior to the :syntax on command
if you want to switch between free style and fixed style, add the following lines:

nmap <S-F> :set syntax=fortran<CR>:let b:fortran_fixed_source=!b:fortran_fixed_source<CR>:set syntax=text<CR>:set syntax=fortran<CR>
nmap <C-F> :filetype detect<CR>

  • enable Tabs in FORTRAN (otherwise they are marked as ugly red blocks):
:let fortran_have_tabs=1
  • code folding:
" :za toggle code folding
" :zr (zR) open all
" :zm (zM) close all
" :zc close
" :zo open

set foldmethod=indent
set foldnestmax=10
set nofoldenable " no fold by default
set foldlevel=1   " some value I don't know...
" code folding for fortran
:let fortran_fold=1
:let fortran_fold_conditionals=1
:let fortran_fold_multilinecomments=1
  • an enhanced vim script for FORTRAN 2003 keywords, can be found here.
  • block comments
this plugin supports block comments for FORTRAN and others.
description:
Global Plugin to comment and un-comment lines in different source files in both normal and visual mode
usage:
ctrl-c to comment a single line ctrl-x to un-comment a single line
shift-v and select multiple lines, then ctrl-c to comment the selected multiple lines
shift-v and select multiple lines, then ctrl-x to un-comment the selected multiple lines
supports:
c, c++, java, php[2345], proc, css, html, htm, xml, xhtml, vim, vimrc, sql, sh, ksh, csh, perl, tex, fortran, ml, caml, ocaml, vhdl, haskel and normal files