linux下开发总是坑爹的,特别是纯命令行的服务器机子。连个gui的编译器都没,无奈之下只能用vim凑合了。vim也不那么让人省心,有些东西还是需要设置才行。
配置文件:
这个是目前用的vim配置文件,我是直接修改的/etc/vimrc,这是全局配置文件。如果只想针对某个用户可以在用户文件夹下~/.vimrc文件配置。
01 |
" If using a dark background within the editing area and syntax highlighting |
02 |
" turn on this option as well |
03 |
"set background=dark |
04 |
05 |
" Uncomment the following to have Vim jump to the last position when |
06 |
" reopening a file |
07 |
"if has("autocmd") |
08 |
" au BufReadPost * if line("'"") > 1 && line("'"") <= line("$") | exe "normal! g'"" | endif |
09 |
"endif |
10 |
11 |
" Uncomment the following to have Vim load indentation rules and plugins |
12 |
" according to the detected filetype. |
13 |
"if has("autocmd") |
14 |
" filetype plugin indent on |
15 |
"endif |
16 |
17 |
" The following are commented out as they cause vim to behave a lot |
18 |
" differently from regular Vi. They are highly recommended though. |
19 |
set nocompatible "支持方向键 |
20 |
set backspace=2 "支持backsapce前删键 |
21 |
autocmd FileType python setlocal et sta sw=4 sts=4 "缩进四个空格,用四个空格替换tab |
22 |
23 |
set ai |
24 |
set nu |
25 |
set showmatch |
26 |
set autoindent |
27 |
set cindent |
28 |
set noignorecase |
29 |
set ruler |
30 |
set scrolloff=5 |
31 |
set tabstop=3 |
32 |
set shiftwidth=3 |
33 |
set wrap |
34 |
set showcmd " Show (partial) command in status line. |
35 |
set showmatch " Show matching brackets. |
36 |
set ignorecase " Do case insensitive matching |
37 |
set smartcase " Do smart case matching |
38 |
"set incsearch " Incremental search |
39 |
"set autowrite " Automatically save before commands like :next and :make |
40 |
"set hidden " Hide buffers when they are abandoned |
41 |
"set mouse=a " Enable mouse usage (all modes),注释掉使得可以在putty上右键粘贴。 |
42 |
set smartindent |
43 |
" Source a global configuration file if available |
44 |
if filereadable("/etc/vim/vimrc.local") |
45 |
source /etc/vim/vimrc.local
|
46 |
endif |
47 |
48 |
syntax enable |
49 |
syntax on |
参数解释:
01 |
"设置方向键移动光标以及退格键。 |
02 |
set nocompatible "支持方向键
|
03 |
set backspace=2 "支持backsapce前删键
|
04 |
05 |
"这行如果不注释,右键是用于选中。 |
06 |
"注释后,右键可以粘贴内容(在putty中) |
07 |
" set mouse=a
|
08 |
09 |
autocmd FileType python setlocal et sta sw=4 sts=4 "因为是用于python编写,所以缩进四个空格,并用四个空格替换tab |
10 |
"参数详解 |
11 |
"et expandtab,将tab键展开成空格 |
12 |
"sta smartab,在行首按TAB将加入sw个空格 |
13 |
"sw shiftwidth,自动缩进插入的空格数 |
14 |
"sts softabstop,使用<Tab>或<BS>自动插入或删除相应的空格数 |
转载请注明:旅途@KryptosX » VIM设置记录
时间: 2024-10-03 19:23:32