将Vim打造成服务器端IDE

1 篇文章 0 订阅
1 篇文章 0 订阅

仔细想了下,服务器端编程由于服务器(一般都是Linux)并不会装Eclipse,Visual Studio之类的IDE,所以用Vim还是比较好的选择,还能提高Coding(敲键盘)能力,固化编程式思维。

爱上Coding!

  • .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# ls color
export CLICOLOR=1;
export LSCOLORS=gxfxaxdxcxegedabagacad;

# command display
# export PS1="\u@\H \w\n\$ "
export PS1='\[\033[01;32m\]\u@\H\[\033[01;33m\] \w\[\033[34;40m\]\n> \[\033[00m\] '

# change open files -> 10000
ulimit -n 10000

# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
  • ctags

brew install ctags

(Centos: yum install ctags)

  • vundle
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
  • .vimrc.bundles

这个是vim vundle的配置文件。

set nocompatible              " be iMproved, required
filetype off                  " required

set rtp+=~/.vim/bundle/vundle/
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
Bundle 'taglist.vim'
Bundle 'winmanager'
Bundle 'The-NERD-tree'
Bundle 'The-NERD-Commenter'
" Bundle 'fholgado/minibufexpl.vim'
Bundle 'minibufexplorerpp'
Bundle 'Yggdroot/indentLine'
Bundle 'scrooloose/syntastic'
Bundle 'vim-scripts/pylint.vim'
Bundle 'leshill/vim-json'
Plugin 'davidhalter/jedi-vim'
Plugin 'Chiel92/vim-autoformat'
Bundle 'luochen1990/rainbow'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
call vundle#end()            " required
filetype plugin indent on    " required
  • .vimrc

这个是vim的配置文件,每次vim启动时都会逐条执行里面的配置选项。贴下我的通用配置 (还没有包含插件,按照下面的步骤增加插件会增加.vimrc中的内容):

" vundle bundles
if filereadable(expand("~/.vimrc.bundles"))
	source ~/.vimrc.bundles
endif

" my own settings
syntax on "语法支持
set laststatus=2 "始终显示状态栏
set tabstop=4 "一个制表符的长度
set softtabstop=4 "一个制表符的长度(可以大于tabstop)
set shiftwidth=4 "一个缩进的长度
set expandtab "使用空格替代制表符
set smarttab "智能制表符
set autoindent "自动缩进
set smartindent "智能缩进
set number "显示行号
set ruler "显示位置指示器
set backupdir=/tmp "设置备份文件目录
set directory=/tmp "设置临时文件目录
set ignorecase "检索时忽略大小写
set hls "检索时高亮显示匹配项
set helplang=cn "帮助系统设置为中文
set foldmethod=syntax "代码折叠
set nobackup "不生成备份文件
set guifont=Courier\ New:h15 "设置字体
set nowrap "长句在一行显示
set encoding=utf-8

colorscheme pablo

" Tlist
let Tlist_Ctags_Cmd='/usr/local/bin/ctags'
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Right_Window=1
let Tlist_Sort_Type = "name"
let Tlist_Auto_Open=1
nmap wt :Tlist<CR>

 " MiniBufExplorer
let g:miniBufExplMapWindowNavVim = 1   
let g:miniBufExplMapWindowNavArrows = 1   
let g:miniBufExplMapCTabSwitchBufs = 1   
let g:miniBufExplModSelTarget = 1  
let g:miniBufExplMoreThanOne=0

nmap be :MiniBufExplorer<CR>

" NERDTree
let g:NERDTree_title="[NERDTree]"

function! NERDTree_Start()
    exec 'NERDTree'
endfunction

function! NERDTree_IsValid()
    return 1
endfunction

" WinManager
let g:winManagerWindowLayout="NERDTree"

nmap wm :WMToggle<CR>

" Cscope
:set cscopequickfix=s-,c-,d-,i-,t-,e-

" autoformatter
let g:formatdef_c = '"astyle --style=linux --indent-switches --indent-namespaces --attach-closing-while --indent-preproc-block --pad-oper --delete-empty-lines --attach-return-type-decl"'
let g:formatters_c = ['c']
let g:formatters_cpp = ['c']
let g:formatdef_html = '"html-beautify -s 2"'
let g:formatters_html = ['html']
au BufWrite * :Autoformat

" rainbow
let g:rainbow_active = 1
let g:rainbow_conf = {
\   'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\   'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\   'operators': '_,_',
\   'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\   'separately': {
\       '*': {},
\       'tex': {
\           'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
\       },
\       'lisp': {
\           'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\       },
\       'vim': {
\           'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
\       },
\       'html': {
\           'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
\       },
\       'css': 0,
\   }
\}

" airline
set t_Co=256 "在windows中用xshell连接打开vim可以显示色彩
set laststatus=2  " 永远显示状态栏
let g:airline_theme='bubblegum' " 选择主题
let g:airline_left_sep = '▶'
let g:airline_left_alt_sep = '❯'
let g:airline_right_sep = '◀'
let g:airline_right_alt_sep = '❮'

:BundleInstall

:PluginInstall
brew install astyle

brew install nodejs
npm install -g cnpm --registry=https://registry.npm.taobao.org --verbose
cnpm install -g js-beautify

 

  • 分屏

新增一个终端: (:term | :vert term | :rightbelow vertical terminal)    Ctrl+W 切换窗口

  • 调试

:packadd termdebug

:Termdebug a.out

Ctrl+W 切换窗口

  • 插入按行递增的数字(从n开始)

首先执行:let i=n,录制宏(qa),这个宏包含如下重要步骤(不是全部,比如可以加些定位步骤):

  • 执行:let @b=i将变量i的值赋给寄存器b
  • 利用"bP插入寄存器b的内容
  • 执行:let i=i+1让变量的值自增
  • q结束宏录制

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值