root/dotfiles/vim/kozo-ni/.vimrc @ 30890

Revision 30890, 8.2 kB (checked in by kozo-ni, 4 years ago)

added ns9tks sharakusee

Line 
1" {{{ fundamentals
2
3" Use Vim settings, rather then Vi settings (much better!).
4" This must be first, because it changes other options as a side effect.
5set nocompatible
6
7" Enable loading filetype and indentation plugins
8filetype plugin indent on
9
10" Turn syntax highlighting on
11syntax on
12
13" for gist.vim
14"source $HOME/.vimProfile
15" }}}
16
17" {{{ set for edit
18
19" Allow backspacing over everything in insert mode
20set backspace=indent,eol,start
21
22" Enable CTRL-A/CTRL-X to work on octal and hex numbers, as well as characters
23set nrformats=octal,hex,alpha
24
25" Use F8 to toggle 'paste' mode
26set pastetoggle=<F8>
27
28set formatoptions+=mM
29" }}}
30
31" {{{ set for completion
32
33" Remember up to 100 'colon' commmands and search patterns
34set history=100
35
36" Insert mode completion options
37set completeopt=menu,longest,preview
38
39" Use menu to show command-line completion (in 'full' case)
40set wildmenu
41
42" http://d.hatena.ne.jp/ns9tks/20080603/1212500562
43" Set command-line completion mode:
44"   - on first <Tab>, when more than one match, list all matches and complete
45"     the longest common  string
46"   - on second <Tab>, complete the next full match and show menu
47set wildmode=list:longest,full
48
49" Remember things between sessions
50"
51" '20  - remember marks for 20 previous files
52" \"50 - save 50 lines for each register
53" :20  - remember 20 items in command-line history
54" %    - remember the buffer list (if vim started without a file arg)
55" n    - set name of viminfo file
56set viminfo='20,\"50,:20,%,n~/.viminfo
57" }}}
58
59" {{{ set for display
60
61" Use UTF-8 as the default buffer encoding
62set enc=utf-8
63
64" http://omake.accense.com/wiki/vimrc
65set fileencodings=utf-8,cp932,euc-jp
66set ambiwidth=double
67set foldmethod=marker
68
69set nonumber
70
71" Show line, column number, and relative position within a file in the status line
72set ruler
73
74" Scroll when cursor gets within 3 characters of top/bottom edge
75set scrolloff=3
76
77set nolist
78set wrap
79
80" Don't wrap words by default
81set textwidth=0
82
83" Always show status line, even for one window
84set laststatus=2
85
86set cmdheight=2
87
88" Show (partial) commands (or size of selection in Visual mode) in the status line
89set showcmd
90
91" When a bracket is inserted, briefly jump to a matching one
92set showmatch
93
94" Jump to matching bracket for 2/10th of a second (works with showmatch)
95set matchtime=2
96
97set splitbelow
98set splitright
99set title
100set background=dark
101set statusline=%F%m%r%h%w\ [%{&fileencoding}\ %{&fileformat}]\ [TYPE=%Y]\ [%l/%L,\ %c]
102" set statusline=%<%f\ %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%l,%c%V%8P
103setlocal cursorline
104" }}}
105
106" {{{ set for tab
107
108" http://d.hatena.ne.jp/amachang/20081019/1224365794
109" Use 4 spaces for (auto)indent
110set shiftwidth=4
111
112" Use 4 spaces for <Tab> and :retab
113set tabstop=4
114
115set softtabstop=0
116set smartindent
117set expandtab
118set smarttab
119set autoindent
120
121" Round indent to multiple of 'shiftwidth' for > and < commands
122set shiftround
123" }}}
124
125" {{{ set for search
126
127" Don't highlight results of a search
128set nohlsearch
129
130" Enable incremental search
131set incsearch
132
133set ignorecase
134set smartcase
135set wrapscan
136
137" }}}
138
139" {{{ set for file manipulation
140
141" Write contents of the file, if it has been modified, on buffer exit
142set autowrite
143
144" Write swap file to disk after every 50 characters
145set updatecount=50
146set updatetime=500
147
148set autoread
149set nobackup
150set noswapfile
151
152" http://vimpi.net/user/dubhead
153set autochdir
154set backupdir=~/.Trash,.,~/
155set hidden
156" }}}
157
158" {{{ expression-commands
159
160" netRW: Open files in a split window
161"let g:netrw_browse_split = 1
162let mapleader = ","
163
164" }}}
165
166" {{{ mappings
167
168" save changes
169noremap ,s :w<CR>
170
171" exit vim without saving any changes
172noremap ,q :q!<CR>
173
174" exit vim saving changes
175noremap ,w :x<CR>
176
177" switch to upper/lower window quickly
178noremap <C-J> <C-W>j
179noremap <C-K> <C-W>k
180
181" map ,f to display all lines with keyword under cursor and ask which one to
182" jump to
183nnoremap ,f [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
184
185" use <F6> to toggle line numbers
186nnoremap <silent> <F6> :set number!<CR>
187
188" open filename under cursor in a new window (use current file's working
189" directory)
190nnoremap gf :new %:p:h/<cfile><CR>
191" map <Alt-p> and <Alt-P> to paste below/above and reformat
192nnoremap <Esc>P  P'[v']=
193nnoremap <Esc>p  p'[v']=
194" visual shifting (does not exit Visual mode)
195vnoremap < <gv
196vnoremap > >gv
197" http://blog.blueblack.net/item_317
198nnoremap J jzz
199nnoremap K kzz
200noremap <CR> o<ESC>
201
202noremap <Leader><Leader> :e .<CR>
203
204noremap - :
205"noremap : -
206" http://d.hatena.ne.jp/kozo-ni/20081028#1225205605
207nnoremap <silent> <C-p> :<C-u>execute '!' &l:filetype '%'<Return>
208
209" Use CTRL-L for Escape
210" http://twitter.com/emanon001/status/1022597622
211vnoremap <silent> <C-l> <Esc>
212inoremap <silent> <C-l> <Esc>
213cnoremap <silent> <C-l> <C-c>
214
215" Use CTRL-S for saving, also in Insert mode
216noremap <C-S>           :update<CR>
217vnoremap <C-S>          <C-C>:update<CR>
218inoremap <C-S>          <C-O>:update<CR>
219" http://whileimautomaton.net/2008/06/diary#d01-214900
220nnoremap <C-h> :<C-u>help<Space>
221nnoremap <C-h><C-h> :<C-u>help <C-r><C-w><Return>
222
223" http://lab.hde.co.jp/2009/02/vimpython.html
224noremap <F5> :!/usr/bin/python %<CR>
225noremap <F12> :!/usr/lib/python2.5/pdb.py %<CR>
226
227" http://my.opera.com/jacob7908/blog/index.dml/tag/VIM
228" pull full path name into paste buffer for attachment to email etc
229nnoremap <F2> :let @p=expand("%:p")<CR>
230
231" http://d.hatena.ne.jp/ns9tks/20081005/1223173570
232inoremap { {}<LEFT>
233inoremap [ []<LEFT>
234inoremap ( ()<LEFT>
235inoremap " ""<LEFT>
236noremap! <C-b> <Left>
237noremap! <C-f> <Right>
238noremap! <C-k> <Up>
239noremap! <C-j> <Down>
240noremap! <C-a> <Home>
241noremap! <C-e> <End>
242inoremap <silent> <expr> <C-e> (pumvisible() ? "\<C-e>" : "\<End>")
243noremap! <C-d> <Del>
244
245" }}}
246
247" {{{ Generic highlight changes
248
249" http://d.hatena.ne.jp/tasukuchan/20070816/1187246177
250highlight WhitespaceEOL ctermbg=red guibg=red
251match WhitespaceEOL /\s\+$/
252autocmd WinEnter * match WhitespaceEOL /\s\+$/
253
254"highlight Comment cterm=none ctermfg=Gray
255"highlight IncSearch cterm=none ctermfg=Black ctermbg=DarkYellow
256"highlight Search cterm=none ctermfg=Black ctermbg=DarkYellow
257"highlight String cterm=none ctermfg=DarkGreen
258"highlight treeDir cterm=none ctermfg=Cyan
259"highlight treeUp cterm=none ctermfg=DarkYellow
260"highlight treeCWD cterm=none ctermfg=DarkYellow
261"highlight netrwDir cterm=none ctermfg=Cyan
262" }}}
263
264" {{{ Set up cscope options
265if has("cscope")
266        set csprg=/usr/bin/cscope
267        set csto=0
268        set cst
269        set nocsverb
270        cs add cscope.out
271        set csverb
272        map <C-_> :cstag <C-R>=expand("<cword>")<CR><CR>
273        map g<C-]> :cs find 3 <C-R>=expand("<cword>")<CR><CR>
274        map g<C-\> :cs find 0 <C-R>=expand("<cword>")<CR><CR>
275endif
276" }}}
277
278" {{{ plugin
279
280" FuzzyFinder
281" http://gist.github.com/raw/4656/bb1aca94bbb12c866bdab00531b539ecd80670de
282" http://vim.g.hatena.ne.jp/keyword/fuzzyfinder.vim
283
284nnoremap <silent> <C-n>      :FuzzyFinderBuffer<CR>
285nnoremap <silent> <C-j>      :FuzzyFinderMruFile<CR>
286nnoremap <silent> <C-k>      :FuzzyFinderMruCmd<CR>
287nnoremap <silent> <C-f><C-d> :FuzzyFinderDir<CR>
288nnoremap <silent> <C-b>      :FuzzyFinderBookmark<CR>
289nnoremap <silent> <C-f>b     :FuzzyFinderAddBookmark<CR>
290nnoremap <silent> <C-f><C-e> :FuzzyFinderEditInfo<CR>
291nnoremap <silent> <C-f><C-t> :FuzzyFinderTag!<CR>
292nnoremap <silent> <C-]> :FuzzyFinderTag! <C-r>=expand('<cword>')<CR><CR>
293noremap <silent> <F5> :FuzzyFinderFile<CR>
294
295" NERDTree
296" Increase window size to 35 columns
297let NERDTreeWinSize=35
298" map <F7> to toggle NERDTree window
299nmap <silent> <F7> :NERDTreeToggle<CR>
300
301" closetag
302"autocmd FileType html,xml,xsl source ~/.vim/scripts/closetag.vim
303" }}}
304
305" autocmd {{{
306" Go back to the position the cursor was on the last time this file was edited
307" This autocommand jumps to the last known position in a file just after
308" opening it, if the '" mark is set:
309" ref. eval.txt line3756
310autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
311
312" For all text files set 'textwidth' to 78 characters.
313autocmd FileType text setlocal textwidth=78
314
315autocmd FileType cvs :set fileencoding=euc-jp
316autocmd FileType svn :set fileencoding=uft-8
317
318autocmd FileType text setlocal spell spelllang=en_us
319
320autocmd BufNewFile *.{py,R,rb,php,txt,css,htm*}{,.in} set fileencoding=utf-8
321
322autocmd WinEnter * setlocal cursorline
323autocmd WinLeave * setlocal nocursorline
324
325" http://paranoid.dip.jp/kaworu/2008-06-07-1.html
326autocmd QuickfixCmdPost make,grep,grepadd,vimgrep copen
327" }}}
Note: See TracBrowser for help on using the browser.