vi/vim常用配置和快捷键

快捷键

命令名 功能描述
gg 将光标移动到文档头部
G 将光标移动到文档尾部
nyy 全选文本(没有全选命令的,我的做法就是复制n行,只要n大于文本的行数就行)

如何复制文本内容到另一个文件中

使用vim进行编辑的时候,如果我们打开了两个不同的vim,此时不能用yy和p在两个Vim窗口之间进行复制和粘贴,此时,需要分割窗口,然后就可以复制粘贴了。步骤如下:

假如我们有两个需要编辑的文件a和b

1.分割:此时先打开a,然后在命令界面下输入sp

2.打开:输入e b,这样就打开了b

3.切换窗口:CTRL+w,然后输入j或者w,就可以切换窗口了。

vim高级配置

效果图:
这里写图片描述

" General
" =======
set history=1000    " History
filetype on         " Auto detech filetype
filetype indent on  " Auto indent

set nocompatible    " No compatible mode
set autoread        " Auto read file modifies
"set paste           " Keep format while paste

set encoding=utf8   " Encoding utf8

" Misc
" ====
set background=dark
syntax on
set showmode  
set colorcolumn=80      " Specific a breakline column
set cursorline " hightlight cursorline
set cursorcolumn
set number     " show linenumber
set linespace=0 " No extra spaces between rows
set hlsearch   " Hightlight search terms
set incsearch  " Find as you type search
set smartcase
set ignorecase

" Formatting
" ==========
"set nowrap          " No auto break line
set autoindent      " Auto indent

set shiftwidth=4     
set expandtab
set tabstop=4
set softtabstop=4

set nojoinspaces
set splitright
set splitbelow
set showmatch       " Show match
set matchtime=1     " Matchtime 100ms
set mat=2

"set foldenable      " Fold code
"set foldmethod=syntax
"set foldcolumn=1

" Status
" ======
set ruler
set showcmd
set so=8            " When scroll line, keep 7 lines
set cmdheight=1

" Color and Syntax
" ================
syntax enable
syntax on

" Plugins
" =======
" execute pathogen#infect()
" autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" let g:autoclose_vim_commentmode = 1

" Key Mapping
" ===========
map <C-j> <C-W>j
map <C-h> <C-W>h
map <C-k> <C-W>k
map <C-l> <C-W>l
map 0 ^
map <C-n> :NERDTreeToggle<CR>

部分用法我还仔细研究,请自行百度吧。

会继续补充,写这篇博客的目的是为了让自己记得更加牢固

猜你喜欢

转载自blog.csdn.net/flitrue/article/details/78014429