此爲vim編輯器配置,比較水,僅記錄本人目前使用的參數,做備份用。待以後對vim有精深研究後再更新。

Installation

CentOS 7最小化安裝中默認只安裝vi編輯器,而vim編輯器則是vi的升級版,功能更爲強大,可通過yum安裝

sudo yum install vim-enhanced -y

VIM (VIsual editor iMproved) is an updated and improved version of the vi editor. Vi was the first real screen-based editor for UNIX, and is still very popular. VIM improves on vi by adding new features: multiple windows, multi-level undo, block highlighting and more. The vim-enhanced package contains a version of VIM with extra, recently introduced features like Python and Perl interpreters.

Configuration File Path

文件名稱(文件名前有點,代表隱藏文件)

#全局用戶
/etc/vimrc

#root用戶
/root/.vimrc

#普通用戶
~/.vimrc

示例

[root@localhost ~]# pwd
/root
[root@localhost ~]# ls -la | grep vim
-rw-------   1 root root   6787 Nov 23 09:51 .viminfo
-rw-r--r--   1 root root    127 Aug 12 14:04 .vimrc
[root@localhost ~]#
[flying@lemp ~]$ pwd
/home/flying
[flying@lemp ~]$ ls -lA | grep vim
-rw-------    1 flying flying  8513 Jan 25 21:43 .viminfo
[flying@lemp ~]$ tail -10 /etc/vimrc

set tabstop=4
set softtabstop=4
set shiftwidth=4
set backspace=2
syntax enable
syntax on
set smartindent
set smarttab
set wrap
[flying@lemp ~]$

Configuration Parameters


" lempstacker custom configuration

set encoding=utf-8              " specify encoding
set fileformats=unix,dos,mac    " specify file formats
syntax enable                   " enable syntax highlighting
syntax on                       " syntax highlight
"set nu                         " show line number on left, nu/nonu

set ai                          " set autoindent ,set auto indent
set si                          " set smartindent, set smart indent
set wrap                        " set line wrap
set smarttab                    " be smart when using tabs
set tabstop=4
set softtabstop=4               " 1 tab == 4 spaces
set shiftwidth=4

set backspace=2
set paste                       " (重要)turning off auto indent when pasting text into vim, paste/nopaste

set nobackup                    " disable auto backup
set nowb
set noswapfile

set autoread                    " auto read when file is changed from the outside
set noignorecase                " ignore case when searching, ignorecase/noignorecase
set smartcase                   " enable smart-case search

set hlsearch                    " highlight search results, hlsearch/nohlsearch
set incsearch                   " searches for strings incrementally

set undolevels=1000	            "number of undo levels
set backspace=eol,start,indent  "backspace behaviour

"set fileformat                 " check file format
"set list                       " check hidden character, list/nolist
set ruler	                    " show row and column ruler information

Operation Procedure

以下操作對全局用戶生效

sudo tee -a /etc/vimrc <<-'EOF'

" lempstacker custom configuration

set encoding=utf-8              " specify encoding
set fileformats=unix,dos,mac    " specify file formats
syntax enable                   " enable syntax highlighting
syntax on                       " syntax highlight
"set nu                         " show line number on left, nu/nonu

set ai                          " set autoindent ,set auto indent
set si                          " set smartindent, set smart indent
set wrap                        " set line wrap
set smarttab                    " be smart when using tabs
set tabstop=4
set softtabstop=4               " 1 tab == 4 spaces
set shiftwidth=4

set backspace=2
set paste                       " (重要)turning off auto indent when pasting text into vim, paste/nopaste

set nobackup                    " disable auto backup
set nowb
set noswapfile

set autoread                    " auto read when file is changed from the outside
set noignorecase                " ignore case when searching, ignorecase/noignorecase
set smartcase                   " enable smart-case search

set hlsearch                    " highlight search results, hlsearch/nohlsearch
set incsearch                   " searches for strings incrementally

set undolevels=1000	            "number of undo levels
set backspace=eol,start,indent  "backspace behaviour

"set fileformat                 " check file format
"set list                       " check hidden character, list/nolist
set ruler	                    " show row and column ruler information
EOF

References

Change Logs

  • 2015.12.26 18:53 Sat Asia/Beijing
    • 更新文件編輯位置(全局用戶、root用戶、普通用戶)
  • 2016.01.25 23:10 Mon Asia/Beijing
    • 勘誤,上傳至lempstacker部落格
  • 2016.08.25 10:28 Thu Asia/Shanghai
    • 修改配置參數,添加Operation ProcedureReferences
  • 2016.10.17 14:31 Mon Asia/Shanghai
    • 添加配置參數set paste解決粘文本貼數據到vim時自動縮進
  • 2017.02.01 11:45 Wed America/Boston
    • 添加配置參數set ruler在文件底部顯示行數佔比信息