Skip to content

Commit

Permalink
improve visualization of cursor, color,
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-ais committed Mar 12, 2024
1 parent 58b33e5 commit 783c546
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 67 deletions.
81 changes: 39 additions & 42 deletions .vimrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
" Hello,我是程序员leon-ais,欢迎添加我的微信号:leon-ais
"
inoremap kj <ESC>
" <ESC> 映射
inoremap kj <ESC>l
"
" 定义快捷键的前缀,即<Leader>
let mapleader=";"
Expand Down Expand Up @@ -41,10 +42,10 @@ set incsearch " do incremental searching
"设置非兼容模式
set nocp

"set encoding=utf-8
""set encoding=gb2312
set langmenu=zh_CN.gb2312
""language message zh_CN.gb2312
set encoding=utf-8
"set encoding=gb2312
"set langmenu=zh_CN.gb2312
"language message zh_CN.gb2312

set fileencoding=gbk2312
set ts=4
Expand All @@ -63,9 +64,11 @@ set noswapfile

" 禁止光标闪烁
" set gcr=a:block-blinkon0
" 十字光标
autocmd FileType cpp set cul cuc colorcolumn=81

" 十字光标
set cursorline cursorcolumn
set colorcolumn=81
highlight ColorColumn ctermbg=0 guibg=black
" ack搜索时不打开第一个搜索文件
map <Leader>fw :Ack! <Space>
" AckFile不打开第一个搜索文件
Expand Down Expand Up @@ -123,7 +126,7 @@ nmap <Leader>s :Sex<CR>
" 竖直分隔
nmap <Leader>v :Vex<CR>
" 全局替换
nmap <Leader>r :%s/fileName-/fileName+/g
nmap <Leader>r :%s/-/+/g
" align 表格对齐
nmap <Leader>t :Tab /
" 打tag
Expand Down Expand Up @@ -202,9 +205,12 @@ autocmd FileType cpp,java inoremap { {<CR>}<ESC>kA<CR>
set fenc=" "
"显示匹配
set showmatch
"优化<ESC>效果
inoremap <ESC> <ESC>l
"括号匹配
inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap < <><ESC>i
inoremap ' ''<ESC>i
inoremap " ""<ESC>i
set selectmode=mouse,key
Expand Down Expand Up @@ -240,14 +246,13 @@ inoremap <C-v> <Esc>:r ~/tmp/clipboard.txt <CR>
autocmd filetype python nnoremap <F5> :w <bar> exec '!python '.shellescape('%')<CR>
autocmd filetype c nnoremap <F5> :w <bar> exec '!gcc '.shellescape('%').' -o '.shellescape('%:r').' && ./'.shellescape('%:r')<CR>
autocmd filetype cpp nnoremap <F5> :w <bar> exec '!g++ -g --std=c++11 -pthread '.shellescape('%').' -o '.shellescape('%:r').' && ./'.shellescape('%:r')<CR>
" autocmd filetype dot nnoremap <F5> :w <bar> exec '!dot -Tsvg '.shellescape('%').' > ./svg/'.shellescape('%:r').' && open ./bin/'.shellescape('%:r')<CR>
autocmd filetype dot nnoremap <F5> :w <bar> exec '!dot -Tsvg sqlparse.dot > sqlparse.svg'<CR>
autocmd Filetype java nnoremap <F5> :w <bar> exec '!javac '.shellescape('%'). ' -d ./bin'<CR>
autocmd filetype java nnoremap <F6> :w <bar> exec '!java -cp ./bin '.shellescape('%:r')<CR>
let g:tlist_markdown_settings = 'markdown;h:Headlins'
"新建.c,.cc,.cpp,.h,.sh,.Java,.go文件,自动插入文件头
autocmd BufNewFile *.cc,*.cpp,*.c,*.h,*.sh,*.Java,*.go exec ":call SetTitle()"
"新建.c,.h,.sh,.Java文件,自动插入文件头
autocmd BufNewFile *.c,*.cpp,*.h,*.sh,*.Java,*.go exec ":call SetTitle()"
"""定义函数SetTitle,自动插入文件头
func SetTitle()
"如果文件类型为.sh文件
Expand All @@ -271,44 +276,36 @@ func SetTitle()
call append(line(".")+6, "")
endif
if expand("%:e") == 'h'
call append(line(".")+7, "#ifndef __".toupper(expand("%:r"))."_H")
call append(line(".")+8, "#define __".toupper(expand("%:r"))."_H")
call append(line(".")+7, "#ifndef _".toupper(expand("%:r"))."_H")
call append(line(".")+8, "#define _".toupper(expand("%:r"))."_H")
call append(line(".")+9, "")
call append(line(".")+10, "#endif // __".toupper(expand("%:r"))."_H")
call append(line(".")+10,"#endif //_".toupper(expand("%:r"))."_H")
elseif expand("%:e") == 'cpp'
call append(line(".")+7, "#include <iostream>")
call append(line(".")+8, "#include <cstdio>")
call append(line(".")+9, "#include <cstdlib>")
call append(line(".")+10, "#include <vector>")
call append(line(".")+11, "#include <stack>")
call append(line(".")+12, "#include <queue>")
call append(line(".")+13, "#include <string>")
call append(line(".")+14, "#include <set>")
call append(line(".")+15, "#include <map>")
call append(line(".")+16, "#include <algorithm>")
call append(line(".")+17, "using namespace std;")
call append(line(".")+18, "")
call append(line(".")+19, "int main() {")
call append(line(".")+20, "")
call append(line(".")+21, " cout << \":\" << endl;")
call append(line(".")+22, " return EXIT_SUCCESS;")
call append(line(".")+23, "}")
call append(line(".")+7, "#include <bits/stdc++.h>")
call append(line(".")+8, "#include <algorithm>")
call append(line(".")+9, "")
call append(line(".")+10,"using namespace std;")
call append(line(".")+11,"")
call append(line(".")+12,"int main(int argc, char* argv[])")
call append(line(".")+13,"{")
call append(line(".")+14," cout << \":\" << endl;")
call append(line(".")+15," return 0;")
call append(line(".")+16,"}")
elseif expand("%:e") == 'c'
call append(line(".")+7, "#include <stdio.h>")
call append(line(".")+8, "#include <stdlib.h>")
call append(line(".")+9, "#include <string.h>")
call append(line(".")+10, "")
call append(line(".")+11, "int main(int argc, char* argv[])")
call append(line(".")+12, "{")
call append(line(".")+13, "")
call append(line(".")+14, " return 0;")
call append(line(".")+15, "}")
call append(line(".")+10,"")
call append(line(".")+11,"int main(int argc, char* argv[])")
call append(line(".")+12,"{")
call append(line(".")+13," printf(\".\");")
call append(line(".")+14," return 0;")
call append(line(".")+15,"}")
endif
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
endfunc


" shortcut for markdown
" 创建时间快捷键for markdown
nmap tm :call SetTime() <CR>
Expand Down Expand Up @@ -350,9 +347,9 @@ func SetCC()
endfunc

" 使用的背景主题
" colorscheme desert " 设置主题
colorscheme desert " 设置主题
" colorscheme Monokai_Gavin
colorscheme seoul256
" colorscheme seoul256
" 添加自动补全字典
au FileType php setlocal dict+=~/.vim/dictionary/php_keywords_list.txt
au FileType cpp setlocal dict+=~/.vim/dictionary/cpp_keywords_list.txt
Expand All @@ -366,7 +363,7 @@ let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_
nnoremap <Leader>p :SyntasticToggleMode<CR> :w<CR>
" set vim-syntastic compiler
let g:syntastic_cpp_compiler = 'g++'
let g:syntastic_cpp_compiler_options = ' -g -std=c++11 -stdlib=libc++'
let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
Expand All @@ -386,7 +383,7 @@ autocmd BufEnter * silent! lcd %:p:h
" :set completeopt+=noinsert

set completeopt=menu,menuone
let OmniCpp_MayCompleteDot=1 " 打开 . 操作符
let OmniCpp_MayCompleteDot=1 " 打开 . 操作符
let OmniCpp_MayCompleteArrow=1 " 打开 -> 操作符
let OmniCpp_MayCompleteScope=1 " 打开 :: 操作符
let OmniCpp_NamespaceSearch=1 " 打开命名空间
Expand Down
94 changes: 69 additions & 25 deletions .vimrc.bak → .vimrc.bakk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
" Hello,我是PowerVim的作者,程序员Carl,欢迎关注我的微信公众号:代码随想录
" Hello,我是程序员leon-ais,欢迎添加我的微信号:leon-ais
"
inoremap kj <ESC>l
" 定义快捷键的前缀,即<Leader>
let mapleader=";"

Expand All @@ -8,6 +9,8 @@ execute pathogen#infect()
" syntax on
filetype plugin indent on

"设置真彩色
set termguicolors
"高亮搜索关键词"
let g:ackhighlight = 1
"修改快速预览窗口高度为15
Expand Down Expand Up @@ -37,10 +40,10 @@ set incsearch " do incremental searching
"设置非兼容模式
set nocp

"set encoding=utf-8
""set encoding=gb2312
set langmenu=zh_CN.gb2312
language message zh_CN.gb2312
set encoding=utf-8
"set encoding=gb2312
"set langmenu=zh_CN.gb2312
"language message zh_CN.gb2312

set fileencoding=gbk2312
set ts=4
Expand All @@ -59,7 +62,12 @@ set noswapfile

" 禁止光标闪烁
" set gcr=a:block-blinkon0

" 十字光标
autocmd FileType cpp set cul cuc colorcolumn=81
"
set cursorline cursorcolumn
set colorcolumn=81
highlight ColorColumn ctermbg=0 guibg=black
" ack搜索时不打开第一个搜索文件
map <Leader>fw :Ack! <Space>
" AckFile不打开第一个搜索文件
Expand Down Expand Up @@ -196,9 +204,12 @@ autocmd FileType cpp,java inoremap { {<CR>}<ESC>kA<CR>
set fenc=" "
"显示匹配
set showmatch
"
inoremap <ESC> <ESC>l
"括号匹配
inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap < <><ESC>i
inoremap ' ''<ESC>i
inoremap " ""<ESC>i
set selectmode=mouse,key
Expand All @@ -217,7 +228,6 @@ set ruler " 显示标尺"
autocmd InsertEnter * se cul " 用浅色高亮当前行"
set shortmess=atI " 启动的时候不显示那个援助乌干达儿童的提示

" :colorscheme desert " 设置主题
" vim-commentary style set 注释针对不同语言的注释方法
autocmd FileType cpp set commentstring=//\ %s
autocmd FileType php set commentstring=//\ %s
Expand All @@ -232,39 +242,73 @@ syntax on
vnoremap <C-c> :w! ~/tmp/clipboard.txt <CR>
inoremap <C-v> <Esc>:r ~/tmp/clipboard.txt <CR>
" 编译快捷键
autocmd filetype python nnoremap <F1> :w <bar> exec '!python '.shellescape('%')<CR> autocmd filetype c nnoremap <F1> :w <bar> exec '!gcc '.shellescape('%').' -o '.shellescape('%:r').' && ./'.shellescape('%:r')<CR>
autocmd filetype cpp nnoremap <F1> :w <bar> exec '!g++ --std=c++11 -pthread '.shellescape('%').' -o ./bin/'.shellescape('%:r').' && ./bin/'.shellescape('%:r')<CR>
" autocmd filetype dot nnoremap <F1> :w <bar> exec '!dot -Tsvg '.shellescape('%').' > ./svg/'.shellescape('%:r').' && open ./bin/'.shellescape('%:r')<CR>
autocmd filetype dot nnoremap <F1> :w <bar> exec '!dot -Tsvg sqlparse.dot > sqlparse.svg'<CR>
autocmd Filetype java nnoremap <F1> :w <bar> exec '!javac '.shellescape('%'). ' -d ./bin'<CR>
autocmd filetype java nnoremap <F2> :w <bar> exec '!java -cp ./bin '.shellescape('%:r')<CR>

autocmd filetype python nnoremap <F5> :w <bar> exec '!python '.shellescape('%')<CR>
autocmd filetype c nnoremap <F5> :w <bar> exec '!gcc '.shellescape('%').' -o '.shellescape('%:r').' && ./'.shellescape('%:r')<CR>
autocmd filetype cpp nnoremap <F5> :w <bar> exec '!g++ -g --std=c++11 -pthread '.shellescape('%').' -o '.shellescape('%:r').' && ./'.shellescape('%:r')<CR>
" autocmd filetype dot nnoremap <F5> :w <bar> exec '!dot -Tsvg '.shellescape('%').' > ./svg/'.shellescape('%:r').' && open ./bin/'.shellescape('%:r')<CR>
autocmd filetype dot nnoremap <F5> :w <bar> exec '!dot -Tsvg sqlparse.dot > sqlparse.svg'<CR>
autocmd Filetype java nnoremap <F5> :w <bar> exec '!javac '.shellescape('%'). ' -d ./bin'<CR>
autocmd filetype java nnoremap <F6> :w <bar> exec '!java -cp ./bin '.shellescape('%:r')<CR>

let g:tlist_markdown_settings = 'markdown;h:Headlins'
"新建.c,.h,.sh,.Java文件,自动插入文件头
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.Java,*.go exec ":call SetTitle()"
"新建.c,.cc,.cpp,.h,.sh,.Java,.go文件,自动插入文件头
autocmd BufNewFile *.cc,*.cpp,*.c,*.h,*.sh,*.Java,*.go exec ":call SetTitle()"
"""定义函数SetTitle,自动插入文件头
func SetTitle()
"如果文件类型为.sh文件
if &filetype == 'sh'
if expand("%:e") == 'sh'
call setline(1,"\#########################################################################")
call append(line("."), "\# File Name: ".expand("%"))
call append(line(".")+1, "\# Author: 程序员Carl")
call append(line(".")+2, "\# mail: programmercarl@163.com")
call append(line(".")+1, "\# Author: leon-ais")
call append(line(".")+2, "\# mail: leon_ais@qq.com")
call append(line(".")+3, "\# Created Time: ".strftime("%c"))
call append(line(".")+4, "\#########################################################################")
call append(line(".")+5, "\#!/bin/bash")
call append(line(".")+6, "")
else
call setline(1, "/* ************************************************************************")
call append(line("."), "> File Name: ".expand("%"))
call append(line(".")+1, "> Author: 程序员Carl")
call append(line(".")+2, "> 微信公众号: 代码随想录")
call append(line(".")+1, "> Author: leon-ais")
call append(line(".")+2, "> mail: leon_ais@qq.com")
call append(line(".")+3, "> Created Time: ".strftime("%c"))
call append(line(".")+4, "> Description: ")
call append(line(".")+5, " ************************************************************************/")
call append(line(".")+6, "")
endif
if expand("%:e") == 'h'
call append(line(".")+7, "#ifndef __".toupper(expand("%:r"))."_H")
call append(line(".")+8, "#define __".toupper(expand("%:r"))."_H")
call append(line(".")+9, "")
call append(line(".")+10, "#endif // __".toupper(expand("%:r"))."_H")
elseif expand("%:e") == 'cpp'
call append(line(".")+7, "#include <iostream>")
call append(line(".")+8, "#include <cstdio>")
call append(line(".")+9, "#include <cstdlib>")
call append(line(".")+10, "#include <vector>")
call append(line(".")+11, "#include <stack>")
call append(line(".")+12, "#include <queue>")
call append(line(".")+13, "#include <string>")
call append(line(".")+14, "#include <set>")
call append(line(".")+15, "#include <map>")
call append(line(".")+16, "#include <algorithm>")
call append(line(".")+17, "using namespace std;")
call append(line(".")+18, "")
call append(line(".")+19, "int main() {")
call append(line(".")+20, "")
call append(line(".")+21, " cout << \":\" << endl;")
call append(line(".")+22, " return EXIT_SUCCESS;")
call append(line(".")+23, "}")
elseif expand("%:e") == 'c'
call append(line(".")+7, "#include <stdio.h>")
call append(line(".")+8, "#include <stdlib.h>")
call append(line(".")+9, "#include <string.h>")
call append(line(".")+10, "")
call append(line(".")+11, "int main(int argc, char* argv[])")
call append(line(".")+12, "{")
call append(line(".")+13, "")
call append(line(".")+14, " return 0;")
call append(line(".")+15, "}")
endif
"新建文件后,自动定位到文件末尾
autocmd BufNewFile * normal G
endfunc
Expand Down Expand Up @@ -310,10 +354,10 @@ func SetCC()
call append(line("."), "// vim: et tw=100 ts=4 sw=4 cc=120")
endfunc

" Hello,我是PowerVim的作者,程序员Carl,欢迎关注我的微信公众号:代码随想录

" 使用的背景主题
colorscheme Monokai_Gavin
colorscheme desert " 设置主题
" colorscheme Monokai_Gavin
" colorscheme seoul256
" 添加自动补全字典
au FileType php setlocal dict+=~/.vim/dictionary/php_keywords_list.txt
au FileType cpp setlocal dict+=~/.vim/dictionary/cpp_keywords_list.txt
Expand All @@ -327,7 +371,7 @@ let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_
nnoremap <Leader>p :SyntasticToggleMode<CR> :w<CR>
" set vim-syntastic compiler
let g:syntastic_cpp_compiler = 'g++'
let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'
let g:syntastic_cpp_compiler_options = ' -g -std=c++11 -stdlib=libc++'
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
Expand Down

0 comments on commit 783c546

Please sign in to comment.