偶然发现的得超好用的vim插件——csupport,它提供的功能中我最喜欢的就是自动编译,知道emacs内置了,但是我确实是vim党派的,不会转到emacs中去,但是程序员打完代码总要回到控制台去编译和执行不觉得很可笑么?前阵子找到一个高手,它自己写了一段自动编译的函数,它的那个直接复制不行,需要打开下面提供的txt中复制设置,我这里就提供下吧:
分类: Vim
-
[转]解决Linux 下 Gvim 菜单栏没有字
正确的解决方法请参考这个:http://liulang.is-programmer.com/posts/329.html
输 入locale查看到的是
LOCALE="zh_CN.utf8"
LANG="zh_CN.utf8"
上面的是不标准的写法。标 准的写法应该是:zh_CN.UTF-8
export LANG=’zh_CN.UTF-8′
后马上 恢复正常可以显示菜单。
之前的解决办法(不修改系统的locale设置):
今天在arch linux上装了gvim,发现打开之后看不到菜单文字,上网搜索到以下解决方法,经测试,问题解决了:
参考:http://superxgz.javaeye.com/blog/81161
在 当前用户下新建一个.gvimrc文件,内容为set encoding=utf8
set langmenu=zh_CN.UTF-8
set imcmdline
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
-
我的vimrc
先简单地说一下自己的配置吧,首先就是直接使用的Vim系统附带的那个vimrc,然后把备份去掉了,但是和他的区别就是自己增加了几个自己比较常用的功能,自认为这些功能还不错,下面贴出来了。
这里的话,我增加的命令是以’\’为前缀,暂时有以下几个:
\html 自动生成html文件,将行号去除
\clean 把文件清空\copy 将全文拷贝\ 自动格式化C文件if v:progname =~? "evim"
finish
endifset nocompatible
set backspace=indent,eol,start
map \html :w<Esc>:set nonu<Esc>:source $VIMRUNTIME/syntax/2html.vim<Esc>ZZZZ
map \clean ggVGd
map \copy ggVG"y
map \ :w<Esc>:!indent "%:p" -kr -i8<Esc>
set nuset history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching" For Win32 GUI: remove ‘t’ flag from ‘guioptions’: no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")" Don’t use Ex mode, use Q for formatting
map Q gq" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>" In many terminal emulators the mouse works just fine, thus enable it.
if has(‘mouse’)
set mouse=a
endif" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif" Only do this part when compiled with support for autocommands.
if has("autocmd")" Enable file type detection.
" Use the default filetype settings, so that mail gets ‘tw’ set to 72,
" ‘cindent’ is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!" For all text files set ‘textwidth’ to 78 characters.
autocmd FileType text setlocal textwidth=78" When editing a file, always jump to the last known cursor position.
" Don’t do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don’t do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost
\ if line("’\"") > 1 && line("’\"") <= line("$") |
\ exe "normal! g`\"" |
\ endifaugroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif -
Vim 第6章 使用语法高亮 的笔记
:模式下的:syntax enable 打开语法高亮
syntax clear 关闭当前编辑文件此次语法高亮
syntax off 彻底关闭语法高亮
if &t_CO > 1 三行语句表示如果终端支持语法高亮才启用语法高亮
syntax enable Ps: t_Co, Help了一下原来是终端支持颜色的个数
endif
solorscheme xxx 使用xxx颜色方案
highlight xx yy=zz 设置xx在yy下变为zz, = =|||, (yy部分参见下面的语法高亮内容) 如:
:highlight Comment cterm=green guifg = green
就是讲term和gui下的注释变为绿色runtime syntax/colortest.vim 查看常用颜色设置的效果
hardcopy 打印当前文件 可以使用Visual模式选择要打印的范围
source $VIMRUNTIME/syntax/2html.vim 用于自动生成Html文件
查看$VIMRUNTIME/colors目录能够知道Vim支持的所有颜色高亮的方案.
在自定义Vim语法高亮时要用到下面的一些内容:term 黑白终端的显示属性
cterm 彩色终端的显示属性
ctermfg 彩色终端的前景色
ctermbg 彩色终端的背景色
gui GUI的显示属性
guifg GUI的前景色
guibg GUI的背景色
-
Vim 设置(2)
以后没看完Vim的用户手册一章就发一次上来(其实就是自己的笔记。)。set iskeyword& 恢复iskeyword的默认值
set map X xx 让x映射为xx
set compatible 兼容Vi的模式(建议不要兼容,既nocompatible)
set autoindent 开始新行时与前一行缩进相同
set backup 设置备份
set history=x 设置冒号命令和搜索命令的历史列表的长度为x
set ruler 总是在窗口的右下角显示当前光标行列信息
set showcmd 在右下角显示一个命令完整的部分(就是显示正常模式下的命令)
set showmode 总是显示当前所在的模式
set incsearch 在输入要搜索的字符串的同时就开始搜索当前输入的这部分了
filetype plugin on 开启针对不同类型使用相应的plugin
set nowrap 设置不要折行
set sidescroll=x 设置每次移动出屏幕左右时移动的字符数..(貌似没讲清楚), 要求nowrap
set whichwrap=… Vim中多数移动光标的命令会在遇到行首或行尾时停止不动。可以通过这个控制具体可以设置哪些值可以通过help ‘whichwrap’查找.
set list 可以让文件中的制表符成为可见的模式每个制表符会显示为^I, 每行末尾有$
set listchars=… 可以修改list模式(上一条)下的制表符的样式
set iskeyword=… 这个选项定义了一个word中可以包含哪些字符. 要增加值的话直接set iskeyword += …, 去掉的话set iskeyword -= …
set cmdheight=num 这个选项设置在Vim的最低下腾出几行来显示命令
学到了第5章 定制你的Vim,感觉官方的help越来越有用了。(虽然是纯英文的,不过我还是能看懂十分之七,八)
-
Vim 具名标记
ma 将当前光标的位置命名为a(可以是其他字符)
`a 跳转到标记a处
‘a 跳转到标记a所在的行
:marks 显示标记列表
`‘ 进行此次跳转之前的位置
‘” 上次编辑文件时光标最后停留的位置
‘[ 最后一次修改的起始位置
‘] 最后一次修改的结束位置
“ 回到刚刚搜索到的地方
Ctrl-O 回到早先停止光标的地方(大写O, 要按Shift)
Ctrl-I(可用Tab代替) 回到后来停止光标的地方(大写I, 要按Shift)
上面的`”和Ctrl-O, Ctrl-I 的功能和别好用..
-
Vim 搜索
搜索的一些功能:
? 向前搜索/ 向后搜索
* 向后搜索光标所在的单词(单个单词,类似\<…\>)
g* 向后搜索光标所在的单词(允许内部包含, 类似….)
# 向前搜索光标所在的单词(单个单词,类似\<…\>)
g# 向前搜索光标所在的单词(允许内部包含, 类似….)
the\> 查找单词以the结尾的
\<the 查找单词以the开头的
\<the\> 查找单词the,包含the的不算,如:there
^xx 匹配一行以xx开头的
xx$ 匹配一行以xx结尾的
c.m .这个字符可以匹配到任何字符,如c.m可以匹配com, cem
. 去掉.的特殊意思,使之变成字符’.’
“ 回到刚刚搜索到的地方
Ctrl-O 回到早先停止光标的地方(大写O, 要按Shift)
Ctrl-I(可用Tab代替) 回到后来停止光标的地方(大写I, 要按Shift)
Vim 的设置
在:命令下的一些设置,以后还会陆续添加的:compatible 兼容Vi的模式(建议不要兼容)
autoindent 开始新行时与前一行缩进相同
backup 设置备份
history=x 设置冒号命令和搜索命令的历史列表的长度为x
ruler 总是在窗口的右下角显示当前光标行列信息
showcmd 在右下角显示一个命令完整的部分(就是显示正常模式下的命令)
showmode 总是显示当前所在的模式
incsearch 在输入要搜索的字符串的同时就开始搜索当前输入的这部分了