VIM ~/.vimrc 最小限の設定¶
" vi互換を行わない set nocompatible " Vim の組み込みプラグインを使う filetype plugin on本当に最小限なら上記の2行(コメント除く)になるが… 実質日常の作業では下記が必要(あくまで個人的に) " BackSpace キーで削除できるものを設定(ArchLinux ではデフォで下記の通り。FreeBSD 用に明示) set backspace=indent,eol,start set iskeyword+=: set shell=/bin/zsh set number " 行番号を各行頭に表示(:set nonu で非表示) set smartindent set ruler " カーソル位置の行番号と桁番号を画面右下に表示 set incsearch " 検索パターンの文字をタイプする毎にカーソルがファイル中を移動&ハイライト set hlsearch " 最後の検索パターンにマッチする全ての箇所をハイライトする(:noh でハイライトオフ) set showmode " 現在のモードをステータス行に表示 set encoding=utf-8 set fileencoding=utf-8 set fileformat=unix " CGI を Perl で書くとは限らないので下記はコメントアウト "au BufReadPost,BufNewFile *.cgi :setl filetype=perl au BufReadPost,BufNewFile *.jq :setl filetype=javascript au BufReadPost,BufNewFile *.make :setl filetype=make " タブ文字関連 set tabstop=4 set softtabstop=4 set shiftwidth=4 " タブ文字をスペースに展開する。 set expandtab " ただし、ファイル名(basename)が「Makefile」か拡張子が「makefile|tsv|txt」だったらタブ文字をスペースに展開しない。 au BufReadPost,BufNewFile *akefile :setl noexpandtab au BufReadPost,BufNewFile *.make :setl noexpandtab au BufReadPost,BufNewFile *.tsv :setl noexpandtab au BufReadPost,BufNewFile *.txt :setl noexpandtab " 文字幅が曖昧な文字に対応 set ambiwidth=double " 不可視文字を可視化(タブが「» 」と表示される:hi SpecialKey で目立たない色にする) " ISO 8859-1(a.k.a Latin-1) 273 187 BB » RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK set list listchars=tab:\»\ " ※ セットする文字の2文字目はエスケープされた半角スペースである " ※ set ambiwidth=double をセットしないと「※」などの文字が正常に表示されないが、 " list listchars= には全角文字を設定できなくなる(「矛盾した設定」というエラーで怒られる) " show TAB bar :h tab-page set showtabline=2自分的に最小限と思っているのはここまで。
以下は好みの問題。
単に " color setting " 256 colors chart http://misc.flogisoft.com/bash/tip_colors_and_formatting#colors1 " gui colors chart https://codeyarns.com/2011/07/29/vim-chart-of-color-names/ set t_Co=256 syntax on set background=light colorscheme default hi Todo ctermfg=7 ctermbg=0 guifg=white guibg=black hi Comment term=none cterm=none ctermfg=94 gui=none guifg=PeachPuff4 hi LineNr term=none cterm=none ctermfg=8 gui=none guifg=gray50 hi SpecialKey term=none cterm=none ctermfg=187 gui=none guifg=snow3 hi Identifier term=bold cterm=none ctermfg=59 gui=bold guifg=black hi Include cterm=none ctermfg=238 gui=bold guifg=black hi Type cterm=none ctermfg=235 gui=bold guifg=black hi PreProc cterm=none ctermfg=232 gui=bold guifg=gray40 hi Special cterm=none ctermfg=17 gui=none guifg=MidnightBlue hi Statement cterm=none ctermfg=17 gui=bold guifg=gray38 hi Constant cterm=none ctermfg=18 gui=none guifg=gray50 hi String cterm=none ctermfg=0 gui=none guifg=black hi Search ctermfg=255 ctermbg=0 guifg=white guibg=black hi Cursor ctermbg=214 ctermfg=0 guibg=orange guifg=black hi link Function Statement " make のデフォだとコマンド行全てがハイライトされてしまうので下記で回避 hi link makeCommands Normal " $$ や $@ などの調節 hi makeIdent cterm=none ctermfg=0 " default: Visual term=reverse ctermbg=7 guibg=LightGrey これだとグレーバックの状態で選択されてるのか分からないので下記に hi Visual term=reverse cterm=reverse gui=reverse話が前後するが、上記の色設定の前提として、ターミナル自体の色設定を下記のようにしている。 ターミナルエミュレータはmltermで、設定ファイルは ~/.mlterm/color
black=#000000 hl_black=#7f7f7f red=#440000 hl_red=#880000 green=#004400 hl_green=#008800 yellow=#444400 hl_yellow=#888800 blue=#000044 hl_blue=#000088 magenta=#440044 hl_magenta=#880088 cyan=#004444 hl_cyan=#008888 #white=#fefefe white=#f3f3f3 hl_white=#ffffff
Ctrlキーとの組み合わせを使ったキーバインド " コマンドライン履歴をたどるとき、C-p, C-n の動作をUp, Downと同じにする(「実践Vim」p.102) cnoremap <C-p> <Up> cnoremap <C-n> <Down> " インサートモードの C-f, C-b はもともと割当がないので、Emacs と同様にする。 inoremap <C-f> <right> inoremap <C-b> <left> " インサートモードで C-d を DELETE に inoremap <C-d> <C-o>x
ユーザ定義用にあらかじめ用意されている Leader キーを " 参考: http://postd.cc/how-to-boost-your-vim-productivity/ let mapleader = "\<Space>" " <Space>w を押してファイルを保存する nnoremap <Leader>w :w<CR> " <Space>x -> :x nnoremap <Leader>x :x<CR> " <Space>e -> :tabe (待ち受け状態) nnoremap <Leader>e :tabe<Space> " <Space>n -> :noh nnoremap <Leader>n :noh<CR> " <Leader>Space でコマンドラインモード nnoremap <leader><Space> : vnoremap <leader><Space> :
HTMLを書くときに使ってるショートカット ab __table <table><NL><tr><NL><td></td><NL></tr><NL></table> ab __ol <ol><NL><li></li><NL><li></li><NL><li></li><NL></ol> ab __ul <ul><NL><li></li><NL><li></li><NL><li></li><NL></ul> ab __a <a href=""></a> ab __pre <pre><NL><NL><NL><NL></pre> ab __bq <blockquote><NL><NL><NL></blockquote> ab __\ \ ab __center <div align="center"></div>
自分の場合は上記までを主に使用してる環境(ArchLinux、Mac、FreeBSD)で共通にしいる。 で、各環境ごとに個別の設定は別ファイルから読み込む。 ~/.vimrcには下記の1行を記載。 " ArchLinuxの場合 " localな設定を各環境の~/.vim/local.vimから読み込む " ArchLinux " fcitx-skk 関連 " <Leader>c クリップボードにコピー " <Leader>v クリップボードからペースト so ~/.vim/local.vimその上で、~/.vim/local.vimに下記の内容を記載。 " ArchLinuxの場合 " fcitx-skk 関連 " Esc 時に fcitx-remote -c を実行 " set imdisable は fcitx-skk では効果無し " http://qiita.com/hoshitocat/items/a80d613ef73b7a06ec50 function! ImInActivate() call system('fcitx-remote -c >/dev/null 2>&1') endfunction inoremap <silent> <C-[> <ESC>:call ImInActivate()<CR> " <Leader>c でヴィジュアルモードで選択した範囲をクリップボードにコピーする vnoremap <silent> <Leader>c :write !xclip -selection clipboard<CR><CR> " <Leader>v でカレント行の下にクリップボードの内容をペーストする nnoremap <silent> <Leader>v :read !xclip -selection clipboard -o<CR>
おまけ .gvimrc " Vim の基本に関係する部分は通常通り .vimrc から読み込む " .gvimrc には GUI に関係する内容だけ書く " " カーソル行をハイライト(イマイチ趣味じゃなかったので使用しない) " " set cursorline " GUI でもマウスをオフ set mouse= " hide Toolbar set guioptions-=T " hide menu bar set guioptions-=m " GUI のときはターミナルのキーバインドとバッティングする心配がないので " C-tab をタブの切り替え(gt)にmapする nnoremap <C-tab> gt inoremap <C-tab> <C-o>gt " GUI font set guifont=Myrica\ M\ 12
Last modified: 2017-01-05 | ||
|
||
|
||
© Shin Nakamura/BasicWerk 2008 - 2024 |