vim

常用命令

a 在光标之后进入插入模式
A 在行末进入插入模式
o 在目前光标所在的下一行处输入新的一行
O 在目前光标所在的上一行处输入新的一行
. 重复上次命令

zf% 括号( <> () [] {} ) 匹配折叠
zc 折叠
zC 对所在范围内所有嵌套的折叠点进行折叠
zo 展开折叠
zO 对所在范围内所有嵌套的折叠点展开
zd 删除在光标下的折叠
zD 嵌套删除折叠
zE 除去窗口里所有的折叠

:%s/s1/s2/g 替换所有 s1 为 s2
:s/s1/s2/g 替换本行中所有 s1 为 s2
:s/\<s1\>/s2/g 替换本行中所有 s1 为 s2,全字匹配


\(MacOS\) 下的 vim 的代码复制粘贴一直是一个问题,今天终于找到了解决方法。
只需在 vimrc 文件中添加以下代码:

vmap <C-c> :w !pbcopy<CR><CR>

便可在可视模式下使用 ctrl-C 复制选中部分,用 command-V 复制到其他区域。


配置文件


func CompileRun()
	exec "w"
	if &filetype == 'cpp'
		exec "!g++ % -std=c++11 -Wall -o %<.exe"
	elseif &filetype == 'cs'
		exec "!csc %"
	endif
endfunc

func Run()
	if &filetype == 'cs' || &filetype == 'cpp'
		exec "!%<.exe"
	endif
endfunc

set fdm=marker
set clipboard+=unnamed "与 Windows 共享剪贴板
set number
set ruler   "在编辑过程中,在右下角显示光标位置的状态行 
set tabstop=4
set shiftwidth=4
set autoindent
set smartindent
set autoread
set shortmess=atI
set nohlsearch " 不要高亮被搜索的句子(phrases) 
set showmatch "自动匹配成对的括号
set guifont=Consolas:h18
set selection=exclusive
set noerrorbells
set noundofile
set nobackup
filetype on
syntax on
colorscheme solarized

nnoremap <F5> <ESC>:w<CR>:!python %<.py <CR>
nnoremap <F12> <ESC>:w<CR>:!g++ % -Wall -o
map <F9> :call CompileRun()<CR>
map <F10> :call Run()<CR> 

inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {}<ESC>i
inoremap " ""<ESC>i
inoremap ' ''<ESC>i

posted @ 2018-07-20 21:21  昤昽  阅读(187)  评论(0编辑  收藏  举报