vim使用方法:
模式:
编辑模式、未编辑模式、命令行模式
i 插入形式进入编辑模式
a 增加
o 下行编辑
O 上行插入
: 进入命令行模式
esc 退出编辑模式
wq 保存文件
yy 复制
p 粘贴
dd 删除当行
/ 搜索具体内容
dG 删除当行以及文件末尾所有内容
^ 跳转行首位置
$ 挑战行尾位置
使用:
sed -i '1i\export TOMOUT=30000000' /etc/profile && source /etc/profile sed -i '1i\export TERM=xterm' /etc/bashrc && source /etc/bashrc sed -i '1i\set mouse=a\r\nset laststatus=2\r\nset nu\r\nset nocompatible\r\nset guifont=Luxi/Mono/9\r\nfiletype on\r\nset history=1000\r\nset background=dark\r\nsyntax on\r\nset autoindent\r\nset cindent\r\nset smartindent\r\nset tabstop=4\r\nset shiftwidth=4\r\nset showmatch\r\nset guioptions-=T\r\nset incsearch\r\nset paste' /etc/vimrc && source /etc/vimrc
vim /etc/bashrc source /etc/bashrc export TERM=xterm vim /etc/vimrc source /etc/vimrc map<Space> "映射空格为: set mouse=a "任意时候显示鼠标 set laststatus=2 "总是显示状态栏 set nu "显示行号 set nocompatible "去掉有关vi一致性模式,避免以前版本的bug和局限 set guifont=Luxi/Mono/9 "设置字体,字体名称和字号 filetype on "检测文件的类型 set history=1000 "记录历史的行数 set background=dark "背景使用黑 syntax on "语法高亮度显示 set autoindent "vim使用自动对齐,也就是把当前行的对齐格式应用到下一行 自动缩进 set cindent "cindent是特别针对C语言语法自动缩进 set smartindent "依据上面的对齐格式,智能的选择对齐方式,对于类似C语言编写上有用 set tabstop=4 "设置tab键为4个空格 set shiftwidth=4 "设置当行之间交错时使用4个空格 set ai! "设置自动缩进 set showmatch "设置匹配模式,类似当输入一个左括号时会匹配相应的右括号 set guioptions-=T "去除vim的GUI版本中得toolbar set incsearch "在程序中查询一单词,自动匹配单词的位置;如查询desk单词,当输到/d时,会自动找到第一个d开头的单词,当输入到/de时,会自动找到第一个以ds开头的单词,以此类推,进行查找;当找到要匹配的单词时,别忘记回车 set paste # 关闭自动对齐 set nopaste # 开启自动对齐 set mouse=a set laststatus=2 set nu set nocompatible set guifont=Luxi/Mono/9 filetype on set history=1000 set background=dark syntax on set autoindent set cindent set smartindent set tabstop=4 set shiftwidth=4 set showmatch set guioptions-=T set incsearch set paste
vim关闭自动对齐
set paste # 关闭自动对齐 set nopaste # 开启自动对齐