OS:ubuntu16.04
vim:7.4
参考:https://blog.csdn.net/haolvshiqi/article/details/54016198
一、开启鼠标定位的功能
临时设置
:set mouse=a
长久设置,在/etc/vim/vimrc或者~/.vimrc 中添加
set mouse=a
开启鼠标模式
:set mouse=x, x取值如下, 例如:set mouse=a, 开启所有模式的mouse支持
n 普通模式
v 可视模式
i 插入模式
c 命令行模式
h 在帮助文件里,以上所有的模式
a 以上所有的模式
r 跳过 |hit-enter| 提示
A 在可视模式下自动选择
关闭鼠标模式
:set mouse=, =后面不要跟任何值, 可以关闭鼠标模式
二、NERDTree安装配置(看目录)
参考:https://www.linuxidc.com/Linux/2017-03/141699.htm
NERDTree 所有版本:
http://www.vim.org/scripts/script.php?script_id=1658
这里使用的NERDTree版本是:4.2.0 (5.0的不能用,楼主没试过)
因为这是插件安装很简单 解压以后拷贝两个文件都用户目录下的.vim中就可以了。
在根目录中的.vim中创建文件doc和plugin
cd ~/.vim
mkdir doc plugin
解压下载好的NERDTree文件
下载好的文件名是:nerdtree.zip
我下载的路径是:~/Downloads下
unzip nerdtree.zip
拷贝文件到~/.vim下
cp plugin/NERD_tree.vim ~/.vim/plugin/
cp doc/NERD_tree.txt ~/.vim/doc/
doc文件就是个说明文档不用拷贝也没事
这样就安装完成了
直接进入使用vim打开一个文档,输入命令
:NERDTree
就可以看到文件目录了
1、如果把指令《autocmd BufRead * 25vsp ./
》或者《autocmd VimEnter * NERDTree
》添加到/etc/vim/vimrc
或者是~/.vimrc
(这两个文件是vim的配置文件)中
每次进入vim就不需要输入 :NERDTree 指令(自动打开)
2、还可以使用快捷方式按打开或关闭文件目录树
在/etc/vim/vimrc
或者是~/.vimrc
添加指令《map <F2> : NERDTreeToggle<CR>
》
3、替换指令使用vimt
指令替换 vim -c "NERDTree" XXX
(这个的好处就是vim和vimt分开使用)
楼主使用的是zsh添加到~/.zshrc文件中去,如果使用bash添加到.bashrc (或者是对应的/etc/目录下的对应配置文件)
alias vimt='vim -c "NERDTree" $1'
注意:这三种方式追踪的目录方式(当前shell目录就是追踪的目录),(如果使用git可以自行百度其他方式,楼主的git特殊这种方式不适用)
这样使用我们还会发现问题,就是关闭文档以后,还要继续关闭NERDTree,就比较麻烦了
继续添加以下指令到/etc/vim/vimrc
或者是~/.vimrc
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
楼主在网上看到的一篇不错的配置,
参考:https://www.cnblogs.com/chjbbs/p/6649685.html
""将F2设置为开关NERDTree的快捷键
map <F2> :NERDTreeToggle
""修改树的显示图标
let g:NERDTreeDirArrowExpandable = '+'
let g:NERDTreeDirArrowCollapsible = '-'
""窗口位置
let g:NERDTreeWinPos='left'
""窗口尺寸
let g:NERDTreeSize=30
""窗口是否显示行号
let g:NERDTreeShowLineNumbers=1
""不显示隐藏文件
let g:NERDTreeHidden=0
""打开vim时如果没有文件自动打开NERDTree
autocmd vimenter * if !argc()|NERDTree|endif
""当NERDTree为剩下的唯一窗口时自动关闭
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") &&b:NERDTreeType == "primary") | q | endif
""打开vim时自动打开NERDTree
autocmd vimenter * NERDTree
拷贝过来的指令其中有几条我这边使用有问题,就自行百度修改了,小伙伴们要是有问题,可以看原文章。
三、安装 taglist(看函数)
下载地址(两个可选择任意一个):
Official site http://vim-taglist.sourceforge.net/
VIM online http://www.vim.org/scripts/script.php?script_id=273
下载解压
unzip taglist.zip
拷贝文件到~/.vim下(类似NERDTree的安装)
cp plugin/taglist.vim ~/.vim/plugin/
cp doc/taglist.txt ~/.vim/doc/
这次配置没有添加到vimt指令中,通过F3开启和关闭。NERDTree通过F2开启和关闭
""""配置taglist
let Tlist_Show_One_File=1 "不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow=1 "如果taglist窗口是最后一个窗口,则退出vim
let Tlist_Ctags_Cmd="/usr/bin/ctags" "将taglist与ctags关联
"==========================
" 1. General
"==========================
" set to auto read when a file is changed from the outside
set autoread
"==========================
" 2. Colors and Fonts
"==========================
" enable syntax highlight
syntax enable
"==========================
" 3. VIM UserInterface
"==========================
" show line number
set nu
" show matching bracets
set showmatch
" highlight search things
set hlsearch
"=========================
" 4. Text Options
"=========================
" set Tab = 4 spaces
set ts=4
"=========================
" 5. others
"=========================
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
let Tlist_WinWidth=40
let Tlist_Auto_Highlight_Tag=1
"设置taglist自动打开
let Tlist_Auto_Open=0
let Tlist_Auto_Update=1
let Tlist_Display_Tag_Scope=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Enable_Dold_Column=1
let Tlist_File_Fold_Auto_Close=1
let Tlist_Show_One_File=1
"let Tlist_Use_Right_Window=1
let Tlist_Use_SingleClick=1
nnoremap <F3> :TlistToggle<CR>
filetype plugin on
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascrīpt set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
安装以上插件以后会发现中NERDTree和taglist这两个功能占用窗口资源。(加上文档一共占据了三个窗口)
winmanager将nerdtree和taglist放到同一个”侧边栏”中,nerdtree在上方,taglist在下方。
四、安装winmanager
下载WinManager:http://www.vim.org/scripts/download_script.php?src_id=754。
然后解压
下载解压
unzip winmanager.zip
拷贝文件到~/.vim下(类似NERDTree的安装)
解压后文件不是两个比较多,我这边的做法发是直接拷贝过去。
cp plugin/* ~/.vim/plugin/
cp doc/* ~/.vim/doc/
配置文件
"""配置winmanager
"""""""""""""""""""""""""""""""
"" winManager setting
"""""""""""""""""""""""""""""""
"设置界面分割
let g:winManagerWindowLayout = "TagList|FileExplorer,BufExplorer"
"设置winmanager的宽度,默认为25
let g:winManagerWidth = 30
"定义打开关闭winmanager按键
nmap <silent> <F4> :WMToggle<cr>
直接使用F4 显示出来,当然你也可以单独使用F2和F3
五、关于程序的跳转
需要安装ctags不过一般linux自带
参看文档
https://www.cnblogs.com/microxiami/p/7988984.html