Skip to content

Commit 0fc989e

Browse files
author
朱礼廷
committed
add
1 parent 8dac66a commit 0fc989e

File tree

181 files changed

+11755
-351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+11755
-351
lines changed

config/vimrc

+141-70
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,54 @@
11
set nocompatible
22

3-
" bundle setting
4-
au GUIEnter * call libcallnr("vimtweak.dll", "SetAlpha", 234)
3+
"sql style
4+
"let g:sql_type_default = 'mysql'
5+
6+
set backspace=indent,eol,start
7+
set tabstop=4
8+
set shiftwidth=4
9+
set expandtab
10+
set cindent
11+
12+
" 代码折叠
13+
set fdm=marker
14+
"set fdm=syntax
15+
16+
" 在编辑过程中,在右下角显示光标位置的状态行
17+
set ruler
518

19+
set showcmd
20+
set hlsearch
21+
" 搜索到文件两端时不重新搜索
22+
set nowrapscan
23+
set incsearch
24+
set cino=g0:0 " let class's public: don't indent
25+
26+
" none of these should be word dividers, so make them not be
27+
set iskeyword+=_,$,@,%,#
28+
29+
" allow backspace and cursor keys to cross line boundaries
30+
set whichwrap+=<,>,h,l
31+
32+
" this makes the color after the textwidth column highlighted
33+
set colorcolumn=+1
34+
35+
" 关闭错误声音
36+
set noerrorbells
37+
38+
" 显示行号
39+
set nu
40+
"set cursorline
41+
" 语法高亮度显示
42+
let python_highlight_all=1
43+
syntax on
44+
45+
" 显示括号配对情况
46+
set showmatch
647
filetype off " required!
748

8-
" set completeopt=longest,menu
9-
" 去掉预览窗口的显示
10-
" set completeopt-=preview
49+
set completeopt=longest,menu
1150

51+
" bundle setting
1252
" git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
1353
" aptitude install vim-gui-common
1454
set rtp+=~/.vim/bundle/vundle/
@@ -17,6 +57,9 @@ call vundle#begin()
1757
" let Vundle manage Vundle
1858
" required!
1959
Bundle 'gmarik/vundle'
60+
" 状态栏
61+
Bundle 'vim-airline/vim-airline'
62+
Bundle 'vim-airline/vim-airline-themes'
2063

2164
" My bundles here:
2265
" original repos on GitHub
@@ -37,8 +80,6 @@ Bundle 'jiangmiao/auto-pairs'
3780

3881
" cpp 补全,see http://www.vim.org/scripts/script.php?script_id=1520
3982
Bundle 'vim-scripts/OmniCppComplete'
40-
Bundle 'vim-scripts/echofunc.vim'
41-
let g:EchoFuncLangsUsed = ["cpp"]
4283

4384
Bundle 'scrooloose/syntastic'
4485
let g:ycm_show_diagnostics_ui = 0
@@ -50,12 +91,18 @@ let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'
5091
Bundle 'Valloric/YouCompleteMe'
5192
" cd ~/.vim/bundle/YouCompleteMe && ./install.py --clang-completer
5293

94+
" 提示函数参数
95+
"Bundle 'vim-scripts/echofunc.vim'
96+
"let g:EchoFuncLangsUsed = ["cpp"]
97+
5398
" vim-scripts repos
54-
Bundle 'SQLComplete.vim'
99+
"Bundle 'SQLComplete.vim'
55100
Bundle 'L9'
56101
Bundle 'FuzzyFinder'
57102
Bundle 'STL-Syntax'
58-
Bundle 'a.vim'
103+
"Bundle 'a.vim'
104+
"Bundle 'derekwyatt/vim-fswitch'
105+
59106
" Bundle 'c.vim'
60107
Bundle 'ctags.vim'
61108
Bundle 'taglist.vim'
@@ -75,8 +122,17 @@ Bundle 'git://git.wincent.com/command-t.git'
75122
" 命令:
76123
" CommandTBuffer
77124
" CommandT
125+
"
126+
127+
" gen tags
128+
"Bundle 'vim-scripts/DfrankUtil'
129+
"Bundle 'vim-scripts/vimprj'
130+
"Bundle 'vim-scripts/indexer.tar.gz'
131+
78132
call vundle#end()
79133

134+
"leader映射为逗号“,”
135+
let mapleader = ","
80136

81137
"*****************************************************
82138
" taglist配置 *
@@ -103,27 +159,64 @@ let Tlist_Use_SingClick=1
103159
"let Tlist_Auto_Open=1
104160
"Tlist 打开关闭快捷键 fn + F9
105161
nnoremap <silent> <F9> :TlistToggle<CR>
162+
let g:tagbar_autopreview = 1
106163

107164

