vim命令 學習總結

來源:互聯網
上載者:User

:so %    重新載入.vimrc

= vim

/尋找
:nohlsearch 去掉選中詞

:%s///ig   全部替換
:s/// + &  指定行替換

>>                縮排
<<                反縮排
4>>               縮排4行

J                 合并兩行
Ctrl+f                             下全屏。
Ctrl+b                             上全屏
Ctrl+d                             下半屏。
Ctrl+u                             上半屏。
Ctrl+E                             編輯視窗中的檔案內容整體上移一行。
Ctrl+Y                             編輯視窗中的檔案內容整體下移一行。
Ctrl-O 跳轉到更早前位置 (Older)
Ctrl-I 跳回到後來停置游標更新的位置 (I在O鍵盤左邊) (與Tab一樣效果)
 b     游標左移一個字至字首
 w     游標右移一個字至字首
 e     游標右移一個字至字尾
 ge     游標左移一個字至字尾

:set ft=perl 設定檔案格式
:set fenc=   設定檔案編碼

ctrl+w gf  開啟選中  

== 習題
You are in Normal Mode as default

1. Move cursor down one line
   j
2. Return to Normal mode from Insert mode
   ESC
3. Exit the editor, discarding any changes
   :q!
4. Append text at the end of the current line
   a
5. Go forward a screen
   gg
6. Go to end of text
   G
7. Go to line 75
   :75  or  75G
8. Undo last command
   U
9. Redo last undo
   ctrl+r
10. Move cursor to next occurrence of character ''c''
    fc
11. Delete a line
    C/cc=>i or D/dd
12. Open a new line above the cursor's line and enter Insert mode
    O
13. Yank (copy) the selected text
    y
    Yank the selected text into buffer a
    "a+y
14. Put (paste) copied text after the cursor
    p
    Put (paste) copied text in buffer a after the cursor
    "a+p
15. Get help on command ''cmd''
    help cmd
16. Forward find word under cursor 尋找單詞
    * (# over cursor)
17. Match of next brace, bracket  匹配括弧
    %
18. Scroll current line to center of window
    M
19. Turn off line numbers
    set nonu
20. Move backward to previous unclosed {
    [{
21. Open ''file'' in a new tab
     :tabnew file
22. Move to previous tab
     F5
23. Move to the 3rd tab   
     :tabn 3  or  tabp 3
24. Count number of matches of a pattern  查看替換個數
    %s/pattern//n
25. Word completion in insert mode    自動補全
    ctrl+p
26. What's the location of user's vimrc file
    系統vim的設定檔

Plus(Maybe not metioned in the section):

1. Open file in new vertical split window
   :vsplit
2. Jump to the next window right, left, up, or dow
   ctrl+w hjkl
3. Stop highlighting the word that was searched for
   :nohlsearch
4. How to set in vimrc to replace tab with 4 spaces.
    set tabstop=4     tab 4
    set softtabstop=4 退格刪4
   Are there other settings about tabs and indent, research and explain the options you want to use.
    set cindent 使用c樣式縮排  set smartindent 智慧縮排
5. Share a key mapping that you think is useful
   ctrl+pageup/pagedown     在shell中滾屏
6. Any other tips you want to share
   ctrl+s  ~~~都卡住了~~~~~~~~~~~~~~~~~~~ ctrl+q恢複

配置
set nocompatible
set history=400
set ruler
set showcmd
set number
set hlsearch
set incsearch
set expandtab
set noerrorbells
set novisualbell
set t_vb= "close visual bell
set tabstop=4
set shiftwidth=4
set nobackup
set nowritebackup
set smarttab
set smartindent
set autoindent
set cindent
set wrap
set wildmenu
set autoread
set cmdheight=3
set showtabline=2
set tabpagemax=20
set laststatus=2
set noswapfile
set cursorline
set statusline=\ [File]\ %F%m%r%h\ %w\ \ %h\ \%=[Line]\ %l,%c\ %=\ %P
set whichwrap=b,s,<,>,[,],h,l "Allow move the cursor left/right to move to the previous/next line
set term=xterm
set listchars=tab:>-,trail:_
set list
"===============
"Mappings
"===============

:map <F5> :tabp<CR>
:map <F6> :tabn<CR>
:imap <F5> <ESC>:tabp<CR>i
:imap <F6> <ESC>:tabn<CR>i
function! CurrectDir()
    let curdir = substitute(getcwd(), "", "", "g")
    return curdir
endfunction
:map pp :call AddPerlHeader()<CR>
 func AddPerlHeader()
    call append(0, "\#!/usr/bin/perl")
    call append(1, "use strict;")
    call append(2, "use warnings;")
    endfunc

syntax match Trail " +$"
highlight def link Trail Todo

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.