Linux下Vim开发环境配置,让你的开发更高效! (linux vim 开发环境配置)

Vim是一款非常受欢迎的文本编辑器,它在Linux开发环境中得到广泛应用。它提供了许多丰富的功能,以及丰富的插件和配置选项,使得它能够满足各种用户的需求。本文将讲解如何在Linux环境中配置Vim开发环境,以便提高开发效率。

1. 安装Vim

通常来说,大多数Linux系统都自带了Vim编辑器,但是为了避免出现版本不一致或者缺少某些插件的情况,可以通过以下命令安装最新版:

“`

sudo apt-get install vim

“`

2. 安装插件管理器

插件管理器可以帮助我们更方便的安装、管理和更新Vim插件,目前比较流行的插件管理器有两个:Vundle和Pathogen。这里我们使用Vundle作为示例。

安装Vundle的命令如下:

“`

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

“`

3. 配置.vimrc

Vim的配置文件通常是存放在用户目录下的.vimrc文件中,可以通过修改这个文件来配置Vim的各种选项。下面是一个示例:

“`

” 使用Vundle管理插件

set rtp+=~/.vim/bundle/Vundle.vim

call vundle#begin()

” 插件列表

Plugin ‘gmarik/Vundle.vim’

Plugin ‘tpope/vim-surround’

Plugin ‘scrooloose/nerdtree’

call vundle#end()

” 设置文件类型

filetype plugin indent on

” 启用行号和状态栏

set nu

set laststatus=2

” 开启语法高亮和括号匹配

syntax on

set showmatch

” 设置自动缩进的宽度为4个空格

set tabstop=4

set shiftwidth=4

set expandtab

” 默认打开NERDTree

autocmd StdinReadPre * let s:std_in=1

autocmd VimEnter * if argc() == 0 && !exists(“s:std_in”) | NERDTree | endif

“`

上述例子中,我们使用了Vundle插件管理器,并安装了三个插件:Vundle.vim(插件管理器本身)、vim-surround(帮助添加、修改、删除括号、引号等字符)、nerdtree(树形目录浏览器)。我们还启用了行号、状态栏和语法高亮,并设置了自动缩进宽度为4个空格。我们使用NERDTree插件来打开树形目录浏览器,方便我们浏览和操作文件。

4. 插件安装和更新

在Vim的命令模式中,可以通过以下命令来安装和更新插件:

“`

:PluginInstall

:PluginUpdate

“`

5. 其他常用插件

除了上面提到的几个插件外,还有很多实用的插件可以提高我们的开发效率。以下列举一些常用的插件:

– CtrlP: 通过模糊查找,快速搜索文件

– YouCompleteMe: 代码补全插件,支持C/C++、Python、Ruby、JavaScript等

– Syntastic: 语法检查插件,支持多种语言

– Tagbar: 代码结构视图插件

– Fugitive: Git插件,支持在Vim中进行Git操作

以上插件只是冰山一角,可以根据自己的需要安装、配置。

通过合理的配置和插件的安装,Vim可以变得更加强大和高效,为我们的开发工作带来很大的帮助。希望本文能够帮助到广大Linux用户。

相关问题拓展阅读:

Linux中的vim配置文件不起作用。

先换个最基本的春基 .vimrc 检查一下是不是能生效。

比如,进 vim 后,执行:

:e $MYVIMRC

:w .vimrc~

备份一下当前的内容。

然后删掉所有内容粗森誉,只加一个比如

set nu

这样的东西。存盘退出,再启动看看岩段能不能生效。

看了下你的配置文件,

首先把迅启档没用的符号去掉,

然后格式统计,行首空格去掉

再把它重命旁巧名为别的名字

然后打开vim,正常vim会自己生成一个配置文件 /home/z-y-z/.vimrc

最后把旧的粘贴到新的里面亩乱,试试

你好,我也遇到了你同样的情况,只有set nu生效,其他的没作用,你之前怎么解决的啊

如何配置go语言集成开发环境 vim

1、编译vimgdb

下载vimgdb73和vim73

mkdir -p ./tmp

cd tmp

tar zxvf ../vim-7.3.tar.gz

unzip ../vimgdb-for-vim7.3-master.zip

mv vimgdb-for-vim7.3-master vimgdb-for-vim7.3

patch -p0 如果能看到函数的声明展示出来,说明安装是正确的。

4、代码跳转提示godef

Set up godef

go get -v code.google.com/p/rog-go/exp/cmd/godef

go install -v code.google.com/p/rog-go/exp/cmd/godef

git clone

~/.vim/bundle/vim-godef

Configure vim in .vimrc file

Bundle ‘dgryski/vim-godef’

Install Plugins

Launch vim and run

: PluginInstall

vim +PluginInstall +qall

