: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