108165
"*****************************************************
109166
" YouCompleteMe配置 *
110167
"*****************************************************
111-
"leader映射为逗号“,”
112-
let mapleader = ","
168+
" YCM 补全菜单配色
169+
" 菜单
170+
highlight Pmenu ctermfg=2 ctermbg=3 guifg=#005f87 guibg=#EEE8D5
171+
172+
" 选中项
173+
highlight PmenuSel ctermfg=2 ctermbg=3 guifg=#AFD700 guibg=#106900
174+
" 补全功能在注释中同样有效
175+
let g:ycm_complete_in_comments=1
176+
177+
" 开启 YCM 标签补全引擎
178+
let g:ycm_collect_identifiers_from_tags_files=1
179+
180+
" 补全内容不以分割子窗口形式出现,只显示补全列表
181+
set completeopt-=preview
182+
183+
" 从第一个键入字符就开始罗列匹配项
184+
let g:ycm_min_num_of_chars_for_completion=1
185+
" 禁止缓存匹配项,每次都重新生成匹配项
186+
let g:ycm_cache_omnifunc=0
187+
" 语法关键字补全
188+
let g:ycm_seed_identifiers_with_syntax=1
189+
113190
"默认的ycm_extra_conf.py
114191
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
115192
"打开vim时不再询问是否加载ycm_extra_conf.py配置
116193
let g:ycm_confirm_extra_conf=0
194+
let g:ycm_semantic_triggers = {'c' : ['->', '.'], 'objc' : ['->', '.'], 'ocaml' : ['.', '#'], 'cpp,objcpp' : ['->', '.', '::'], 'php' : ['->', '::'], 'cs,java,javascript,vim,coffee,python,scala,go' : ['.'], 'ruby' : ['.', '::']}
195+
117196

118197
" Look for tag def in a "tags" file in the dir of the current file, then for
119198
" that same file in every folder above the folder of the current file, until the
120199
" root.
121-
"set tags=./tags;/
200+
set tags=./tags;/
122201
" gen systags:
123202
" ctags -R --fields=+aiKlSz --extra=+q --c++-kinds=+px .
124-
set notagbsearch
125-
" 使用ctags生成的tags文件
126-
let g:ycm_collect_identifiers_from_tag_files = 1
203+
"set notagbsearch
204+
205+
206+
" easymotin
207+
"let g:EasyMotion_leader_key = 'f'
208+
" <Leader>f{char} to move to {char}
209+
map <leader>f <Plug>(easymotion-bd-f)
210+
nmap <leader>f <Plug>(easymotion-overwin-f)
211+
" m{char}{char} to move to {char}{char}
212+
nmap <leader>m <Plug>(easymotion-overwin-f2)
213+
" Move to line
214+
map <leader>l <Plug>(easymotion-bd-jk)
215+
nmap <leader>l <Plug>(easymotion-overwin-line)
216+
" Move to word
217+
"map <leader>w <Plug>(easymotion-bd-w)
218+
"nmap <leader>w <Plug>(easymotion-overwin-w)
219+
127220

128221
"leader映射为逗号“,”
129222
" nnoremap <leader>d:YcmCompleter GoToDeclaration<CR>
@@ -134,53 +227,10 @@ let g:ycm_collect_identifiers_from_tag_files = 1
134227
" 键位映射 *
135228
"*****************************************************
136229

137-
"sql style
138-
let g:sql_type_default = 'mysql'
139-
140-
set backspace=indent,eol,start
141-
set tabstop=4
142-
set shiftwidth=4
143-
set expandtab
144-
set cindent
145-
146-
" 代码折叠
147-
set fdm=marker
148-
"set fdm=syntax
149-
150-
" 在编辑过程中,在右下角显示光标位置的状态行
151-
set ruler
152-
153-
set showcmd
154-
set hlsearch
155-
" 搜索到文件两端时不重新搜索
156-
set nowrapscan
157-
set incsearch
158-
set cino=g0:0 " let class's public: don't indent
159-
160-
" none of these should be word dividers, so make them not be
161-
set iskeyword+=_,$,@,%,#
162-
163-
" allow backspace and cursor keys to cross line boundaries
164-
set whichwrap+=<,>,h,l
165-
166-
" this makes the color after the textwidth column highlighted
167-
set colorcolumn=+1
168-
169-
170-
" 关闭错误声音
171-
set noerrorbells
172-
173-
" 显示括号配对情况
174-
set showmatch
175-
176-
177230
" F12 run python
178231
map <F12> :!/usr/bin/python %
179232
map <F9> :!~/go/bin/go run %
180233
181-
" 语法高亮度显示
182-
let python_highlight_all=1
183-
syntax on
184234

185235
filetype plugin indent on
186236
set viminfo='20,\"50
@@ -200,13 +250,10 @@ if has("autocmd")
200250
endif
201251
" set bg=dark
202252

203-
" 显示行号
204-
set nu
205-
206253
filetype plugin on
207254

