zoukankan      html  css  js  c++  java
  • VI小抄

    Move

    • h j k l
    • Move to file begin
      gg
    • Move to file end
      G
    • Move to line 3
      :3

    Copy & Paste

    • Copy
      y
    • Cut
      d
    • Paste
      p

    Search & Replace

    • Search
      /Apple
    • Search by word
      /\<Apple\>
    • Search ignorecase
      /Apple\c
    • Replace in lines
      :1,10s/Apple/Banana
    • Replace in a file
      :%s/Apple/Banana/g
    • Count items
      :%s/Apple/&/gn
    • Search in files
      vimgrep /Apple/ *.txt
      grep -R . --include='*.cxx' -i -e 'Apple' (You can open the quickfix list by :copen)

    Align several lines

    1. Go to first line and enter Visual Mode by CRTL-v
    2. Move to the last line and select the lines by SHIFT-v
    3. Align the lines to have 4 spaces in the left by entering :'<,'>left 4
      (You may need enable ":set expandtab" to insert tab by spaces.)

    Undo & Redo

    • Undo
      u
    • Redo
      CTRL-r

    New Window & Split Window

    • New window
      :new
    • Switch between windows
      CTRL-w CTRL-w
      CTRL-w h (or j, k, l)
    • Split horizontal window
      CTRL-w s
    • Split vertical window
      CTRL-w v
    • Close a window
      :q
    • Close other windows
      CTRL-w o

    Display

    • Display line number
      :set number
    • Set tab stop
      :set tabstop=4
    • Insert space to tab
      :set expandtab (reversely, :set noexpandtab)
    • Highlight cursor line and column
      :set cursorline
      :set cursorcolumn
    • Folding with marker
      :set foldenable
      :set foldmethod=marker
      :set foldmarker={{{,}}}
      (Then you can wrap the sections with {{{ and }}} to create folders and sub-folders. You can add comments after {{{ to add the folder comment)
      Close a folder by zc
      Open a folder by zo

    Tag

    • Generate tag file
      ctags --extra=+q -R .
      ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
    • Install taglist (http://vim-taglist.sourceforge.net/installation.html)
    • Show tag list
      :Tlist
    • Go to a tag
      :ta class::member
      :ta class.member
      :ta /disp*
      CTRL-] (go to tag)
      CTRL-T (go back)
    • Set Multiple Tag files
      :set tags:=~/a/tags;~/b/tags
      :set tags+=/my/path/to/tags
    • Set Tag Files Recursively
      :set tags=./tags;/.

    Cscope

    • Generate cscope file
      find . -name '*.hxx' -print > cscope.files
      find . -name '*.cxx' -print >> cscope.files
      cscope -b
    • Find functions calling this function
      :cs find c foo
    • Find a function definition and show the result in a newly splitted window
      :scs find g foo
    • Show cscope file (up to 8)
      :cs show
    • Add a cscope file
      :cs add yourfile
    • Add the line to your ~/.vimrc to map "cscope find e" to Ctrl-\
      nmap <C-\> :cs find e <C-R>=expand("<cword>")<CR><CR>

    Word Completion

    • C-x C-n
  • 相关阅读:
    算法基础_递归_求杨辉三角第m行第n个数字
    算法基础_递归_返回字符串的反串
    算法基础_递归_求两个字符串的公共最长子序列长度
    算法基础_递归_全排列问题
    玩转数据结构:第7章 集合和映射
    Java8 新特性_Stream API
    一、VIP课程:互联网工程专题 04-Maven私服使用与插件开发
    Java8 新特性_Lambda 表达式
    一、VIP课程:互联网工程专题 03-Maven基本概念与核心配置
    玩转数据结构:第6章 二分搜索树
  • 原文地址:https://www.cnblogs.com/frankbadpot/p/1582780.html
Copyright © 2011-2022 走看看