diff --git a/chapter/Common problems.md b/chapter/Common problems.md new file mode 100644 index 0000000..08260f8 --- /dev/null +++ b/chapter/Common problems.md @@ -0,0 +1,11 @@ +# 常见问题 + +## 编辑小文件很慢 + +## 编辑大文件很慢 + +## 相同部分粘贴 (要不为什么我总要设置‘粘贴’?) + +## 使用终端中 Esc 键时的延迟 + +## 无法重复函数中执行的搜索 diff --git a/chapter/Miscellaneous.md b/chapter/Miscellaneous.md new file mode 100644 index 0000000..3241844 --- /dev/null +++ b/chapter/Miscellaneous.md @@ -0,0 +1,14 @@ +# 杂项 + +## 附加资源 + +## Vim 配置集合 + +## 内置插件 + +## 映射大写锁定键(CapsLock)到控制键(Ctrl) + +## 复活节彩蛋 + +## 为什么用 hjkl 移动光标? + diff --git a/chapter/Technical quirks.md b/chapter/Technical quirks.md new file mode 100644 index 0000000..a36ee9b --- /dev/null +++ b/chapter/Technical quirks.md @@ -0,0 +1,3 @@ +# 技术怪癖 + +## NUL 符用新行表示 diff --git a/chapter/additional-resources.md b/chapter/additional-resources.md new file mode 100644 index 0000000..60ccb3f --- /dev/null +++ b/chapter/additional-resources.md @@ -0,0 +1,12 @@ +## Դ + +| Դ | | +|----------|-------------| +| [߸Чı༭ϰ](http://www.moolenaar.net/habits.html) | ߣBram Moolenaar Vim ߣ | +| [߸Чı༭ϰ2.0PDF棩](http://www.moolenaar.net/habits_2007.pdf) | ͬ | +| [IBM DeveloperWorks: ʹýűд Vim ༭](http://www.ibm.com/developerworks/views/linux/libraryview.jsp?sort_order=asc&sort_by=Title&search_by=scripting+the+vim+editor) | Vim űд弭 | +| [ Vim ·](http://learnvimscriptthehardway.stevelosh.com) | ʹħץ Vim | +| [ Vim ʵ (2)](http://www.amazon.com/Practical-Vim-Edit-Speed-Thought/dp/1680501275/) | ȡ Vim 鼮 | +| [Vimcasts.org](http://vimcasts.org/episodes/archive) | Vim¼ʾ | +| [ΪʲôǸű vi](http://www.viemu.com/a-why-vi-vim.html) | | +| [㲻 vi㲻 Vim ](http://stackoverflow.com/a/1220118) | ,Ҫ,׼ȷĸɻ | \ No newline at end of file diff --git a/chapter/bracketed-paste.md b/chapter/bracketed-paste.md new file mode 100644 index 0000000..f7356d4 --- /dev/null +++ b/chapter/bracketed-paste.md @@ -0,0 +1,18 @@ +## ճ (ҪΪʲôҪáճ) + +ճģʽʹնּıճı + +ǷԹ Vim ճ룬Ūһ㣿 + +ֻͨ `cmd+v` `shift-insert` `middle-click` ȵճʱ +ΪʱֻնﶪıVim ֪ճıΪһĴԱˣŰ棬ʧˡ + +ʹ Vim ճ `"+p` ͲΪ⣬Ϊ Vim ֪ճ + +Ϊ˽Ҫճ `:set paste` Աȡճ״ ο `:h 'paste'` `:h 'pastetoggle'`. + +Ѿܹ˲ͣл `'paste'` һIJΪʲô[ճ](https://github.com/ConradIrwin/vim-bracketed-paste) + +ߵչĶ[ӭ](http://cirw.in/blog/bracketed-paste). + +**Neovim**: Neovim Ŭ޷Щն֧ʱԶ趨ճģʽ diff --git a/chapter/delays-when-using-escape-key-in-terminal.md b/chapter/delays-when-using-escape-key-in-terminal.md new file mode 100644 index 0000000..d364eff --- /dev/null +++ b/chapter/delays-when-using-escape-key-in-terminal.md @@ -0,0 +1,44 @@ +## ʹն Esc ʱӳ + +ʹ xterm gnome-terminal iTerm2 ȵν _ն_[ն](https://en.wikipedia.org/wiki/Computer_terminal) + +նһնʹ [˳](https://en.wikipedia.org/wiki/Escape_sequence) ߽ __ƹƶıɫȵȡ +˳һЩ˳루 [](https://en.wikipedia.org/wiki/Caret_notation) չʾΪ `^[`ͷ ASCII 봮 +յ봮ʱն [terminfo](https://en.wikipedia.org/wiki/Terminfo) ݿѰ֮ƥָ + +ΪʹȽһӳ䳬ʱӳ䳬ʱģӳʱ + +```vim +:nnoremap ,a :echo 'foo' +:nnoremap ,ab :echo 'bar' +``` + +ӳ䶼пܣ `,a` ͻһӵӳ٣Ϊ Vim ȴûټ `b` Dzˡ + +˳Ҳһ⣺ + +- `` ڷģʽ˳ָʱʹá +- ʹ˳нб +- Vim Alt ҲΪ _Meta key_ȥ͹̶ĸλ8λأǺܶն֧֣Ĭϲã˳д档 + + `vim -u NONE -N` һ˵ģȻ `i` ͻῴһ `^[`˳룩ͷıС + +ּ֮ `` һϸϵ˳ж Vim ˵һʹĹ̡ + +Ĭ `:set timeout timeoutlen=1000` Vim 1ӳڵ __ ģӳ䡣 +ӳ˵һȽֵͨΪ˽⣬Զijʱֵ + +```vim +set timeout " ӳ䳬ʱ +set timeoutlen=1000 " Ĭֵ +set ttimeout " 볬ʱ +set ttimeoutlen=10 " Сֵ +``` + +ִ `:h ttimeout` ҵһСչʾЩѡ໥ϵ + + Vim ն֮ʹõ tmux 뽫һз `~/.tmux.conf` + +```tmux +set -sg escape-time 0 +``` diff --git a/chapter/easter-eggs.md b/chapter/easter-eggs.md new file mode 100644 index 0000000..bb66cbc --- /dev/null +++ b/chapter/easter-eggs.md @@ -0,0 +1,13 @@ +## ڲʵ + +| | Ϣ | +|-----------|---------| +| `:Ni!` | `Ҫľԣ` | +| `:h 'sm'` | `ע⣺дƼ` | +| `:h 42` | `һеʲôҵǣ ˹ǵ˹Douglas AdamsΨһ֪Ѿˡܻ֪˼ʲô` | +| `:h UserGettingBored` | `ʲôʱûᰴͬһ42ΣðɣֻǿЦ :-)` | +| `:h bar` | `ⲻһ̶` | +| `:h holy-grail` | `ɪվҵˣ` | +| `:h map-modes` | `:nunmap ޵ԺҲ.` | +| `:help!` | `E478£` (? ʹģʱ (`ģ=`) `:h help.txt` һЧ) | +| `:smile` | `һ ;-) 7.4.1005.` | diff --git a/chapter/editing-huge-files-is-slow.md b/chapter/editing-huge-files-is-slow.md new file mode 100644 index 0000000..e3c0cae --- /dev/null +++ b/chapter/editing-huge-files-is-slow.md @@ -0,0 +1,20 @@ +## ༭ļ + +ļ⣬ Vim һԶȡļһ̵ȡڲṩռ䡣 +([Vim ](https://groups.google.com/forum/#!topic/vim_dev/oY3i8rqYGD4/discussion)) + +ֻȡ `tail hugefile | vim -` һܺõĽ. + +﷨趨ͲҲһʱ: + +``` +$ vim -u NONE -N +``` + +⽫ʹõ٣Ϊ۸߰﷨ʽٱʹáҲӦ Vim Ҫʹýļ Vim ϢļԱдʱijӳ١ + +``` +$ vim -n -u NONE -i NONE -N +``` + +֮д볬ļʱ Vim :\ diff --git a/chapter/editing-small-files-is-slow.md b/chapter/editing-small-files-is-slow.md new file mode 100644 index 0000000..0e519c7 --- /dev/null +++ b/chapter/editing-small-files-is-slow.md @@ -0,0 +1,17 @@ +## 编辑小文件很慢 + +对性能有重大影响的有两个方面: + +1. 复杂的**正则表达式**。尤其是 Ruby 语法文件导致人们过去一直慢慢吞吞。([Debugging syntax files](#debugging-syntax-files)里也有说明。) +2. **页面刷新**。一些特性强制所有行都刷新。 + +| 典型败笔 | 原因? | 解决方法? | +|-----------------|------|-----------| +| `:set cursorline` | 导致所有行刷新。 | `:set nocursorline` | +| `:set cursorcolumn` | 导致所有行刷新。 | `:set nocursorcolumn` | +| `:set relativenumber` | 导致所有行刷新。 | `:set norelativenumber` | +| `:set foldmethod=syntax` | 语法文件算减速的话,这无异于刹车。 | `:set foldmethod=manual`, `:set foldmethod=marker` or [快速折叠](https://github.com/Konfekt/FastFold) | +| `:set synmaxcol=3000` | 根据内部表示规则, Vim 一般不待见对很长的行。这一设定导致3000列时才会把所在行高亮。 | `:set synmaxcol=200` | +| matchparen.vim           | 使用默认加载。使用正则表达式去匹配括回。 | 禁用插件: `:h matchparen` | + +**注意**: 只有当真的遭遇实质的性能缺陷时,你才需要做这些改进。多数情况下,上面提到的这些方面还都凑合。 diff --git a/chapter/function-search-undo.md b/chapter/function-search-undo.md new file mode 100644 index 0000000..7db6925 --- /dev/null +++ b/chapter/function-search-undo.md @@ -0,0 +1,8 @@ +## ޷ظִе + +- һؼʣ`/`, `:`, ...ıˡһõĹؼʡı䱣 `/` עʹ `:echo @/` Դӡ +- һ򵥵ı޸Ŀ `.` ٴִСִб `.` עʹ `:echo @.` Դӡ + +һϲ_not_ô¶㲻ܼ򵥵һʻͬʱı޸ġ + + `:h function-search-undo` \ No newline at end of file diff --git a/chapter/map-capslock-to-control.md b/chapter/map-capslock-to-control.md new file mode 100644 index 0000000..a5bf1bb --- /dev/null +++ b/chapter/map-capslock-to-control.md @@ -0,0 +1,30 @@ +## ӳдCapsLockƼCtrl + +дڼõİҪȿƼװ +Ϊλַڼʱ[ʼ](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-homerow.png) +úܶĻӳдCapsLockƼCtrlЧ +[ظʹ˺](https://de.wikipedia.org/wiki/Repetitive-Strain-Injury-Syndrom) (ps:Ϊʲô jk ӳΪ esc jjظͬһָ˺ܴ) + +ʾϰ趨벻ˡ + +**OSX**: + +`System Preferences -> Keyboard -> Keyboard Tab -> Modifier Keys`. +"CapsLock" Ϊ "Control" + +**Linux**: + +ΪʹЧ¼з `~/.xmodmap` ļ: + + remove Lock = Caps_Lock + keysym Caps_Lock = Control_L + add Control = Control_L + +ʹ֮Ч
`$ xmodmap ~/.xmodmap` + +[caps2esc](https://github.com/oblitum/caps2esc) +[xcape](https://github.com/alols/xcape) + +**Windows**: + +ο [superuser.com: Windows8.1ӳдƼ](http://superuser.com/questions/764782/map-caps-lock-to-control-in-windows-8-1) diff --git a/chapter/newline-used-for-nul.md b/chapter/newline-used-for-nul.md new file mode 100644 index 0000000..c1abd23 --- /dev/null +++ b/chapter/newline-used-for-nul.md @@ -0,0 +1,5 @@ +## NUL бʾ + +ļе NUL `\0`ڴбУ`\n`棬ڻռʾΪ `^@` + +Ϣο `man 7 ascii` `:h NL-used-for-Nul` \ No newline at end of file diff --git a/chapter/standard-plugins.md b/chapter/standard-plugins.md new file mode 100644 index 0000000..fc5073c --- /dev/null +++ b/chapter/standard-plugins.md @@ -0,0 +1,20 @@ +## ò + +ܶ˵ϣVimԼĬϼ˴ѴѵIJ Vim `:scriptnames`鿴мصԴļ + +ЩļԶᱻõֹ² +ЩԾɻԴļгǵVimʱֻеһлᱻȡ֮ã־ִС + +| | | | +|------------|-------------------------------------|------| +| 2html | `let g:loaded_2html_plugin = 1` | `:h 2html` | +| getscript | `let g:loaded_getscriptPlugin = 1` | `:h pi_getscript` | +| gzip | `let g:loaded_gzip = 1` | `:h pi_gzip` | +| logipat | `let g:loaded_logipat = 1` | `:h pi_logipat` | +| matchparen | `let g:loaded_matchparen = 1` | `:h pi_paren` | +| netrw | `let g:loaded_netrwPlugin = 1` | `:h pi_netrw` | +| rrhelper | `let g:loaded_rrhelper = 1` | `:e $VIMRUNTIME/plugin/rrhelper.vim` | +| spellfile | `let g:loaded_spellfile_plugin = 1` | `:h spellfile.vim` | +| tar | `let g:loaded_tarPlugin = 1` | `:h pi_tar` | +| vimball | `let g:loaded_vimballPlugin = 1` | `:h pi_vimball` | +| zip | `let g:loaded_zipPlugin = 1` | `:h pi_zip` | diff --git a/chapter/vim-distributions.md b/chapter/vim-distributions.md new file mode 100644 index 0000000..8561d01 --- /dev/null +++ b/chapter/vim-distributions.md @@ -0,0 +1,18 @@ +## Vim ü + +Vim üǼɶֲԼõϡ + +߽û֪ιԼı༭üһԳѧߡ +Ҫԣôһ֤뷨ܶĶѧϰ Vim ǷøӼ򵥡 + +֪ܶ˲ñ༭ϻʱ䣨ʵϣ㿨סʱͻ᲻ͣػʱ䶨Լ vimrc +ˣҪԼʱ䣬ôȥ˽ѧϰ Vim ԭܣֻл档 + +ٴǿһ£һԱӦĹߡ + +֪֮ԼʲôҲܴ¼ Vim üлһЩС + +- [cream](http://cream.sourceforge.net) +- [janus](https://github.com/carlhuda/janus.git) +- [spacevim](https://github.com/SpaceVim/SpaceVim) +- [spf13](https://github.com/spf13/spf13-vim) diff --git a/chapter/why-hjkl-for-navigation.md b/chapter/why-hjkl-for-navigation.md new file mode 100644 index 0000000..28b5288 --- /dev/null +++ b/chapter/why-hjkl-for-navigation.md @@ -0,0 +1,8 @@ +## Ϊʲôhjklƶꣿ + + [Bill Joy](https://en.wikipedia.org/wiki/Bill_Joy) [vi](https://en.wikipedia.org/wiki/Vi)Vim ǰʱ, Ĺһ̨[ADM-3A](https://en.wikipedia.org/wiki/ADM-3A)ɵģûñļƹ꣬µ hjkl ΪƼ + +̲: [](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-adm-3a-layout.jpg) + +ҲΪʲô Unix ϵͳ`~`Ŀ¼ +