Vim配置文件浅析

" /etc/vimrc (configuration file for vim only)
" author: Klaus Franken     <[email protected]>
" author: Werner Fink       <[email protected]>
" author: Florian La Roche  <[email protected]>
" version: 00/01/20
" commented lines start with `"‘

" enable syntax highlighting
syntax on

" automatically indent lines (default)
" set noautoindent

" select case-insenitiv search (not default)
set ignorecase

" show cursor line and column in the status line
set ruler
set number
" show matching brackets
set showmatch

" display mode INSERT/REPLACE/...
set showmode

" changes special characters in search patterns (default)
" set magic

" Required to be able to use keypad keys and map missed escape sequences
set esckeys

" get easier to use and more user friendly vim defaults
" CAUTION: This option breaks some vi compatibility.
"          Switch it off if you prefer real vi compatibility
set nocompatible

" Complete longest common string, then each full match
" enable this for bash compatible behaviour
" set wildmode=longest,full

" Try to get the correct main terminal type
if &term =~ "xterm"
let myterm = "xterm"
else
let myterm =  &term
endif
let myterm = substitute(myterm, "cons[0-9][0-9].*$",  "linux", "")
let myterm = substitute(myterm, "vt1[0-9][0-9].*$",   "vt100", "")
let myterm = substitute(myterm, "vt2[0-9][0-9].*$",   "vt220", "")
let myterm = substitute(myterm, "\\([^-]*\\)[_-].*$", "\\1",   "")

" Here we define the keys of the NumLock in keyboard transmit mode of xterm
" which misses or hasn‘t activated Alt/NumLock Modifiers. Often not defined
" within termcap/terminfo and we should map the character printed on the keys.
if myterm == "xterm" || myterm == "kvt" || myterm == "gnome"
" keys in insert/command mode.
map! <ESC>Oo :
map! <ESC>Oj *
map! <ESC>Om -
map! <ESC>Ok +
map! <ESC>Ol ,
map! <ESC>OM
map! <ESC>Ow 7
map! <ESC>Ox 8
map! <ESC>Oy 9
map! <ESC>Ot 4
map! <ESC>Ou 5
map! <ESC>Ov 6
map! <ESC>Oq 1
map! <ESC>Or 2
map! <ESC>Os 3
map! <ESC>Op 0
map! <ESC>On .
" keys in normal mode
map <ESC>Oo :
map <ESC>Oj *
map <ESC>Om -
map <ESC>Ok +
map <ESC>Ol ,
map <ESC>OM
map <ESC>Ow 7
map <ESC>Ox 8
map <ESC>Oy 9
map <ESC>Ot 4
map <ESC>Ou 5
map <ESC>Ov 6
map <ESC>Oq 1
map <ESC>Or 2
map <ESC>Os 3
map <ESC>Op 0
map <ESC>On .
endif

