您的位置:首页 > 其它

vim命令 学习总结

2012-12-04 12:12 393 查看
: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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: