美文网首页
Vi编辑器

Vi编辑器

作者: 丶沙工 | 来源:发表于2017-03-12 07:02 被阅读56次

键盘图

命令

i 光标前插入
o 当前行下插入新行
dd 删除当前行
yy 复制行
n+yy 复制多行
p粘贴
u 撤销操作
r 替换字符
/ 查找关键字

  • ex
    :w 保存
    :q 退出
    :q! 强制退出
    :x 保存退出
    set number 显示行号
    :!系统命令 执行系统命令
    :sh 切换到命令行

安装VIM中文帮助文档

  1. 打开一个终端
  2. 下载vimcdoc-1.8.0.tar.gz 下载地址
  3. 解压
    tar -zxvf vimcdoc-1.8.0.tar.gz
  4. 进入解包后的文件夹
    cd vimcdoc-1.8.0
  5. 安装
    sudo ./vimcdoc.sh -i
  6. 测试打开vim
    输入:helpor:h如果成功就应该看到中文帮助文档

VIM进阶

显示行号:

set nu

语法高亮:

syntax on

vim 跳到指定行:

:n

检索:

/string

.vimrc

    " This line should not be removed as it ensures that various options are
    " properly set to work with the Vim-related packages available in Debian.debian.vim

    " Uncomment the next line to make Vim more Vi-compatible
    " NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
    " options, so any other options should be set AFTER setting 'compatible'.
    set nocompatible

    " Vim5 and later versions support syntax highlighting. Uncommenting the
    " following enables syntax highlighting by default.
    if has("syntax")
      syntax on            " 语法高亮                                                                                                                                                           
    endif                                                                                                                                                                                       
    colorscheme ron        " elflord ron peachpuff default 设置配色方案,vim自带的配色方案保存在/usr/share/vim/vim72/colors目录下                                                               
                                                                                                                                                                                                
    " detect file type                                                                                                                                                                          
    filetype on                                                                                                                                                                                 
    filetype plugin on                                                                                                                                                                          
                                                                                                                                                                                                
    " If using a dark background within the editing area and syntax highlighting                                                                                                                
    " turn on this option as well                                                                                                                                                               
    set background=dark                                                                                                                                                                         
                                                                                                                                                                                                
    " Uncomment the following to have Vim jump to the last position when                                                                                                                        
    " reopening a file                                                                                                                                                                          
    if has("autocmd")                                                                                                                                                                           
      au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif                                                                                              
      "have Vim load indentation rules and plugins according to the detected filetype                                                                                                           
      filetype plugin indent on                                                                                                                                                                 
    endif

    " The following are commented out as they cause vim to behave a lot
    " differently from regular Vi. They are highly recommended though.

    "set ignorecase        " 搜索模式里忽略大小写
    "set smartcase        " 如果搜索模式包含大写字符,不使用 'ignorecase' 选项。只有在输入搜索模式并且打开 'ignorecase' 选项时才会使用。
    set autowrite        " 自动把内容写回文件: 如果文件被修改过,在每个 :next、:rewind、:last、:first、:previous、:stop、:suspend、:tag、:!、:make、CTRL-] 和 CTRL-^命令时进行;用 :buffer、CTRL-O、CTRL-I、'{A-Z0-9} 或 `{A-Z0-9} 命令转到别的文件时亦然。
    set autoindent        " 设置自动对齐(缩进):即每行的缩进值与上一行相等;使用 noautoindent 取消设置
    "set smartindent        " 智能对齐方式
    set tabstop=4        " 设置制表符(tab键)的宽度
    set softtabstop=4     " 设置软制表符的宽度    
    set shiftwidth=4    " (自动) 缩进使用的4个空格
    set cindent            " 使用 C/C++ 语言的自动缩进方式
    set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s     "设置C/C++语言的具体缩进方式
    "set backspace=2    " 设置退格键可用
    set showmatch        " 设置匹配模式,显示匹配的括号
    set linebreak        " 整词换行
    set whichwrap=b,s,<,>,[,] " 光标从行首和行末时可以跳到另一行去
    "set hidden " Hide buffers when they are abandoned
    set mouse=a            " Enable mouse usage (all modes)    "使用鼠标
    set number            " Enable line number    "显示行号
    "set previewwindow    " 标识预览窗口
    set history=50        " set command history to 50    "历史记录50条


    "--状态行设置--
    set laststatus=2 " 总显示最后一个窗口的状态行;设为1则窗口数多于一个的时候显示最后一个窗口的状态行;0不显示最后一个窗口的状态行
    set ruler            " 标尺,用于显示光标位置的行号和列号,逗号分隔。每个窗口都有自己的标尺。如果窗口有状态行,标尺在那里显示。否则,它显示在屏幕的最后一行上。

    "--命令行设置--
    set showcmd            " 命令行显示输入的命令
    set showmode        " 命令行显示vim当前模式

    "--find setting--
    set incsearch        " 输入字符串就显示匹配点
    set hlsearch 

资料

My Vim configuration
安装vim中文帮助vimcdoc
Vim简明教程【CoolShell】
超强vim配置文件 【推荐】

相关文章

  • 学习笔记之vi/vim编辑器命令一文知晓常用可精通

    VI 编辑器就是linux下的文本编辑器 VI编辑器的特点,可以说是linux上最经典的文本编辑器 VI编辑器特点...

  • Linux入门学习笔记(七)vi 编辑器

    vi 编辑器 文本编辑器,子处理器 ASCII,sed, vi: Visual Interface vim: VI...

  • 2018-09-24 vim命令详解

    vim:文本编辑器vi:visual interfacevim: VI improved全屏编辑器,模式化编辑器...

  • vi编辑器的使用

    vi编辑器的使用 关键词:VI,vi编辑器, 1、关于文本编辑器 文本编辑器有很多,比如图形模式的gedit、kw...

  • Linux:10、Vim编辑器

    vim编辑器是由vi发展而来,所以,我们先了解一下vi编辑器 一、Vi简介 vi是“Visual interfac...

  • 第10章 使用编辑器

    10.1 vim编辑器 vi编辑器是Unix系统最初的编辑器。vi improved or vim 是GUN项目的...

  • VI文本编辑器

    VI文本编辑器 在本教程中,你将学习 - [TOC] 什么是VI编辑器? VI编辑器是Linux系列中最受欢迎和最...

  • Linux文件管理(下)

    一、VIM编辑器 1、vi概述 vi(visual editor)编辑器通常被简称为vi,它是Linux和Unix...

  • linux vi/vim 使用

    介绍 vi编辑器是所有Unix及Linux系统下标准的编辑器,Vi也是Linux中最基本的文本编辑器。使用vi是l...

  • 文本编辑工具------vi

    vi是Linux下默认的编辑器,几乎所有的Linux/UNIX都捆绑了vi。也可以用vim编辑器 vi编辑器有两种...

网友评论

      本文标题:Vi编辑器

      本文链接:https://www.haomeiwen.com/subject/fshtnttx.html