VIM 入门记录

本文详细介绍了Vim编辑器的基本操作,包括编辑、复制、粘贴、移动、退出、删除、插入、替换等快捷键,并展示了如何自定义Vim配置文件以实现更友好的界面和搜索、高亮等功能。通过学习,你可以提升在Vim中的工作效率。
摘要由CSDN通过智能技术生成

1.vim快捷键

编辑模式(i o a R)命令模式(:、 ?/)一般模式(直接输入)
复制yy;yny复制 复制光标所在行;复制所在行之后n行保存w光标移动方向键;h,j,k,l
粘贴p在光标所在行之前的行粘贴退出q删除dd;ndd
插入

i;a;o

I;A;O

在光标前;后;下一行插入

在行首;行末;上一行插入

保存后退出wq;x重复操作.
替换cc替换当前行强制命令!q;!wq撤销u;ctrl+r
删除

x

X

删除光标所在字符

删除光标前字符

剪贴板粘贴模式set paste快速移动光标

G:到行首;nG:到第n行首

n+/n-:下/上移n行

0/$:当前行首/尾

   进入Visual Modev翻页

Ctrl+u,f:向上半/一页

Ctrl+d,b:向下半/一页

   搜索

/x;

n下一个,shift n上一个

  

 

 

 

 

 

 

 

2.vim界面设置

打开: vi ~/.vimrc,插入:

 1set nocompatible                " don't bother with vi compatibility "                                                
 2 set autoread                    " reload files when changed on disk, i.e. 
 3 set shortmess=atI
 4 set magic                       " For regular expressions turn magic on "
 5 set title                       " change the terminal's title "
 6 set nobackup                    " do not keep a backup file "                                                         
 7 set noerrorbells                " don't beep "
 8 set visualbell t_vb=            " turn off error beep/flash "
 9 set t_vb=
 10 set timeoutlen=500
 11
 12
 13 set encoding=utf-8
 14 set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
 15 set fileformats=unix,dos,mac
 16 set termencoding=utf-8
 17 set formatoptions+=m
 18 set formatoptions+=B
 19
 20
 21 set ruler                       " show the current row and column "
 22 set number                      " show line numbers "
 23 set nowrap
 24 set showcmd                     " display incomplete commands "                                                      
 25 set showmode                    " display current modes "
 26 set showmatch                   " jump to matches when entering parentheses "
 27 set matchtime=2               " tenths of a second to show the matching parenthesis "
 28
 29 set hlsearch                    " highlight searches "
 30 set incsearch                   " do incremental searching, search as you type "                                     
 31 set ignorecase                  " ignore case when searching "                                                       
 32 set smartcase                   " no ignorecase if Uppercase char present "                                          
 33                                                                                                                      
 34 set expandtab                   " expand tabs to spaces "                                                            
 35 set smarttab                                                                                                         
 36 set shiftround                                                                                                       
 37 set autoindent smartindent shiftround                                                                                
 38 set shiftwidth=4                                                                                                     
 39 set tabstop=4                                                                                                        
 40 set softtabstop=4                                                                                                    
 41                                                                                                                      
 42                                                                                                                      
 43 set cursorcolumn                                                                                                     
 44 set cursorline                                                                                                       
 45                                                                                                                      
 46 filetype on                                                                                                          
 47 syntax on                                                                                                            
 48 filetype plugin on                                                                                                   
 49                                                                                                                      
 50 set filetype=c                                                                                                       
 51                                                                                                                      
 52 color desert                                                                                                         
 53 set guifont=Courier\ 20                                                                                              
 54 set foldmethod=indent                                                                       

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值