K.I.S.S. – 简单哲学 Linux, Freedom, Arch, Python, Gtk+, C … Keep It Simple, Stupid!

21三/092

Show 一下我的 Vim

正在学 VC++,当然是先学 ++,可是每次打开一个虚拟机,用那个一点也不好用的 VC++ 编程,真是一件痛苦的事情……
于是我卧薪尝胆、发奋图强,终于把 配置得差不多了。
看一下效果~

vim_autocomplete.png

我的 .vimrc:

"设定操作系统
function! MySys()
return "linux"
endfunction

"""""""""""""""""""""""""""""""""""""""
"常规
"""""""""""""""""""""""""""""""""""""""
"编码
set fileencodings=ucs-bom,utf-8,gb18030,gb2312,gbk,cp936
"文件类型识别
filetype plugin indent on
"设置shell
if MySys() == "linux"
set shell=bash
endif
"关闭兼容模式
set nocompatible
"外部修改时自动读取
set autoread
"设置鼠标
set mouse=a
"设置历史
set history=400
"设置mapleader
let mapleader=","
let g:mapleader=","
let g:C_MapLeader=","
"设置Tlist
"let Tlist_Show_One_File=1
"let Tlist_Auto_Open=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_SingleClick=1
let Tlist_Auto_Highlight_Tag=1
let tlist_make_settings='make;m:makros;t:targets'
let tlist_qmake_settings='qmake;t:SystemVariables'
"winManager
let g:persistentBehaviour=0
let g:winManagerWindowLayout='FileExplorer|TagList'
:set cscopequickfix=s-,-,d-,i-,t-,e-

"""""""""""""""""""""""""""""""""""""""
"界面
"""""""""""""""""""""""""""""""""""""""

"显示行号
set number
"显示光标位置
set ruler
"增强命令行补全
set wildmenu
"设置命令行高度
set cmdheight=2
"减少刷新和重画
set lz
"设置退格键
set backspace=eol,start,indent
"设置跨行键
set whichwrap+=<,>,h,l
"搜索时忽略大小写
set ignorecase
"搜索时高亮关键字
set hlsearch
"设置magic
set magic
"关闭提示音
set noerrorbells
set novisualbell
set vb t_vb=
"自动匹配括号
set showmatch
set mat=2

"""""""""""""""""""""""""""""""""""""""
"文本
"""""""""""""""""""""""""""""""""""""""

"设置Tab键
set expandtab
set smarttab
set tabstop=4
set shiftwidth=4
"自动缩进与智能缩进
set autoindent
set smartindent
"换行不截断单词
set linebreak
"风格缩进
set cindent
set guifont=terminus\ 10
"自动补全
set completeopt=longest,menu

"""""""""""""""""""""""""""""""""""""""
"状态条
"""""""""""""""""""""""""""""""""""""""

set laststatus=2

"""""""""""""""""""""""""""""""""""""""
"外观
"""""""""""""""""""""""""""""""""""""""

"语法高亮
syntax enable
"设置颜色主题
set t_Co=256
colorscheme darkblue
"高亮当前行
set cursorline
if has("gui_running")
 colorscheme slate
 hi cursorline guibg=#333333
 hi CursorColumn guibg=#333333
endif
"高亮菜单
hi Pmenu guibg=#333333
hi PmenuSel guibg=#555555 guifg=#ffffff

""""""""""""""""""""""""""""""""""""""
"
"""""""""""""""""""""""""""""""""""""""

set tags+=/home/iven/./gtktags
set autochdir

"""""""""""""""""""""""""""""""""""""""
"补全快捷键
"""""""""""""""""""""""""""""""""""""""

function! SuperCleverTab()
 if strpart(getline('.'), 0, col('.') - 1) =~ '^\s*$'
 return "\"
 else
 if &omnifunc != ''
 return "\\"
 elseif &dictionary != ''
 return "\"
 else
 return "\"
 endif
 endif
endfunction

inoremap  =SuperCleverTab()

""""""""""""""""""""""""""""""""""""""
"快捷键
"""""""""""""""""""""""""""""""""""""""
"Tlist
noremap   :Tlist
inoremap   :Tlist
map w :WMToggle
"快速保存
nmap w :w
"快速重载.vimrc
"map s :source ~/.vimrc
"快速编辑.vimrc
"map e :e ~/.vimrc
"当.vimrc改变时,自动重载
autocmd! bufwritepost vimrc source ~/.vimrc
"Paste toggle - when pasting something in, don't indent.
set pastetoggle=
"Remove indenting on empty lines
map  :%s/\s*$//g:noh''
"去除空行
map  :g/^$/d
"Super paste
inoremap  :set pastemui+mv'uV'v=:set nopaste
"切换Tab
map  :tabnext
"切换buffer
map bn :bnext
map bp :bprevious
"生成
map cta :! -R --++-kinds=+p --fields=+iaS --extra=+q:TlistUpdate

"""""""""""""""""""""""""""""""""""""""
"Python
"""""""""""""""""""""""""""""""""""""""

"自动补全
autocmd FileType python set complete+=k~/./pydiction isk+=.,
"快速运行
au FileType python map   :w!:!python %
"快速补全
au FileType python inoremap  $r return
au FileType python inoremap  $s self
au FileType python inoremap  $ ####kla
au FileType python inoremap  $i import
au FileType python inoremap  $p print
au FileType python inoremap  $d """"""O

呵呵,接下来就是学习 本身的用法了……可是不知道什么时候才有时间……
配置时参考了 Easwy Yang 大侠的《使用进阶》,在此深表感谢!

标签: 2 评论
13二/090

Vim中删除空行的方法

:g/^$/d
标签: 没有评论
17一/090

用vim格式化代码

虽然不是第一次听说,但是第一次用的感觉还是很神奇。
以下转自:http://hi.baidu.com/seesea8/blog/item/b96c8e51eb8f352743a75b41.html
从别的编辑器里粘贴到里的代码经常由于不正常的缩进变得格式混乱。在的官方FAQ (http://vimdoc.sourceforge.net/cgi-bin/vimfaq2html3.pl)找到的:
格式化全文:

gg=G

自动缩进当前行:

==

这个是原文节选:

14.6. How do I format/indent an entire file?

You can format/indent an entire file using the gg=G command, where

gg - Goto the beginning of the file
= - apply indentation
G - till end of file

For more information, read

:help gg
:help =
:help G
:help 'formatprg'
:help -indenting

标签: , 没有评论
11一/090

Vim 对Gtk+ API 函数自动补全(转载)

转自:http://www.91linux.com/html/article/linux_soft/20090103/15308.html

的API有很多,如何在使用时让自动补全呢?
其实已经有此功能了,这就是的自动补全功能。包括ctrl-N,ctrl-P以及Ommi 补全功能。
当然了,还有对包含的头文件的自动搜索。但是编写程序有一点不方便的是,它包的是.h
,而.h中是一大堆的*.h文件,显然是不可能在.h中找到什么有用的东西的。
是不是有别的什么办法呢?

linux的使用在于小巧组合,配合即可完成此任务。步骤如下:
1.首先进入/usr/include/-2.0/目录,下面有很多头文件,我们要在此目录下生成一个tags文件供使用。
2.执行 -R
3.将生成的tags文件copy到你的工作目录,即你写程序的地方。
4.再执行 -a //将你写的程序的函数appended 到此文件上。

OK,大功告成。这下你写程序时,即可ctrl-N/P来自动补全的API了。
不过使用时列表中的函数是有点多了,选择起来反而有点麻烦,但总比没有要好。