208255
" highlight setting
209-
let c_no_curly_error=1
256+
"let c_no_curly_error=1
210257
let g:ophigh_color = 226
211258
let g:ophigh_color_gui = "#F6FF00"
212259
let g:cpp_member_variable_highlight = 1
@@ -240,25 +287,51 @@ set background=light
240287
"colorscheme monokai
241288
"colorscheme molokai
242289
" 暗色调主题,适合夜间
243-
" colorscheme colorsbox-stnight
244-
" colorscheme colorsbox-faff
245-
" colorscheme colorsbox-greenish
290+
colorscheme colorsbox-stnight
291+
"colorscheme colorsbox-faff
292+
"colorscheme colorsbox-greenish
246293
" colorscheme colorsbox-material
247-
" colorscheme colorsbox-stblue
294+
"colorscheme colorsbox-stblue
248295
"colorscheme colorsbox-stbright
249-
colorscheme colorsbox-steighties
296+
"colorscheme colorsbox-steighties
250297
" colorscheme wombat256
251298

299+
" 显示状态栏
300+
set laststatus=2
301+
" 设置状态栏主题风格
302+
let g:Powerline_colorscheme='molokai256'
303+
let g:airline_theme = 'badwolf'
304+
252305
" Fast saving
253306
"前面leader为逗号“,”
307+
noremap <leader>w <esc>:w!<cr>
254308
inoremap <leader>w <esc>:w!<cr>
255-
noremap <leader>q :q<cr>
309+
noremap <leader>q :q!<cr>
256310
noremap <leader>x :x<cr>
311+
inoremap <leader>x <esc>:x<cr>
257312
258313
"上、下方向键
259314
nmap j gj
260315
nmap k gk
261316
317+
" find file
318+
noremap <leader>t :CommandT<cr>
319+
320+
"分屏
321+
noremap <leader>s :vs<cr>
322+
noremap <leader>p :sp<cr>
323+
324+
" 分屏多窗口跳转
325+
noremap zj <c-w>j
326+
noremap zk <c-w>k
327+
noremap zl <c-w>l
328+
noremap zh <c-w>h
329+
330+
331+
332+
" Ctrl + ] 多选择跳转
333+
"nmap <c-]> g<c-]>
334+
262335
inoremap jk <esc>
263336
264337
"insert模式下快捷键
@@ -278,5 +351,3 @@ imap ;; <esc>A;<esc>
278351
" enhance '<' '>' , do not need to reselect the block after shift it.
279352
vnoremap < <gv
280353
vnoremap > >gv
281-
282-
au GUIEnter * call libcallnr("vimtweak.dll", "SetAlpha", 234)

cpp/11/a.out

15.7 KB
Binary file not shown.

cpp/11/constructor.cpp

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
class MyString {
2+
private:
3+
char* _data;
4+
size_t _len;
5+
void _init_data(const char *s) {
6+
_data = new char[_len+1];
7+
memcpy(_data, s, _len);
8+
_data[_len] = '\0';
9+
}
10+
public:
11+
MyString() {
12+
_data = NULL;
13+
_len = 0;
14+
}
15+
16+
MyString(const char* p) {
17+
_len = strlen (p);
18+
_init_data(p);
19+
}
20+
21+
MyString(const MyString& str) {
22+
_len = str._len;
23+
_init_data(str._data);
24+
std::cout << "Copy Constructor is called! source: " << str._data << std::endl;
25+
}
26+
27+
MyString& operator=(const MyString& str) {
28+
if (this != &str) {
29+
_len = str._len;
30+
_init_data(str._data);
31+
}
32+
std::cout << "Copy Assignment is called! source: " << str._data << std::endl;
33+
return *this;
34+
}
35+
36+
MyString(MyString&& str) {
37+
std::cout << "Move Constructor is called! source: " << str._data << std::endl;
38+
_len = str._len;
39+
_data = str._data;
40+
str._len = 0;
41+
str._data = NULL;
42+
}
43+
44+
virtual ~MyString() {
45+
if (_data) free(_data);
46+
}
47+
};
48+
49+
int main() {
50+
MyString a;
51+
a = MyString("Hello");
52+
std::vector<MyString> vec;
53+
vec.push_back(MyString("World"));
54+
return 0;
55+
}

cpp/11/lambda3.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include<iostream>
2+
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int j = 10;
8+
auto by_val_lambda = [=]{ return j + 1; };
9+
auto by_ref_lambda = [&]{ return j + 1; };
10+
cout<<"by_val_lambda: "<<by_val_lambda()<<endl;
11+
cout<<"by_ref_lambda: "<<by_ref_lambda()<<endl;
12+
13+
++j;
14+
cout<<"by_val_lambda: "<<by_val_lambda()<<endl;
15+
cout<<"by_ref_lambda: "<<by_ref_lambda()<<endl;
16+
17+
return 0;
18+
}

0 commit comments

Comments
 (0)