显示标签为“vim”的博文。显示所有博文
显示标签为“vim”的博文。显示所有博文

2012年11月12日星期一

Auto indent for fortran (.f90) in Vim

1. Download fortran.vim (v 0.3.1) and copy it to  $HOME\Vim\vimfiles\indent for Windows.

2. Revise the fortran.vim
 
   Revise the lines 19,20,57 and 61 as:


19 setlocal indentkeys+==~subroutine,=~function,=~forall,=~program,=~module

20 setlocal indentkeys+==~endsubroutine,=~endfunction,=~endforall,=~endprogram,=~endmodule

57 if line =~? '^\s*\(pure\|elemental\)\=\s*\(subroutine\|function\|program\|module\)' ||
\ line =~? '^\s*\(forall\)'

61 if getline(v:lnum) =~? '^\s*end\s*\(subroutine\|function\|forall\|program\|module\)'

   save it.

3. Create a .f90 source file and test the auto-indent for "program/function/module/subroutine", "do-loop" and "if-else".


You do not need to add any content in the _vimrc (or .vimrc) file. 




2012年11月2日星期五

gVim install in Ubuntu 12.10

Install gvim in Terminal
1. Install mercruial for supporting to clone vim (hg clone https://vim.googlecode.com/hg/ vim)
    sudo apt-get install mercurial

2. check dependence and install library if any, for example  'ncurses'
    ./configure
    sudo apt-get install libncurses5-dev

3. clone and make
  (you can alternatively find and install the gVim in Ubuntu software center)
    hg clone https://vim.googlecode.com/hg/ vim
    sudo make distclean (clean)
    sudo apt-get updata  (update system file)
    cd vim/src
    sudo make 
    sudo make install
    export PATH=$PATH:{~/vim}

4. install vim configuration (spf13)
    sudo apt-get install git
    curl http://j.mp/spf13-vim3 -L -o - | sh
 

vim的源码安装与配置文件的设定 (转载)

vim的源码安装与配置文件的设定 - smallmickey - 博客园:
vim的源码安装与配置文件的设定
安装篇
1.必要性
自vim版本升级后,原来的完全安装模式不见了,即sudo apt-get install vim-full 这一过渡模式退出历史舞台了,要使用vim的全部功能最好源码安装;
2.大体步骤
从http://www.vim.org/sources.php下载相应源码文件,利用tar -jxvf 命令解压到当前用户目录,即~;

解压后进入vim的src目录,首先执行sudo make distclean(清理以前编译生成的文件);

更新系统软件源,即运行 sudo apt-get updata
接着运行configure文件,即./configure,检查安装所需的依赖环境是否完善,若缺失某些文件则根据运行结果进行安装,如缺少库文件ncurses,则运行命令 sudo apt-get install libncurses5-dev;
最后执行sudo make 和 sudo make install 。

配置篇

1.两类配置文件的优先级
vim的配置文件分为全局和局部,而局部配置文件的优先级高于全局文件,换句话说就是我们之需要修改局部配置文件即可。

2.配置文件的位置
全局(系统)配置文件 “/etc/vim/vimrc”
局部(用户)配置文件 “$HOME/.vimrc”


3.配置

参考网上各种vimrc的文件内容复写到用户目录的.vimrc文件(若没有则touch一个新的空文件.vimrc);或者将现有的.vimrc文件拷贝到用户目录下覆盖即可。

2012年10月31日星期三

gVim 64位 Windows 7 安装过程 (使用spf13配置)

64bit Windows 7 安装 gVim 7.3 (gvim73_46.exe) 并使用spf13-vim配置,过程如下:

1. 下载并安装gvim73_46.exe, 本文采用路径为:C:\Users\(your user name here)\Vim

2. spf13-vim是利用Vundle管理的一套Vim配置脚本,集成了很多流行的插件。可以用来方便地配置安装在Linux,Mac和Windows系统下面的Vim。为了下载并使用spf13的配置文件,首先需要安装msysgit (本文使用版本为Git-1.8.0-preview20121022), 该版本已经捆绑了Curl;验证git和curl是否安装成功,如果出现以下信息,表示OK。









虽然curl安装成功,但是为了能够让git正常使用curl,按照spf13的提示,需要新建一个curl.cmd 文件并复制到C:\Program Files\Git\cmd\curl.cmd。该文件内容如下:


@rem Do not use "echo off" to not affect any child calls.
@setlocal

@rem Get the abolute path to the parent directory, which is assumed to be the
@rem Git installation root.
@for /F "delims=" %%I in ("%~dp0..") do @set git_install_root=%%~fI
@set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%PATH%

@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%

@curl.exe %*
这样运行gVim时,就不会出现gist无法使用curl的错误提示。


3. 下载并运行spf13-vim 的 spf13-vim-windows-install.cmd。注意,必须以管理员权限运行,否则无法建立配置文件与原版配置文件的链接。

4. 在路径C:\Users\(your user name here)\ 下新建 ~/.vimrc.local 和 ~/.gvimrc.local 做本地个性化配置。 例如,在.vimrc.local文件中输入 colorscheme molokai 可以用molokai代替缺省的颜色主题。更多的个性化配置和插件说明可以参考spf13-vim。

5. 为了使用Tagbar插件,需要安装生成索引文件的Exuberant Ctags(ctags58.zip)。解压并复制ctags.exe到windows/system32/. 验证是否成功如下图所示:







更多在Vim中使用ctags的信息请参考Tagbar和Exuberant Ctags。

PS. spf13的gVim MacVim配置文件备受推崇,号称最完美的vim配置文件。但是里面插件种类比较多,不一定每个都会用到;有些操作习惯也并不是受每个人的欢迎。尤其是对我这种基本上只用fortran做数值计算的人来说,很多功能都浪费了。