保存和传递宏
1 先建立一个宏。如上
2 在任意一个文件的空白位置normal状态下,命令"ap 即可以把宏的内容显示出来。比如说我的宏是:
"ohello th id<80>kb<80>kb<80>kbis is a a<80>kba<80>kbmaco of vim.^["
3 这段内容保存或传递。
4 使用命令:let @a="ohello th id<80>kb<80>kb<80>kbis is a a<80>kba<80>kbmaco of vim.^["
或者参考修改宏的第三步。
5 其他人用@a命令就可以使用你制作的宏了。
2018年3月28日17:25:10 —— CentOS 安装vim 8.0
yum install ncurses-devel
wget https://github.com/vim/vim/archive/master.zip
unzip master.zip (如果没有unzip就 yum install unzip -y)
cd vim-master
cd src/
./configure
make
sudo make install
vim –version
2018年6月4日15:11:21 —— vim设置
1、vim ~/.vimrc并添加如下内容
set autoindent
set tabstop=4
set softtabstop=4
set number
set shiftwidth=4
set hls
set cindent
map <F2> :w<CR>
" --------------cscope 配置--------------
"if has("cscope")
" set csprg=/usr/bin/cscope
" set csto=0
" set cst
" set nocsverb
" " add any database in current directory
" if filereadable("cscope.out")
" cs add cscope.out
" " else add database pointed to by environment
" elseif $CSCOPE_DB != ""
" cs add $CSCOPE_DB
" endif
" set csverb
"endif
if has("cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
"set csverb
set cspc=3
"add any database in current dir
if filereadable("cscope.out")
cs add cscope.out
"else search cscope.out elsewhere
else
let cscope_file=findfile("cscope.out", ".;")
let cscope_pre=matchstr(cscope_file, ".*/")
if !empty(cscope_file) && filereadable(cscope_file)
exe "cs add" cscope_file cscope_pre
endif
endif
map g<C-]> :cs find 3 <C-R>=expand(“<cword>”)<CR><CR>
map g<C-/> :cs find 0 <C-R>=expand(“<cword>”)<CR><CR>
nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-_>i :cs find i <C-R>=expand("<cfile>")<CR><CR>
nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>
endif
" --------------cscope 配置 结束--------------
" --------------vundle 配置开始--------------
set nocompatible " 去除VI一致性,必须要添加
filetype off " 必须要添加
" 设置包括vundle和初始化相关的runtime path
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" 另一种选择, 指定一个vundle安装插件的路径
"call vundle#begin('~/some/path/here')
" 让vundle管理插件版本,必须
Plugin 'VundleVim/Vundle.vim'
"" 以下范例用来支持不同格式的插件安装.
"" 请将安装插件的命令放在vundle#begin和vundle#end之间.
"" Github上的插件
"" 格式为 Plugin '用户名/插件仓库名'
"Plugin 'tpope/vim-fugitive'
"" 来自 http://vim-scripts.org/vim/scripts.html 的插件
"" Plugin '插件名称' 实际上是 Plugin 'vim-scripts/插件仓库名' 只是此处的用户名可以省略
"Plugin 'L9'
"" 由Git支持但不再github上的插件仓库 Plugin 'git clone 后面的地址'
"Plugin 'git://git.wincent.com/command-t.git'
"" 本地的Git仓库(例如自己的插件) Plugin 'file:///+本地插件仓库绝对路径'
"Plugin 'file:///home/gmarik/path/to/plugin'
"" 插件在仓库的子目录中.
"" 正确指定路径用以设置runtimepath. 以下范例插件在sparkup/vim目录下
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
"" 安装L9,如果已经安装过这个插件,可利用以下格式避免命名冲突
"Plugin 'ascenator/L9', {'name': 'newL9'}
" 自己的插件
" Plugin 'autoload_cscope.vim'
" 你的所有插件需要在下面这行之前
call vundle#end() " 必须
filetype plugin indent on " 必须 加载vim自带和插件相应的语法和文件类型相关脚本
" 忽视插件改变缩进,可以使用以下替代:
"filetype plugin on
"
" 常用的命令
" :PluginList - 列出所有已配置的插件
" :PluginInstall - 安装插件,追加 `!` 用以更新或使用 :PluginUpdate
" :PluginSearch foo - 搜索 foo ; 追加 `!` 清除本地缓存
" :PluginClean - 清除未使用插件,需要确认; 追加 `!` 自动批准移除未使用插件
"
" 查阅 :h vundle 获取更多细节和wiki以及FAQ
" 将你自己对非插件片段放在这行之后
" --------------vundle 配置结束--------------
2018年7月27日21:28:52 —— ubuntu 安装 cscope
sudo apt-get install cscope
1、建立数据库
在代码根目录下执行 cscope –bR
其中-R是递归建立
2、常用命令
1》查找定义
光标移到符号或函数上,按 ctrl+]
2》查找符号
:cs find s xxx
3》查找函数foo()在什么地方被调用
光标移动到函数名上,按ctrl+shift+减号+c
4》上面的vim配置可以保证,进入到项目的任何一个目录下都可以使用cscope
2018年7月30日9:52:44 —— 查找windows下vimrc的位置
打开一个vim然后输入 :set $VIM
2018年8月1日22:22:28 —— vim粘贴外部文本保持格式
打开vim输入如下命令:
:set paste
如果在ubuntu中就按shift + insert进行粘贴,这时候是原格式粘贴,粘贴完之后再执行
:set nopaste