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

Revision 34539, 9.0 kB (checked in by kozo-ni, 4 years ago)

背景黒にした

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
198"nnoremap J jzz
199nnoremap K kzz
200noremap <CR> o<ESC>
201
202noremap <Leader><Leader> :e .<CR>
203
204" http://d.hatena.ne.jp/kozo-ni/20081028#1225205605
205nnoremap <silent> <C-p> :<C-u>execute '!' &l:filetype '%'<Return>
206
207" Use CTRL-L for Escape
208" http://twitter.com/emanon001/status/1022597622
209vnoremap <silent> <C-l> <Esc>
210inoremap <silent> <C-l> <Esc>
211cnoremap <silent> <C-l> <C-c>
212
213" Use CTRL-S for saving, also in Insert mode
214noremap <C-S>           :update<CR>
215vnoremap <C-S>          <C-C>:update<CR>
216inoremap <C-S>          <C-O>:update<CR>
217" http://whileimautomaton.net/2008/06/diary#d01-214900
218nnoremap <C-h> :<C-u>help<Space>
219nnoremap <C-h><C-h> :<C-u>help <C-r><C-w><Return>
220
221" http://lab.hde.co.jp/2009/02/vimpython.html
222noremap <F5> :!/usr/bin/python %<CR>
223noremap <F12> :!/usr/lib/python2.5/pdb.py %<CR>
224
225" http://my.opera.com/jacob7908/blog/index.dml/tag/VIM
226" pull full path name into paste buffer for attachment to email etc
227nnoremap <F2> :let @p=expand("%:p")<CR>
228
229" http://d.hatena.ne.jp/ns9tks/20081005/1223173570
230inoremap { {}<LEFT>
231inoremap [ []<LEFT>
232"inoremap ( ()<LEFT>
233"inoremap " ""<LEFT>
234noremap! <C-b> <Left>
235noremap! <C-f> <Right>
236noremap! <C-k> <Up>
237noremap! <C-j> <Down>
238noremap! <C-a> <Home>
239noremap! <C-e> <End>
240inoremap <silent> <expr> <C-e> (pumvisible() ? "\<C-e>" : "\<End>")
241noremap! <C-d> <Del>
242
243" azerty emulation
244" http://vim.wikia.com/index.php?title=Invert_the_number_row_keys_for_faster_typing
245" map each number to its shift-key character
246inoremap 1 !
247inoremap ! 1
248
249inoremap 2 ""<LEFT>
250inoremap " 2
251
252inoremap 3 #
253inoremap # 3
254
255inoremap 4 $
256inoremap $ 4
257noremap 4 $
258
259inoremap 5 %
260inoremap % 5
261
262inoremap 6 &
263inoremap & 6
264
265inoremap 7 ''<LEFT>
266inoremap ' 7
267
268inoremap 8 ()<LEFT>
269inoremap ( 8
270
271inoremap 9 )
272inoremap ) 9
273
274inoremap 0 ~
275inoremap ~ 0
276
277noremap - :
278"noremap : -
279
280" http://vim.g.hatena.ne.jp/ka-nacht/20090624
281noremap D d$
282
283" :h scroll-smooth
284map <C-U> <C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y>
285map <C-D> <C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E>
286
287" }}}
288
289" {{{ Generic highlight changes
290
291" http://d.hatena.ne.jp/tasukuchan/20070816/1187246177
292highlight WhitespaceEOL ctermbg=red guibg=red
293match WhitespaceEOL /\s\+$/
294autocmd WinEnter * match WhitespaceEOL /\s\+$/
295
296"highlight Comment cterm=none ctermfg=Gray
297"highlight IncSearch cterm=none ctermfg=Black ctermbg=DarkYellow
298"highlight Search cterm=none ctermfg=Black ctermbg=DarkYellow
299"highlight String cterm=none ctermfg=DarkGreen
300"highlight treeDir cterm=none ctermfg=Cyan
301"highlight treeUp cterm=none ctermfg=DarkYellow
302"highlight treeCWD cterm=none ctermfg=DarkYellow
303"highlight netrwDir cterm=none ctermfg=Cyan
304" }}}
305
306" {{{ Set up cscope options
307if has("cscope")
308        set csprg=/usr/bin/cscope
309        set csto=0
310        set cst
311        set nocsverb
312        cs add cscope.out
313        set csverb
314        map <C-_> :cstag <C-R>=expand("<cword>")<CR><CR>
315        map g<C-]> :cs find 3 <C-R>=expand("<cword>")<CR><CR>
316        map g<C-\> :cs find 0 <C-R>=expand("<cword>")<CR><CR>
317endif
318" }}}
319
320" {{{ plugin
321
322" FuzzyFinder
323" http://gist.github.com/raw/4656/bb1aca94bbb12c866bdab00531b539ecd80670de
324" http://vim.g.hatena.ne.jp/keyword/fuzzyfinder.vim
325
326nnoremap <silent> <C-n>      :FuzzyFinderBuffer<CR>
327nnoremap <silent> <C-j>      :FuzzyFinderMruFile<CR>
328nnoremap <silent> <C-k>      :FuzzyFinderMruCmd<CR>
329nnoremap <silent> <C-f><C-d> :FuzzyFinderDir<CR>
330nnoremap <silent> <C-b>      :FuzzyFinderBookmark<CR>
331nnoremap <silent> <C-f>b     :FuzzyFinderAddBookmark<CR>
332nnoremap <silent> <C-f><C-e> :FuzzyFinderEditInfo<CR>
333nnoremap <silent> <C-f><C-t> :FuzzyFinderTag!<CR>
334nnoremap <silent> <C-]> :FuzzyFinderTag! <C-r>=expand('<cword>')<CR><CR>
335noremap <silent> <F5> :FuzzyFinderFile<CR>
336
337" NERDTree
338" Increase window size to 35 columns
339let NERDTreeWinSize=35
340" map <F7> to toggle NERDTree window
341nmap <silent> <F7> :NERDTreeToggle<CR>
342
343" closetag
344"autocmd FileType html,xml,xsl source ~/.vim/scripts/closetag.vim
345" }}}
346
347" autocmd {{{
348" Go back to the position the cursor was on the last time this file was edited
349" This autocommand jumps to the last known position in a file just after
350" opening it, if the '" mark is set:
351" ref. eval.txt line3756
352autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
353
354" For all text files set 'textwidth' to 78 characters.
355autocmd FileType text setlocal textwidth=78
356
357autocmd FileType cvs :set fileencoding=euc-jp
358autocmd FileType svn :set fileencoding=uft-8
359
360autocmd FileType text setlocal spell spelllang=en_us
361
362autocmd BufNewFile *.{py,R,rb,php,txt,css,htm*}{,.in} set fileencoding=utf-8
363
364autocmd WinEnter * setlocal cursorline
365autocmd WinLeave * setlocal nocursorline
366
367autocmd FileType netrw nnoremap q :q<CR>
368
369" http://paranoid.dip.jp/kaworu/2008-06-07-1.html
370autocmd QuickfixCmdPost make,grep,grepadd,vimgrep copen
371" }}}
372
373" abbreviations {{{
374" :h type-mistakes
375ab teh the
376ab fro for
377" }}}
Note: See TracBrowser for help on using the browser.