Vim

Contents


Vim のインストール

$ sudo apt-get install vim

Vim の設定

~/.vimrc の設定 。
コマンドなど使い方は、下記のページが参考になった。
http://www.7key.jp/software/vi.html


:syntax on
set number
set cmdheight=2
set tabstop=2
set list
set listchars=tab:>-
set expandtab
set noautoindent
set shiftwidth=2
set expandtab
set fileformat=unix
set lcs=tab:>.,eol:$,trail:_,extends:\
set nocompatible
set runtimepath+=~/.vim/bundle/neobundle.vim/


highlight NonText guifg=blue
highlight JpSpace cterm=underline ctermfg=Blue guifg=Blue
au BufRead,BufNew * match JpSpace / /



if has('vim_starting')
  set runtimepath+=~/.vim/bundle/neobundle.vim/
  call neobundle#begin(expand('~/.vim/bundle/'))
endif

 set rtp+=~/.vim/vundle/
 call vundle#rc('~/.vim/bundle/')

NeoBundle 'Shougo/neocomplcache'
NeoBundle 'Shougo/neosnippet'
NeoBundle 'Shougo/neobundle.vim'
NeoBundle 'Shougo/neocomplcache.git'
NeoBundle 'Shougo/unite.vim.git'
NeoBundle 'Shougo/vimfiler.git'
NeoBundle 'Shougo/vimproc.git'
NeoBundle 'thinca/vim-quickrun'
NeoBundle 'h1mesuke/unite-outline.git'
NeoBundle 'kana/vim-smartchr.git'
NeoBundle 'kchmck/vim-coffee-script.git'
NeoBundle 'mattn/zencoding-vim.git'
NeoBundle 'motemen/hatena-vim.git'
NeoBundle 'othree/eregex.vim.git'
NeoBundle 'Shougo/neobundle.vim.git'
NeoBundle 'Shougo/vimshell.git'
NeoBundle 'thinca/vim-qfreplace.git'
NeoBundle 'thinca/vim-quickrun.git'
NeoBundle 'tsukkee/unite-tag.git'
NeoBundle 'ujihisa/shadow.vim.git'
NeoBundle 'vim-scripts/delphi.vim.git'
NeoBundle 'vim-scripts/JSON.vim.git'
NeoBundle 'vim-scripts/TwitVim.git'

call neobundle#end()

filetype plugin on
filetype indent on


"smatchr
autocmd Filetype sh inoremap  > smartchr#loop(' > ', ' >> ', '>')
autocmd Filetype sh inoremap  < smartchr#loop(' < ', ' << ', '<')
autocmd Filetype fortran inoremap  = smartchr#loop(' = ', ' == ', ' /= ', '=')
autocmd FileType fortran inoremap   > smartchr#one_of(' > ', ' >= ')
autocmd FileType fortran inoremap   < smartchr#one_of(' < ', ' <= ')
autocmd Filetype fortran inoremap  , smartchr#loop(', ', ',')
autocmd Filetype fortran inoremap  : smartchr#loop(':', ' :: ')
autocmd Filetype fortran inoremap  " smartchr#loop('""', '"')

autocmd Filetype python inoremap  = smartchr#loop(' = ', ' == ', ' != ', '=')
autocmd Filetype python inoremap  , smartchr#loop(', ', ',')
autocmd Filetype python inoremap  " smartchr#loop('""', '"')
autocmd Filetype python inoremap  + smartchr#loop(' + ', '+')
autocmd Filetype python inoremap  < smartchr#loop(' < ', ' <= ', '<')
autocmd Filetype python inoremap  > smartchr#loop(' > ', ' >= ', '>')

" Directory of Snippet
let g:neosnippet#snippets_directory='~/.vim/bundle/snipmate-snippets/snippets, ~/lib/snippets'

inoremap   pumvisible() ? "\" : "\"

" Plugin key-mappings.
imap      (neosnippet_expand_or_jump)
smap      (neosnippet_expand_or_jump)

" SuperTab like snippets behavior.
imap  neosnippet#expandable()  neosnippet#jumpable() ? "\(neosnippet_expand_or_jump)" : pumvisible() ? "\" : "\"
smap  neosnippet#expandable()  neosnippet#jumpable() ? "\(neosnippet_expand_or_jump)" : "\"


" For snippet_complete marker.
if has('conceal')
  set conceallevel=2 concealcursor=i
endif

" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 1
" Use underbar completion.
let g:neocomplcache_enable_underbar_completion = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'

" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Use camel case completion.
let g:neocomplcache_enable_camel_case_completion = 1
" Select with 
inoremap  pumvisible() ? "\" : "\"

let g:neocomplcache_ctags_arguments_list = {
    \ 'perl' : '-R -h ".pm"'
    \ }

let g:neocomplcache_dictionary_filetype_lists = {
    \ 'default'    : '',
    \ 'perl'       : $HOME . '/.vim/dict/perl.dict',
    \ 'fortran'    : $HOME . '/.vim/dict/fortran.dict'
    \ }

" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
  let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'

                  

NeoBundle のインストール

$ mkdir -p ~/.vim
$ cd ~/.vim
$ git clone git://github.com/Shougo/neobundle.vim.git ~/.vim
$ cp -r neobundle/* ./

.vimrc をコピーした後、":NeoBundleInstall" と打つと、インストールされる。

参考: http://d.hatena.ne.jp/sasaplus1/20111023/1319298810


smartchrのインストール

$ cd .vim/bundle/
$ git clone https://github.com/kana/vim-smartchr.git

.vimrc に以下を追加。

autocmd FileType fortran inoremap   = smartchr#one_of( ' = ', ' == ', '=')

Vimを起動してf90のファイルを開いて"="を入力すると、" = " が入力される。2回連続で"="とすると" == "と入力される。

参考HP:http://d.hatena.ne.jp/sasaplus1/20110623/1308795489


snippet

.vimrc を ~/ に保存してプラグインをインストール。snippets のディレクトリ下に fortran.snip を保存して、あとはガリガリ書き込む。