-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.vim
More file actions
122 lines (92 loc) · 2.86 KB
/
basic.vim
File metadata and controls
122 lines (92 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
execute pathogen#infect()
syntax on
"filetype plugin indent on
""""""""""""""基本设置"""""""""
"文件在Vim之外修改过,自动重新读入
set autoread
"设置默认打开字符编码
set encoding=utf8
"设置tab的长度等于4个空格
set tabstop=4
"设置缩进长度
set sw=4
set autoindent
"命令行自动完成
set wildmenu
"设置选中之后按*和#就可以对选中的部分进行查找
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
"设置vim文件浏览
map <C-n> :NERDTreeToggle<CR>
"设置自动加载模板路径
let g:template_path = '~/.vimConfig/templates/'
"设置自动加载模板引用的参数
let g:t_author = 'zhuchao'
let g:t_email = 'zhuchao@ifchange.com'
let g:t_website = "www.ifchange.com"
"source ~/.vimConfig/syntax/javascript.vim
"""""""""""""样式""""""""""""""
"设置样式,这些样式都在color文件夹下,以下是我喜欢的几个,放这方便切换
"colorscheme tango
"colorscheme blink
colorscheme calmar256
"colorscheme xterm16
"设置搜索高亮显示
set hlsearch
"自动跳转到搜索的字符上
set incsearch
"设置读取文件的格式
set ffs=unix,dos
"记录上次位置
if has("autocmd")
" In text files, always limit the width of text to 78 characters
autocmd BufRead *.txt set tw=78
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif
endif
"""""""""符号和代码补全""""""""""""""
"html代码补全,使用Ctrl+_进行补全
source ~/.vimConfig/plugin/closetag.vim
"设置高亮宣示匹配的符号
set showmatch
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap < <><ESC>i
:inoremap > <c-r>=ClosePair('>')<CR>
"""""""""""""共用函数"""""""""""""""""
function! VisualSelection(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
function! ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endfunction
set encoding=UTF-8
set langmenu=zh_CN.UTF-8
language message zh_CN.UTF-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set fileencoding=utf-8