-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc_windows
135 lines (128 loc) · 3.29 KB
/
vimrc_windows
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
123
124
125
126
127
128
129
130
131
132
133
134
135
"---General---
"Backspace is on
set bs=2
"Enable syntax highlighting
syn on
"Always show the status line
set laststatus=2
"Custom Status line
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]
"Set Font
if has('gui_running')
set guifont=Consolas:h9:cANSI
endif
"Enable Autoreload
set autoread
"Search along while typing
set incsearch
"Case insensitive, but if searching with case then revert to case sensitive
set ignorecase
set smartcase
"Highlight search term, toggle with a key binding
set hlsearch!
"Show the mode
set showmode
"Show matching braces
set showmatch
"Show line number
set number
"Solarized color scheme
"set background=light
colorscheme desert
"Indent new lines based on previous line
set autoindent
"Try to determine file type based on name and contents
filetype indent plugin on
"Do not retain buffers after closing tab
set nohidden
"Better command-line completion
set wildmenu
"Fold method
set foldmethod=indent
"Spell check
map <F8> :set spell!<CR>
set spell spelllang=en
set spellfile=~/_spellfile.add
highlight clear SpellBad
highlight SpellBad term=standout guibg=#ffffff guifg=#000000
set nospell!
"Remove toolbar
set guioptions-=T
"---Plugins---
"Plugins list
"NERDTree, CtrlP, Solarized color scheme
"NERDTree
"Map to show/close
map <C-S-n> :NERDTreeToggle<CR>
"CtrlP
"Map ctrlp show
let g:ctrlp_map = '<c-p>'
"Default to reg ex based search
let g:ctrlp_regexp = 1
"Do not change working directory based on open buffer
let g:ctrlp_working_path_mode = 0
"---Custom key bindings---
"Create new tab
map <C-S-t> :tabnew<CR>
"Toggle text wrapping
map <F5> :set wrap!<CR>
"Toggle search highlight
nnoremap <F3> :set hlsearch!<CR>
"Call user defined function list
map <F7> :call UserDefinedCalls()<CR>
"Navigate Splits
nmap <silent> <A-Up> :wincmd k<CR>
nmap <silent> <A-Down> :wincmd j<CR>
nmap <silent> <A-Left> :wincmd h<CR>
nmap <silent> <A-Right> :wincmd l<CR>
"---Custom functions---
"Main function to call individual user defined functions
function! UserDefinedCalls()
let l:opt = input("SearchAndReplace: 1\nCopy: 2\nFileFormat: 3\n:")
if l:opt == 1
call SearchAndReplace()
elseif l:opt == 2
call Copy()
elseif l:opt == 3
call FileFormat()
endif
endfunction
"Common search and replace commands
function! SearchAndReplace()
execute('redraw!')
let l:opt = input("x to 'x',: 1\nx\\ny to xy: 2\n:")
if l:opt == 1
execute("%s/^/\'/g\|%s/$/\'\,/g")
elseif l:opt == 2
execute("%s/\\n//g")
endif
endfunction
function! Copy()
execute('redraw!')
let l:opt = input("Copy lines containing: 1\nCopy all to clipboard: 2\n:")
"Copy the lines which contain a pattern to a register 'a' and then to system clipboard
if l:opt == 1
let l:pattern = input("Enter pattern\n:")
execute('normal qaq')
execute('g/' . l:pattern . '/y A')
let @* = @a
"Copy all to clipboard
elseif l:opt == 2
execute('%y*')
endif
endfunction
"Change File Format
function! FileFormat()
execute('redraw!')
let l:opt = input("Unix: 1\nDOS: 2\nRemove ^M and convert to unix: 3\n:")
"Set format to dos
if l:opt == 2
execute('update | setlocal ff=dos | w | set ff?')
"Set format to unix
elseif l:opt == 1
execute('update | setlocal ff=unix | w | set ff?')
"Remove the ^M characters and convert to unix
elseif l:opt == 3
execute('update | e ++ff=dos | setlocal ff=unix | w | set ff?')
endif
endfunction