zoukankan      html  css  js  c++  java
  • Vim编辑器的使用和基本配置

    三种模式

    1 命令模式
      插入 a i o A I O
      定位 gg G :n nG ngg $ 0
      删除 x nx dd ndd dG
      复制和剪切 yy-p dd-p
      替换 r R
      撤销和恢复 u Ctrl+r
      搜索和替换 /关键词 n :范围/old/new/g

    2 插入模式
      
    3 编辑模式
      :set nu
      :wq ZZ :wq!
      :q :q!
      :w file_name  
    一些技巧  配置文件:~/.vimrc

    1 导入命令的执行结果 :r !command
      :r filename 导入文件内容
      :!command 不退出的情况下使用系统命令
      :r !命令 eg. :r !date

    2 定义快捷键 (编辑模式设置只是临时生效,要永久生效需要写入配置文件[不用前面的':'])
    命令模式下的快捷键: :map 快捷键 触发命令  注意 ^是Ctrl+V, 不是Shift+6, 也可以用<C+p>
      范例 :map ^P I#<ESC> 行首加#注释
         :map ^B 0x 删除行首的#
         :map ^H 0
         :map ^L $
        

    插入模式下的快捷键: imap 快捷键 命令
        :imap ^H <Left> //这样可以不用方向键移动光标了
        :imap ^L <Right>
        :imap ^B <Backspace>
        :imap ^D <Delete>


    3 连续行注释
      :n1,n2s/^/#/g
      :n1,n2s/^#//g
      :n1,n2s/^////g
        正则表达式: ^行首 $行尾

    4 替换
      :ab mymail xxx@mail.com
        当插入mymail时会自动变成后者

    以上只有写入配置文件才能永久生效
    配置文件为 用户的家目录下的 .vimrc 进入家目录 cd 或 cd ~

    个人配置文件  ~/.vimrc  

    "Basic
    set nu
    set autoindent
    set mouse=a
    set backspace=2
    set smartindent
    
    "Scheme color
    set tabstop=4
    syntax enable
    set t_Co=256
    set background=dark
    colorscheme molokai
    
    " 设置vim背景透明,还要先设置终端背景透明度(直接在终端配置文件里设置即可)
    hi Normal  ctermfg=252 ctermbg=none
    
    "快捷键映射 
    "map -- 命令模式, imap -- 插入模式
    " ^H <= ctrl+v h <CR> == Enter
    autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
    " map
    <F3> :NERDTreeToggle<CR> map <F5> :w<Enter> map  I#<ESC> map  0x<ESC> map <Tab> I<Tab><Esc> map <C-> I<Backspace><Esc> map  ^H 0 map ^L $ map <C-up> ddkkp map <C-down> ddp map <C-S-down> yyp map <C-S-up> ddk map <CR> A<CR><Esc> map <C-F5> :!python3 % <CR> 在py文件中直接 Ctrl+F5 运行该文件
    "插入模式下 不用方向键 快速移动光标,退格,删除 imap
    <C-h> <Left> imap <C-l> <Right> imap <C-k> <Up> imap <C-j> <Down> imap <C-b> <Backspace> imap <C-d> <Delete>
    imap <F5> <ESC>:w<Enter> imap () ()<Left> imap [] []<Left> imap {} {}<Left> imap <> <><Left> imap '' ''<Left> imap "" ""<Left>
    "插件管理工具
    "
    Vundle for plugin set nocompatible filetype off set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'VundleVim/Vundle.vim' "可以在这是添加要安装的插件 Plugin 'Valloric/YouCompleteMe' "Plugin 'SirVer/ultisnips' "Plugin 'honza/vim-snippets' Plugin 'scrooloose/nerdtree' Plugin 'kien/ctrlp.vim' Plugin 'tomasr/molokai' Plugin 'rkulla/pydiction' Plugin 'pangloss/vim-javascript' Plugin 'Shougo/neocomplcache.vim' Plugin 'moll/vim-node' Plugin 'myhere/vim-nodejs-complete' Plugin 'mattn/emmet-vim' call vundle#end() filetype plugin indent on "Python pydiction -- Tab-complete filetype plugin on let g:pydiction_location = '/home/sqd/.vim/bundle/pydiction/complete-dict' let g:pydiction_menu_height = 4 "Node.js vim-node autocmd User Node if &filetype == "javascript" | setlocal expandtab | endif autocmd FileType css set omnifunc=csscomplete#CompleteCSS autocmd FileType html set omnifunc=htmlcomplete#CompleteTags

    效果图

    KEEP LEARNING!
  • 相关阅读:
    tps,qps
    JS打包与代码分割
    css module
    垃圾回收算法、内存管理
    css flex布局
    angularJS transclude
    JS模块之AMD, CMD, CommonJS、UMD和ES6模块
    js event loop事件循环
    bootstrap3之栅格系统
    viewport理解
  • 原文地址:https://www.cnblogs.com/roronoa-sqd/p/4874442.html
Copyright © 2011-2022 走看看