" xterm but without activated keyboard transmit mode
" and therefore not defined in termcap/terminfo.
if myterm == "xterm" || myterm == "kvt" || myterm == "gnome"
" keys in insert/command mode.
map! <Esc>[H <Home>
map! <Esc>[F <End>
" Home/End: older xterms do not fit termcap/terminfo.
map! <Esc>[1~ <Home>
map! <Esc>[4~ <End>
" Up/Down/Right/Left
map! <Esc>[A <Up>
map! <Esc>[B <Down>
map! <Esc>[C <Right>
map! <Esc>[D <Left>
" KP_5 (NumLock off)
map! <Esc>[E <Insert>
" PageUp/PageDown
map <ESC>[5~ <PageUp>
map <ESC>[6~ <PageDown>
map <ESC>[5;2~ <PageUp>
map <ESC>[6;2~ <PageDown>
map <ESC>[5;5~ <PageUp>
map <ESC>[6;5~ <PageDown>
" keys in normal mode
map <ESC>[H 0
map <ESC>[F $
" Home/End: older xterms do not fit termcap/terminfo.
map <ESC>[1~ 0
map <ESC>[4~ $
" Up/Down/Right/Left
map <ESC>[A k
map <ESC>[B j
map <ESC>[C l
map <ESC>[D h
" KP_5 (NumLock off)
map <ESC>[E i
" PageUp/PageDown
map <ESC>[5~
map <ESC>[6~
map <ESC>[5;2~
map <ESC>[6;2~
map <ESC>[5;5~
map <ESC>[6;5~
endif

" xterm/kvt but with activated keyboard transmit mode.
" Sometimes not or wrong defined within termcap/terminfo.
if myterm == "xterm" || myterm == "kvt" || myterm == "gnome"
" keys in insert/command mode.
map! <Esc>OH <Home>
map! <Esc>OF <End>
map! <ESC>O2H <Home>
map! <ESC>O2F <End>
map! <ESC>O5H <Home>
map! <ESC>O5F <End>
" Cursor keys which works mostly
" map! <Esc>OA <Up>
" map! <Esc>OB <Down>
" map! <Esc>OC <Right>
" map! <Esc>OD <Left>
map! <Esc>[2;2~ <Insert>
map! <Esc>[3;2~ <Delete>
map! <Esc>[2;5~ <Insert>
map! <Esc>[3;5~ <Delete>
map! <Esc>O2A <PageUp>
map! <Esc>O2B <PageDown>
map! <Esc>O2C <S-Right>
map! <Esc>O2D <S-Left>
map! <Esc>O5A <PageUp>
map! <Esc>O5B <PageDown>
map! <Esc>O5C <S-Right>
map! <Esc>O5D <S-Left>
" KP_5 (NumLock off)
map! <Esc>OE <Insert>
" keys in normal mode
map <ESC>OH 0
map <ESC>OF $
map <ESC>O2H 0
map <ESC>O2F $
map <ESC>O5H 0
map <ESC>O5F $
" Cursor keys which works mostly
" map <ESC>OA k
" map <ESC>OB j
" map <ESC>OD h
" map <ESC>OC l
map <Esc>[2;2~ i
map <Esc>[3;2~ x
map <Esc>[2;5~ i
map <Esc>[3;5~ x
map <ESC>O2A ^B
map <ESC>O2B ^F
map <ESC>O2D b
map <ESC>O2C w
map <ESC>O5A ^B
map <ESC>O5B ^F
map <ESC>O5D b
map <ESC>O5C w
" KP_5 (NumLock off)
map <ESC>OE i
endif

if myterm == "linux"
" keys in insert/command mode.
map! <Esc>[G <Insert>
" KP_5 (NumLock off)
" keys in normal mode
" KP_5 (NumLock off)
map <ESC>[G i
endif

" This escape sequence is the well known ANSI sequence for
" Remove Character Under The Cursor (RCUTC[tm])
map! <Esc>[3~ <Delete>
map <ESC>[3~ x

" Only do this part when compiled with support for autocommands.
if has("autocmd")
" 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).
autocmd BufReadPost *
\ if line("‘\"") > 0 && line("‘\"") <= line("$") |
\ exe "normal g`\"" |
\ endif

endif " has("autocmd")

" Changed default required by SuSE security team--be aware if enabling this
" that it potentially can open for malicious users to do harmful things.
set modelines=0

" get easier to use and more user friendly vim defaults
" /etc/vimrc ends here

Vim配置文件浅析

时间: 2025-01-01 13:27:07

Vim配置文件浅析的相关文章

强大的vim配置文件,让编程更随意

花了很长时间整理的,感觉用起来很方便,共享一下. 我的vim配置主要有以下优点: 1.按F5可以直接编译并执行C.C++.java代码以及执行shell脚本,按"F8"可进行C.C++代码的调试 2.自动插入文件头 ,新建C.C++源文件时自动插入表头:包括文件名.作者.联系方式.建立时间等,读者可根据需求自行更改 3.映射"Ctrl + A"为全选并复制快捷键,方便复制代码 4.按"F2"可以直接消除代码中的空行 5."F3"

mac 下vim 配置文件

" Configuration file for vim set modelines=0 " CVE-2007-2438 " Normally we use vim-extensions. If you want true vi-compatibility " remove change the following statements set nocompatible " Use Vim defaults instead of 100% vi compa

vim配置文件 高亮+自动缩进+行号+折叠+优化

配置文件是网上找的,我把出错的几个地方改了下 将一下代码copy到 用户目录下 新建文件为  .vimrc保存即可生效: 如果想所有用户生效 请修改 /etc/vimrc (建议先cp一份) "========================================================================= " DesCRiption: 适合自己使用的vimrc文件,for Linux/Windows, GUI/Console " "

分享一下个人的Vim配置文件

强烈拥护开源精神,高举开源大旗,今天我就分享下我自己结合网上还有自己实际使用配的vimrc,可以给各位参考下,不要见笑哈,具体说明我在rc里写的也很详细,可以具体看下,也希望可以借这个机会能多认识认识几个Vimer们 "======================================== " File Name: .vimrc " Author: Jin Yuqi " Email: [email protected] " Description

vim 配置文件 ,高亮+自动缩进+行号+折叠+优化

vim 配置文件 ,高亮+自动缩进+行号+折叠+优化 将一下代码copy到 用户目录下 新建文件为  .vimrc保存即可生效: 如果想所有用户生效 请修改 /etc/vimrc (建议先cp一份)"=========================================================================" DesCRiption: 适合自己使用的vimrc文件,for Linux/Windows, GUI/Console""

[转] vim配置文件.vimrc

--------------------------------------------------------------------------- 转自:http://www.cnblogs.com/wangj08/archive/2013/03/13/2957309.html ------------------------------------------------------------------------------------- vim 配置文件 ,高亮+自动缩进+行号+折

我的 vim 配置文件

vim 配置文件存放路径 : ~/.vimrc 点(.)开头的文件,系统默认不显示,需要使用 ls -a 选项. syntax on set nobackup set noswapfile set hlsearch set number set ruler set expandtab set tabstop=4 set softtabstop=4 set shiftwidth=4 set autoindent set cindent set smartindent set mouse=v set

vim配置文件--显示行号tabstop设置

在Red Hat Linux 中管理员的vim的配置文件存放在/etc/vimrc set nocompatible            //去掉有关vi一致性模式,避免以前版本的bug和局限 set nu                      //显示行号 等等配置信息都在vimrc这个文件下,可以查看该文件下的具体设置. 如果是普通用户,可以再普通用户的主目录(~)下即cd跳转到的那个文件目录,新建一个.vimrc文件: 如 set nu set tabstop=4       //按

强大的vim配置文件,让编程更随意(转)

欢迎来到小码哥的博客 博客搬家啦 blog.ma6174.com 强大的vim配置文件,让编程更随意 花了很长时间整理的,感觉用起来很方便,共享一下. 我的vim配置主要有以下优点: 1.按F5可以直接编译并执行C.C++.java代码以及执行shell脚本,按"F8"可进行C.C++代码的调试 2.自动插入文件头 ,新建C.C++源文件时自动插入表头:包括文件名.作者.联系方式.建立时间等,读者可根据需求自行更改 3.映射"Ctrl + A"为全选并复制快捷键,方