5、代码结构提示gotags

Set up gotags

go get -u github.com/jstemmer/gotags

Put the following configuration in your vimrc:

Bundle ‘majutsushi/tagbar’

nmap :TagbarToggle

let g:tagbar_type_go = {

\ ‘ctagstype’ : ‘go’,

\ ‘kinds’ :

\ ‘p:package’,

\ ‘i:imports:1’,

\ ‘c:constants’,

\ ‘v:variables’,

\ ‘t:types’,

\ ‘n:interfaces’,

\ ‘w:fields’,

\ ‘e:embedded’,

\ ‘m:methods’,

\ ‘r:constructor’,

\ ‘f:functions’

\ >,

\ ‘sro’ : ‘.’,

\ ‘kind2scope’ : {

\ ‘t’ : ‘ctype’,

\ ‘n’ : ‘ntype’

\ },

\ ‘scope2kind’ : {

\ ‘ctype’ : ‘t’,

\ ‘ntype’ : ‘n’

\ },

\ ‘ctagin’ : ‘gotags’,

\ ‘ctagsargs’ : ‘-sort -silent’

\ }

命令模式下按在右边就会显示当前文件下的函数名,结构体名等等,光标放到相应的tag上,按回车可以快速跳到程序中的相应位置。

再次按会关闭tag窗口。

PS:本地的.vimrc的配置

” 插件管理器 vundle

set nocompatible ” be iMproved, required

filetype off ” required

” set the runtime path to include Vundle and initialize

set rtp+=~/.vim/bundle/vundle/

call vundle#rc()

” alternatively, pass a path where Vundle should install plugins

“let path = ‘~/some/path/here’

“call vundle#rc(path)

” let Vundle manage Vundle, required

Plugin ‘gmarik/vundle’

” The following are examples of different formats supported.

” Keep Plugin commands between here and filetype plugin indent on.

” scripts on GitHub repos

” Plugin ‘tpope/vim-fugitive’

” Plugin ‘Lokaltog/vim-easymotion’

” Plugin ‘tpope/vim-rails.git’

” The sparkup vim script is in a subdirectory of this repo called vim.

” Pass the path to set the runtimepath properly.

” Plugin ‘rstacruz/sparkup’, {‘rtp’: ‘vim/’}

” scripts from

” Plugin ‘L9’

” Plugin ‘FuzzyFinder’

” scripts not on GitHub

” Plugin ‘

” git repos on your local machine (i.e. when working on your own plugin)

” Plugin ‘

” …

filetype plugin indent on ” required

” To ignore plugin indent changes, instead use:

” filetype plugin on

” Brief help

” : PluginList – list configured plugins

” : PluginInstall(!)- install (update) plugins

” : PluginSearch(!) foo – search (or refresh cache first) for foo

” : PluginClean(!) – confirm (or auto-approve) removal of unused plugins

” see :h vundle for more details or wiki for FAQ

” NOTE: comments after Plugin commands are not allowed.

” Put your stuff after this line

syntax on

” ********************************************************************

” 这里省略了其它不相关的插件

” vimgdb插件

run macros/gdb_mappings.vim

” 官方的插件

” Some Linux distributions set filetype in /etc/vimrc.

” Clear filetype flags before changing runtimepath to force Vim to

” reload them.

filetype off

filetype plugin indent off

set runtimepath+=$GOROOT/misc/vim

filetype plugin indent on

syntax on

autocmd FileType go autocmd BufWritePre Fmt

” 代码补全的插件

Bundle ‘Blackrush/vim-gocode’

” 代码跳转提示

Bundle ‘dgryski/vim-godef’

” 代码结构提示

Bundle ‘majutsushi/tagbar’

nmap :TagbarToggle

let g:tagbar_type_go = {

\ ‘ctagstype’ : ‘go’,

\ ‘kinds’ :

\ ‘p:package’,

\ ‘i:imports:1’,

\ ‘c:constants’,

\ ‘v:variables’,

\ ‘t:types’,

\ ‘n:interfaces’,

\ ‘w:fields’,

\ ‘e:embedded’,

\ ‘m:methods’,

\ ‘r:constructor’,

\ ‘f:functions’

\ >,

\ ‘sro’ : ‘.’,

\ ‘kind2scope’ : {

\ ‘t’ : ‘ctype’,

\ ‘n’ : ‘ntype’

\ },

\ ‘scope2kind’ : {

\ ‘ctype’ : ‘t’,

\ ‘ntype’ : ‘n’

\ },

\ ‘ctagin’ : ‘gotags’,

\ ‘ctagsargs’ : ‘-sort -silent’

\ }

关于linux vim 开发环境配置的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。


数据运维技术 » Linux下Vim开发环境配置,让你的开发更高效! (linux vim 开发环境配置)