From 8a2b0764985d7e4d8501aa92a8585f84d2daa834 Mon Sep 17 00:00:00 2001 From: chengrui Date: Mon, 27 Mar 2017 11:33:10 +0800 Subject: [PATCH 01/18] list chapters to translate --- chapter/Common problems.md | 0 chapter/Miscellaneous.md | 281 ++++++++++++++++++ chapter/additional-resources.md | 0 chapter/bracketed-paste.md | 0 ...elays-when-using-escape-key-in-terminal.md | 0 chapter/easter-eggs.md | 0 chapter/editing-huge-files-is-slow.md | 0 chapter/editing-small-files-is-slow.md | 0 chapter/function-search-undo.md | 0 chapter/map-capslock-to-control.md | 0 chapter/standard-plugins.md | 0 chapter/vim-distributions.md | 0 chapter/why-hjkl-for-navigation.md | 0 13 files changed, 281 insertions(+) create mode 100644 chapter/Common problems.md create mode 100644 chapter/Miscellaneous.md create mode 100644 chapter/additional-resources.md create mode 100644 chapter/bracketed-paste.md create mode 100644 chapter/delays-when-using-escape-key-in-terminal.md create mode 100644 chapter/easter-eggs.md create mode 100644 chapter/editing-huge-files-is-slow.md create mode 100644 chapter/editing-small-files-is-slow.md create mode 100644 chapter/function-search-undo.md create mode 100644 chapter/map-capslock-to-control.md create mode 100644 chapter/standard-plugins.md create mode 100644 chapter/vim-distributions.md create mode 100644 chapter/why-hjkl-for-navigation.md diff --git a/chapter/Common problems.md b/chapter/Common problems.md new file mode 100644 index 0000000..e69de29 diff --git a/chapter/Miscellaneous.md b/chapter/Miscellaneous.md new file mode 100644 index 0000000..44266b5 --- /dev/null +++ b/chapter/Miscellaneous.md @@ -0,0 +1,281 @@ +# Miscellaneous + +## Additional resources + +| Resource | Description | +|----------|-------------| +| [Seven habits of effective text editing](http://www.moolenaar.net/habits.html) | By Bram Moolenaar, the author of Vim. | +| [Seven habits of effective text editing 2.0 (PDF)](http://www.moolenaar.net/habits_2007.pdf) | See above. | +| [IBM DeveloperWorks: Scripting the Vim editor](http://www.ibm.com/developerworks/views/linux/libraryview.jsp?sort_order=asc&sort_by=Title&search_by=scripting+the+vim+editor) | Five-part series on Vim scripting. | +| [Learn Vimscript the Hard Way](http://learnvimscriptthehardway.stevelosh.com) | Develop a Vim plugin from scratch. | +| [Practical Vim (2nd Edition)](http://www.amazon.com/Practical-Vim-Edit-Speed-Thought/dp/1680501275/) | Hands down the best book about Vim. | +| [Vimcasts.org](http://vimcasts.org/episodes/archive) | Vim screencasts. | +| [Why, oh WHY, do those #?@! nutheads use vi?](http://www.viemu.com/a-why-vi-vim.html) | Common misconceptions explained. | +| [Your problem with Vim is that you don't grok vi](http://stackoverflow.com/a/1220118) | Concise, informative and correct. A real gem. | + +## Vim distributions + +Vim distributions are bundles of custom settings and plugins for Vim. + +More advanced users know how to configure their editor anyway, so distributions +are mostly targeted at beginners. If you think about that, it's quite +paradoxical though: Making it easier by adding even more things to learn about? + +I know that many people don't want to spend hours and hours on customizing an +editor (and actually you never stop customizing your vimrc when you finally got +hooked), but eventually you only get efficient in Vim when you take the time to +learn it properly. + +Repeat after me: "A programmer should know their tools." + +Anyway, if you know what you're doing, you might draw some inspiration from +looking at a few distributions: + +- [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) + +## Standard plugins + +Surprising to many people, Vim comes with a handful of plugins on its own that +all get loaded by default. Check `:scriptnames` after starting Vim to see all +sourced files. + +Most of them will never get used, so disable them as you see fit. They will +still be shown as sourced, but only the first lines actually get read before Vim +bails out. No further code (mappings, commands, logic) will be processed. + +| Plugin | Disable it using.. | Help | +|------------|-------------------------------------|------| +| 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` | + +## Map CapsLock to Control + +CapsLock belongs to the most useless keys on your keyboard, but it's much easier +to reach than the Control key, since it lies on your [home +row](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-homerow.png). +Mapping CapsLock to Control is a great way to prevent or at least reduce +[RSI](https://de.wikipedia.org/wiki/Repetitive-Strain-Injury-Syndrom) if you +program a lot. + +Attention: When you get used to it, you can't live without it anymore. + +**OSX**: + +`System Preferences -> Keyboard -> Keyboard Tab -> Modifier Keys`. Change +"CapsLock" to "Control". + +**Linux**: + +To change the keys in X, put this in your `~/.xmodmap`: + + remove Lock = Caps_Lock + keysym Caps_Lock = Control_L + add Control = Control_L + +Afterwards source it via `$ xmodmap ~/.xmodmap`. + +An alternative would be using [caps2esc](https://github.com/oblitum/caps2esc) or +[xcape](https://github.com/alols/xcape). + +**Windows**: + +See [superuser.com: Map Caps-Lock to Control in Windows +8.1](http://superuser.com/questions/764782/map-caps-lock-to-control-in-windows-8-1). + +## Easter eggs + +| Command | Message | +|-----------|---------| +| `:Ni!` | `Do you demand a shrubbery?` | +| `:h 'sm'` | `NOTE: Use of the short form is rated PG.` | +| `:h 42` | `What is the meaning of life, the universe and everything? Douglas Adams, the only person who knew what this question really was about is now dead, unfortunately. So now you might wonder what the meaning of death is...` | +| `:h UserGettingBored` | `When the user presses the same key 42 times. Just kidding! :-)` | +| `:h bar` | `Ceci n'est pas une pipe.` | +| `:h holy-grail` | `You found it, Arthur!` | +| `:h map-modes` | `:nunmap can also be used outside of a monastery.` | +| `:help!` | `E478: Don't panic!` (Glitch? When used in a help buffer (`buftype=help`) this works like `:h help.txt` instead.) | +| `:smile` | Try it out yourself. ;-) Added in 7.4.1005. | + +## Why hjkl for navigation? + +When [Bill Joy](https://en.wikipedia.org/wiki/Bill_Joy) created +[vi](https://en.wikipedia.org/wiki/Vi), a predecessor of Vim, he did it on a +[ADM-3A](https://en.wikipedia.org/wiki/ADM-3A) which had no extra cursor buttons +but used, you might already guessed it, hjkl instead. + +Keyboard layout: [click](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-adm-3a-layout.jpg) + +This also shows why `~` is used to denote the home directory on Unix systems. + +# Common problems + +## Editing small files is slow + +There are two things which can have a huge impact on performance: + +1. Complex **regular expressions**. Particular the Ruby syntax file caused + people to have slowdowns in the past. (Also see [Debugging syntax files](#debugging-syntax-files).) +2. **Screen redraws**. Some features force all lines to redraw. + +| Typical culprit | Why? | Solution? | +|-----------------|------|-----------| +| `:set cursorline` | Causes all lines to redraw. | `:set nocursorline` | +| `:set cursorcolumn` | Causes all lines to redraw. | `:set nocursorcolumn` | +| `:set relativenumber` | Causes all lines to redraw. | `:set norelativenumber` | +| `:set foldmethod=syntax` | If the syntax file is slow already, this makes it even worse. | `:set foldmethod=manual`, `:set foldmethod=marker` or [FastFold](https://github.com/Konfekt/FastFold) | +| `:set synmaxcol=3000` | Due to internal representation, Vim has problems with long lines in general. Highlights columns till column 3000. | `:set synmaxcol=200` | +| matchparen.vim | Loaded by default. Uses regular expressions to find the accompanying parenthesis. | Disable plugin: `:h matchparen` | + +**NOTE**: You only need to do this if you experience actual performance +drawbacks. In most cases using the things mentioned above is absolutely fine. + +## Editing huge files is slow + +The biggest issue with big files is, that Vim reads the whole file at once. This +is done due to how buffers are represented internally. +([Discussion on vim_dev@](https://groups.google.com/forum/#!topic/vim_dev/oY3i8rqYGD4/discussion)) + +If you only want to read, `tail hugefile | vim -` is a good workaround. + +If you can live without syntax, settings and plugins for the moment: + +``` +$ vim -u NONE -N +``` + +This should make navigation quite a lot faster, especially since no expensive +regular expressions for syntax highlighting are used. You should also tell Vim +not to use swapfiles and viminfo files to avoid long delays on writing: + +``` +$ vim -n -u NONE -i NONE -N +``` + +Putting it in a nutshell, try to avoid using Vim when intending to write really +huge files. :\ + +## Bracketed paste (or why do I have to set 'paste' all the time?) + +Bracketed paste mode allows terminal emulators to distinguish between typed text +and pasted text. + +Did you ever tried pasting code into Vim and afterwards everything seemed messed +up? + +This only happens if you paste via `cmd+v`, `shift-insert`, `middle-click` etc. +because then you're just throwing text at the terminal emulator. Vim doesn't +know that you just pasted the text, it thinks you're an extremely fast typist. +Accordingly, it tries to indent the lines and fails. + +Obviously this is not an issue, if you paste using Vim's registers, e.g. `"+p`, +because then Vim knows that you're actually pasting. + +To workaround this, you have to `:set paste`, so it gets pasted as-is. See `:h +'paste'` and `:h 'pastetoggle'`. + +If you're fed up with toggling `'paste'` all the time, have a look at this fine +plugin that does it for you: +[bracketed-paste](https://github.com/ConradIrwin/vim-bracketed-paste). + +Additional read from the same author as the plugin: +[here](http://cirw.in/blog/bracketed-paste). + +**Neovim**: Neovim tries to make all of this much more seamless and sets +bracketed paste mode automatically if the terminal emulator supports it. + +## Delays when using escape key in terminal + +If you live in the command-line, you probably use a so-called _terminal +emulator_ like xterm, gnome-terminal, iTerm2, etc. (opposed to a real +[terminal](https://en.wikipedia.org/wiki/Computer_terminal)). + +Like their ancestors, terminal emulators use [escape +sequences](https://en.wikipedia.org/wiki/Escape_sequence) (or _control +sequences_) to control things like moving the cursor, changing text colors, etc. +They're simply strings of ASCII characters starting with an escape character +(displayed in [caret notation](https://en.wikipedia.org/wiki/Caret_notation) as +`^[`). When such a string arrives, the terminal emulator looks up the +accompanying action in the [terminfo](https://en.wikipedia.org/wiki/Terminfo) +database. + +To make the problem clearer, I'll explain mapping timeouts first. They always +happen when there's ambiguity between mappings: + +```vim +:nnoremap ,a :echo 'foo' +:nnoremap ,ab :echo 'bar' +``` + +Both mappings work as expected, but when typing `,a`, there will be a delay of 1 +second, because Vim waits whether the user keys in another `b` or not. + +Escape sequences pose the same problem: + +- `` is used a lot for returning to normal mode or quitting an action. +- Cursor keys are encoded using escape sequences. +- Vim expects Alt (also called _Meta key_) to send a proper 8-bit + encoding with the high bit set, but many terminal emulators don't support it + (or don't enable it by default) and send an escape sequence instead. + +You can test the above like this: `vim -u NONE -N` and type `i` and +you'll see a sequence inserted that starts with `^[` which denotes the escape +character. + +Putting it in a nutshell, Vim has a hard time distinguishing between a typed +`` character and a proper escape sequence. + +By default, Vim uses `:set timeout timeoutlen=1000`, so it delays on ambiguity +of mappings _and_ key codes by 1 second. This is a sane value for mappings, but +you can define the key code timeout on its own which is the most common +workaround for this entire issue: + +```vim +set timeout " for mappings +set timeoutlen=1000 " default value +set ttimeout " for key codes +set ttimeoutlen=10 " unnoticeable small value +``` + +Under `:h ttimeout` you find a small table showing the relationship between +these options. + +If you're using tmux between Vim and your terminal emulator, also put this in +your `~/.tmux.conf`: + +```tmux +set -sg escape-time 0 +``` + +## Function search undo + +- A search pattern in a command (`/`, `:substitute`, ...) changes the "last used + search pattern". (It's saved in the `/` register; print it with `:echo @/`). +- A simple text change can be redone with `.`. (It's saved in the `.` register; + print it with `:echo @.`). + +Both things are _not_ the case, if you do them from a function, though! Thus you +can't easily highlight words from a function or redo the text changes made by +it. + +Help: `:h function-search-undo` + +# Technical quirks + +## Newline used for NUL + +NUL characters (`\0`) in a file, are stored as newline (`\n`) in memory and +displayed in a buffer as `^@`. + +See `man 7 ascii` and `:h NL-used-for-Nul` for more information. diff --git a/chapter/additional-resources.md b/chapter/additional-resources.md new file mode 100644 index 0000000..e69de29 diff --git a/chapter/bracketed-paste.md b/chapter/bracketed-paste.md new file mode 100644 index 0000000..e69de29 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..e69de29 diff --git a/chapter/easter-eggs.md b/chapter/easter-eggs.md new file mode 100644 index 0000000..e69de29 diff --git a/chapter/editing-huge-files-is-slow.md b/chapter/editing-huge-files-is-slow.md new file mode 100644 index 0000000..e69de29 diff --git a/chapter/editing-small-files-is-slow.md b/chapter/editing-small-files-is-slow.md new file mode 100644 index 0000000..e69de29 diff --git a/chapter/function-search-undo.md b/chapter/function-search-undo.md new file mode 100644 index 0000000..e69de29 diff --git a/chapter/map-capslock-to-control.md b/chapter/map-capslock-to-control.md new file mode 100644 index 0000000..e69de29 diff --git a/chapter/standard-plugins.md b/chapter/standard-plugins.md new file mode 100644 index 0000000..e69de29 diff --git a/chapter/vim-distributions.md b/chapter/vim-distributions.md new file mode 100644 index 0000000..e69de29 diff --git a/chapter/why-hjkl-for-navigation.md b/chapter/why-hjkl-for-navigation.md new file mode 100644 index 0000000..e69de29 From c7339fa21c4693dc166d9a000e7f0e50267fe0bc Mon Sep 17 00:00:00 2001 From: chengrui Date: Mon, 27 Mar 2017 14:09:41 +0800 Subject: [PATCH 02/18] translate Miscellaneous.md --- chapter/Common problems.md | 11 ++ chapter/Miscellaneous.md | 269 +----------------------------- chapter/additional-resources.md | 12 ++ chapter/origin.md | 281 ++++++++++++++++++++++++++++++++ 4 files changed, 305 insertions(+), 268 deletions(-) create mode 100644 chapter/origin.md diff --git a/chapter/Common problems.md b/chapter/Common problems.md index e69de29..8c33cb4 100644 --- a/chapter/Common problems.md +++ b/chapter/Common problems.md @@ -0,0 +1,11 @@ +# Common problems + +## Editing small files is slow + +## Editing huge files is slow + +## Bracketed paste (or why do I have to set 'paste' all the time?) + +## Delays when using escape key in terminal + +## Function search undo \ No newline at end of file diff --git a/chapter/Miscellaneous.md b/chapter/Miscellaneous.md index 44266b5..3e11dd0 100644 --- a/chapter/Miscellaneous.md +++ b/chapter/Miscellaneous.md @@ -1,281 +1,14 @@ -# Miscellaneous +# 鏉傞」 ## Additional resources -| Resource | Description | -|----------|-------------| -| [Seven habits of effective text editing](http://www.moolenaar.net/habits.html) | By Bram Moolenaar, the author of Vim. | -| [Seven habits of effective text editing 2.0 (PDF)](http://www.moolenaar.net/habits_2007.pdf) | See above. | -| [IBM DeveloperWorks: Scripting the Vim editor](http://www.ibm.com/developerworks/views/linux/libraryview.jsp?sort_order=asc&sort_by=Title&search_by=scripting+the+vim+editor) | Five-part series on Vim scripting. | -| [Learn Vimscript the Hard Way](http://learnvimscriptthehardway.stevelosh.com) | Develop a Vim plugin from scratch. | -| [Practical Vim (2nd Edition)](http://www.amazon.com/Practical-Vim-Edit-Speed-Thought/dp/1680501275/) | Hands down the best book about Vim. | -| [Vimcasts.org](http://vimcasts.org/episodes/archive) | Vim screencasts. | -| [Why, oh WHY, do those #?@! nutheads use vi?](http://www.viemu.com/a-why-vi-vim.html) | Common misconceptions explained. | -| [Your problem with Vim is that you don't grok vi](http://stackoverflow.com/a/1220118) | Concise, informative and correct. A real gem. | - ## Vim distributions -Vim distributions are bundles of custom settings and plugins for Vim. - -More advanced users know how to configure their editor anyway, so distributions -are mostly targeted at beginners. If you think about that, it's quite -paradoxical though: Making it easier by adding even more things to learn about? - -I know that many people don't want to spend hours and hours on customizing an -editor (and actually you never stop customizing your vimrc when you finally got -hooked), but eventually you only get efficient in Vim when you take the time to -learn it properly. - -Repeat after me: "A programmer should know their tools." - -Anyway, if you know what you're doing, you might draw some inspiration from -looking at a few distributions: - -- [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) - ## Standard plugins -Surprising to many people, Vim comes with a handful of plugins on its own that -all get loaded by default. Check `:scriptnames` after starting Vim to see all -sourced files. - -Most of them will never get used, so disable them as you see fit. They will -still be shown as sourced, but only the first lines actually get read before Vim -bails out. No further code (mappings, commands, logic) will be processed. - -| Plugin | Disable it using.. | Help | -|------------|-------------------------------------|------| -| 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` | - ## Map CapsLock to Control -CapsLock belongs to the most useless keys on your keyboard, but it's much easier -to reach than the Control key, since it lies on your [home -row](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-homerow.png). -Mapping CapsLock to Control is a great way to prevent or at least reduce -[RSI](https://de.wikipedia.org/wiki/Repetitive-Strain-Injury-Syndrom) if you -program a lot. - -Attention: When you get used to it, you can't live without it anymore. - -**OSX**: - -`System Preferences -> Keyboard -> Keyboard Tab -> Modifier Keys`. Change -"CapsLock" to "Control". - -**Linux**: - -To change the keys in X, put this in your `~/.xmodmap`: - - remove Lock = Caps_Lock - keysym Caps_Lock = Control_L - add Control = Control_L - -Afterwards source it via `$ xmodmap ~/.xmodmap`. - -An alternative would be using [caps2esc](https://github.com/oblitum/caps2esc) or -[xcape](https://github.com/alols/xcape). - -**Windows**: - -See [superuser.com: Map Caps-Lock to Control in Windows -8.1](http://superuser.com/questions/764782/map-caps-lock-to-control-in-windows-8-1). - ## Easter eggs -| Command | Message | -|-----------|---------| -| `:Ni!` | `Do you demand a shrubbery?` | -| `:h 'sm'` | `NOTE: Use of the short form is rated PG.` | -| `:h 42` | `What is the meaning of life, the universe and everything? Douglas Adams, the only person who knew what this question really was about is now dead, unfortunately. So now you might wonder what the meaning of death is...` | -| `:h UserGettingBored` | `When the user presses the same key 42 times. Just kidding! :-)` | -| `:h bar` | `Ceci n'est pas une pipe.` | -| `:h holy-grail` | `You found it, Arthur!` | -| `:h map-modes` | `:nunmap can also be used outside of a monastery.` | -| `:help!` | `E478: Don't panic!` (Glitch? When used in a help buffer (`buftype=help`) this works like `:h help.txt` instead.) | -| `:smile` | Try it out yourself. ;-) Added in 7.4.1005. | - ## Why hjkl for navigation? -When [Bill Joy](https://en.wikipedia.org/wiki/Bill_Joy) created -[vi](https://en.wikipedia.org/wiki/Vi), a predecessor of Vim, he did it on a -[ADM-3A](https://en.wikipedia.org/wiki/ADM-3A) which had no extra cursor buttons -but used, you might already guessed it, hjkl instead. - -Keyboard layout: [click](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-adm-3a-layout.jpg) - -This also shows why `~` is used to denote the home directory on Unix systems. - -# Common problems - -## Editing small files is slow - -There are two things which can have a huge impact on performance: - -1. Complex **regular expressions**. Particular the Ruby syntax file caused - people to have slowdowns in the past. (Also see [Debugging syntax files](#debugging-syntax-files).) -2. **Screen redraws**. Some features force all lines to redraw. - -| Typical culprit | Why? | Solution? | -|-----------------|------|-----------| -| `:set cursorline` | Causes all lines to redraw. | `:set nocursorline` | -| `:set cursorcolumn` | Causes all lines to redraw. | `:set nocursorcolumn` | -| `:set relativenumber` | Causes all lines to redraw. | `:set norelativenumber` | -| `:set foldmethod=syntax` | If the syntax file is slow already, this makes it even worse. | `:set foldmethod=manual`, `:set foldmethod=marker` or [FastFold](https://github.com/Konfekt/FastFold) | -| `:set synmaxcol=3000` | Due to internal representation, Vim has problems with long lines in general. Highlights columns till column 3000. | `:set synmaxcol=200` | -| matchparen.vim | Loaded by default. Uses regular expressions to find the accompanying parenthesis. | Disable plugin: `:h matchparen` | - -**NOTE**: You only need to do this if you experience actual performance -drawbacks. In most cases using the things mentioned above is absolutely fine. - -## Editing huge files is slow - -The biggest issue with big files is, that Vim reads the whole file at once. This -is done due to how buffers are represented internally. -([Discussion on vim_dev@](https://groups.google.com/forum/#!topic/vim_dev/oY3i8rqYGD4/discussion)) - -If you only want to read, `tail hugefile | vim -` is a good workaround. - -If you can live without syntax, settings and plugins for the moment: - -``` -$ vim -u NONE -N -``` - -This should make navigation quite a lot faster, especially since no expensive -regular expressions for syntax highlighting are used. You should also tell Vim -not to use swapfiles and viminfo files to avoid long delays on writing: - -``` -$ vim -n -u NONE -i NONE -N -``` - -Putting it in a nutshell, try to avoid using Vim when intending to write really -huge files. :\ - -## Bracketed paste (or why do I have to set 'paste' all the time?) - -Bracketed paste mode allows terminal emulators to distinguish between typed text -and pasted text. - -Did you ever tried pasting code into Vim and afterwards everything seemed messed -up? - -This only happens if you paste via `cmd+v`, `shift-insert`, `middle-click` etc. -because then you're just throwing text at the terminal emulator. Vim doesn't -know that you just pasted the text, it thinks you're an extremely fast typist. -Accordingly, it tries to indent the lines and fails. - -Obviously this is not an issue, if you paste using Vim's registers, e.g. `"+p`, -because then Vim knows that you're actually pasting. - -To workaround this, you have to `:set paste`, so it gets pasted as-is. See `:h -'paste'` and `:h 'pastetoggle'`. - -If you're fed up with toggling `'paste'` all the time, have a look at this fine -plugin that does it for you: -[bracketed-paste](https://github.com/ConradIrwin/vim-bracketed-paste). - -Additional read from the same author as the plugin: -[here](http://cirw.in/blog/bracketed-paste). - -**Neovim**: Neovim tries to make all of this much more seamless and sets -bracketed paste mode automatically if the terminal emulator supports it. - -## Delays when using escape key in terminal - -If you live in the command-line, you probably use a so-called _terminal -emulator_ like xterm, gnome-terminal, iTerm2, etc. (opposed to a real -[terminal](https://en.wikipedia.org/wiki/Computer_terminal)). - -Like their ancestors, terminal emulators use [escape -sequences](https://en.wikipedia.org/wiki/Escape_sequence) (or _control -sequences_) to control things like moving the cursor, changing text colors, etc. -They're simply strings of ASCII characters starting with an escape character -(displayed in [caret notation](https://en.wikipedia.org/wiki/Caret_notation) as -`^[`). When such a string arrives, the terminal emulator looks up the -accompanying action in the [terminfo](https://en.wikipedia.org/wiki/Terminfo) -database. - -To make the problem clearer, I'll explain mapping timeouts first. They always -happen when there's ambiguity between mappings: - -```vim -:nnoremap ,a :echo 'foo' -:nnoremap ,ab :echo 'bar' -``` - -Both mappings work as expected, but when typing `,a`, there will be a delay of 1 -second, because Vim waits whether the user keys in another `b` or not. - -Escape sequences pose the same problem: - -- `` is used a lot for returning to normal mode or quitting an action. -- Cursor keys are encoded using escape sequences. -- Vim expects Alt (also called _Meta key_) to send a proper 8-bit - encoding with the high bit set, but many terminal emulators don't support it - (or don't enable it by default) and send an escape sequence instead. - -You can test the above like this: `vim -u NONE -N` and type `i` and -you'll see a sequence inserted that starts with `^[` which denotes the escape -character. - -Putting it in a nutshell, Vim has a hard time distinguishing between a typed -`` character and a proper escape sequence. - -By default, Vim uses `:set timeout timeoutlen=1000`, so it delays on ambiguity -of mappings _and_ key codes by 1 second. This is a sane value for mappings, but -you can define the key code timeout on its own which is the most common -workaround for this entire issue: - -```vim -set timeout " for mappings -set timeoutlen=1000 " default value -set ttimeout " for key codes -set ttimeoutlen=10 " unnoticeable small value -``` - -Under `:h ttimeout` you find a small table showing the relationship between -these options. - -If you're using tmux between Vim and your terminal emulator, also put this in -your `~/.tmux.conf`: - -```tmux -set -sg escape-time 0 -``` - -## Function search undo - -- A search pattern in a command (`/`, `:substitute`, ...) changes the "last used - search pattern". (It's saved in the `/` register; print it with `:echo @/`). -- A simple text change can be redone with `.`. (It's saved in the `.` register; - print it with `:echo @.`). - -Both things are _not_ the case, if you do them from a function, though! Thus you -can't easily highlight words from a function or redo the text changes made by -it. - -Help: `:h function-search-undo` - -# Technical quirks - -## Newline used for NUL - -NUL characters (`\0`) in a file, are stored as newline (`\n`) in memory and -displayed in a buffer as `^@`. - -See `man 7 ascii` and `:h NL-used-for-Nul` for more information. diff --git a/chapter/additional-resources.md b/chapter/additional-resources.md index e69de29..944ffab 100644 --- a/chapter/additional-resources.md +++ b/chapter/additional-resources.md @@ -0,0 +1,12 @@ +## 附加资源 + +| 资源名称 | 简介 | +|----------|-------------| +| [七个高效的文本编辑习惯](http://www.moolenaar.net/habits.html) | 作者:Bram Moolenaar(即Vim的作者) | +| [七个高效的文本编辑习惯2.0(PDF版)](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/origin.md b/chapter/origin.md new file mode 100644 index 0000000..44266b5 --- /dev/null +++ b/chapter/origin.md @@ -0,0 +1,281 @@ +# Miscellaneous + +## Additional resources + +| Resource | Description | +|----------|-------------| +| [Seven habits of effective text editing](http://www.moolenaar.net/habits.html) | By Bram Moolenaar, the author of Vim. | +| [Seven habits of effective text editing 2.0 (PDF)](http://www.moolenaar.net/habits_2007.pdf) | See above. | +| [IBM DeveloperWorks: Scripting the Vim editor](http://www.ibm.com/developerworks/views/linux/libraryview.jsp?sort_order=asc&sort_by=Title&search_by=scripting+the+vim+editor) | Five-part series on Vim scripting. | +| [Learn Vimscript the Hard Way](http://learnvimscriptthehardway.stevelosh.com) | Develop a Vim plugin from scratch. | +| [Practical Vim (2nd Edition)](http://www.amazon.com/Practical-Vim-Edit-Speed-Thought/dp/1680501275/) | Hands down the best book about Vim. | +| [Vimcasts.org](http://vimcasts.org/episodes/archive) | Vim screencasts. | +| [Why, oh WHY, do those #?@! nutheads use vi?](http://www.viemu.com/a-why-vi-vim.html) | Common misconceptions explained. | +| [Your problem with Vim is that you don't grok vi](http://stackoverflow.com/a/1220118) | Concise, informative and correct. A real gem. | + +## Vim distributions + +Vim distributions are bundles of custom settings and plugins for Vim. + +More advanced users know how to configure their editor anyway, so distributions +are mostly targeted at beginners. If you think about that, it's quite +paradoxical though: Making it easier by adding even more things to learn about? + +I know that many people don't want to spend hours and hours on customizing an +editor (and actually you never stop customizing your vimrc when you finally got +hooked), but eventually you only get efficient in Vim when you take the time to +learn it properly. + +Repeat after me: "A programmer should know their tools." + +Anyway, if you know what you're doing, you might draw some inspiration from +looking at a few distributions: + +- [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) + +## Standard plugins + +Surprising to many people, Vim comes with a handful of plugins on its own that +all get loaded by default. Check `:scriptnames` after starting Vim to see all +sourced files. + +Most of them will never get used, so disable them as you see fit. They will +still be shown as sourced, but only the first lines actually get read before Vim +bails out. No further code (mappings, commands, logic) will be processed. + +| Plugin | Disable it using.. | Help | +|------------|-------------------------------------|------| +| 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` | + +## Map CapsLock to Control + +CapsLock belongs to the most useless keys on your keyboard, but it's much easier +to reach than the Control key, since it lies on your [home +row](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-homerow.png). +Mapping CapsLock to Control is a great way to prevent or at least reduce +[RSI](https://de.wikipedia.org/wiki/Repetitive-Strain-Injury-Syndrom) if you +program a lot. + +Attention: When you get used to it, you can't live without it anymore. + +**OSX**: + +`System Preferences -> Keyboard -> Keyboard Tab -> Modifier Keys`. Change +"CapsLock" to "Control". + +**Linux**: + +To change the keys in X, put this in your `~/.xmodmap`: + + remove Lock = Caps_Lock + keysym Caps_Lock = Control_L + add Control = Control_L + +Afterwards source it via `$ xmodmap ~/.xmodmap`. + +An alternative would be using [caps2esc](https://github.com/oblitum/caps2esc) or +[xcape](https://github.com/alols/xcape). + +**Windows**: + +See [superuser.com: Map Caps-Lock to Control in Windows +8.1](http://superuser.com/questions/764782/map-caps-lock-to-control-in-windows-8-1). + +## Easter eggs + +| Command | Message | +|-----------|---------| +| `:Ni!` | `Do you demand a shrubbery?` | +| `:h 'sm'` | `NOTE: Use of the short form is rated PG.` | +| `:h 42` | `What is the meaning of life, the universe and everything? Douglas Adams, the only person who knew what this question really was about is now dead, unfortunately. So now you might wonder what the meaning of death is...` | +| `:h UserGettingBored` | `When the user presses the same key 42 times. Just kidding! :-)` | +| `:h bar` | `Ceci n'est pas une pipe.` | +| `:h holy-grail` | `You found it, Arthur!` | +| `:h map-modes` | `:nunmap can also be used outside of a monastery.` | +| `:help!` | `E478: Don't panic!` (Glitch? When used in a help buffer (`buftype=help`) this works like `:h help.txt` instead.) | +| `:smile` | Try it out yourself. ;-) Added in 7.4.1005. | + +## Why hjkl for navigation? + +When [Bill Joy](https://en.wikipedia.org/wiki/Bill_Joy) created +[vi](https://en.wikipedia.org/wiki/Vi), a predecessor of Vim, he did it on a +[ADM-3A](https://en.wikipedia.org/wiki/ADM-3A) which had no extra cursor buttons +but used, you might already guessed it, hjkl instead. + +Keyboard layout: [click](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-adm-3a-layout.jpg) + +This also shows why `~` is used to denote the home directory on Unix systems. + +# Common problems + +## Editing small files is slow + +There are two things which can have a huge impact on performance: + +1. Complex **regular expressions**. Particular the Ruby syntax file caused + people to have slowdowns in the past. (Also see [Debugging syntax files](#debugging-syntax-files).) +2. **Screen redraws**. Some features force all lines to redraw. + +| Typical culprit | Why? | Solution? | +|-----------------|------|-----------| +| `:set cursorline` | Causes all lines to redraw. | `:set nocursorline` | +| `:set cursorcolumn` | Causes all lines to redraw. | `:set nocursorcolumn` | +| `:set relativenumber` | Causes all lines to redraw. | `:set norelativenumber` | +| `:set foldmethod=syntax` | If the syntax file is slow already, this makes it even worse. | `:set foldmethod=manual`, `:set foldmethod=marker` or [FastFold](https://github.com/Konfekt/FastFold) | +| `:set synmaxcol=3000` | Due to internal representation, Vim has problems with long lines in general. Highlights columns till column 3000. | `:set synmaxcol=200` | +| matchparen.vim | Loaded by default. Uses regular expressions to find the accompanying parenthesis. | Disable plugin: `:h matchparen` | + +**NOTE**: You only need to do this if you experience actual performance +drawbacks. In most cases using the things mentioned above is absolutely fine. + +## Editing huge files is slow + +The biggest issue with big files is, that Vim reads the whole file at once. This +is done due to how buffers are represented internally. +([Discussion on vim_dev@](https://groups.google.com/forum/#!topic/vim_dev/oY3i8rqYGD4/discussion)) + +If you only want to read, `tail hugefile | vim -` is a good workaround. + +If you can live without syntax, settings and plugins for the moment: + +``` +$ vim -u NONE -N +``` + +This should make navigation quite a lot faster, especially since no expensive +regular expressions for syntax highlighting are used. You should also tell Vim +not to use swapfiles and viminfo files to avoid long delays on writing: + +``` +$ vim -n -u NONE -i NONE -N +``` + +Putting it in a nutshell, try to avoid using Vim when intending to write really +huge files. :\ + +## Bracketed paste (or why do I have to set 'paste' all the time?) + +Bracketed paste mode allows terminal emulators to distinguish between typed text +and pasted text. + +Did you ever tried pasting code into Vim and afterwards everything seemed messed +up? + +This only happens if you paste via `cmd+v`, `shift-insert`, `middle-click` etc. +because then you're just throwing text at the terminal emulator. Vim doesn't +know that you just pasted the text, it thinks you're an extremely fast typist. +Accordingly, it tries to indent the lines and fails. + +Obviously this is not an issue, if you paste using Vim's registers, e.g. `"+p`, +because then Vim knows that you're actually pasting. + +To workaround this, you have to `:set paste`, so it gets pasted as-is. See `:h +'paste'` and `:h 'pastetoggle'`. + +If you're fed up with toggling `'paste'` all the time, have a look at this fine +plugin that does it for you: +[bracketed-paste](https://github.com/ConradIrwin/vim-bracketed-paste). + +Additional read from the same author as the plugin: +[here](http://cirw.in/blog/bracketed-paste). + +**Neovim**: Neovim tries to make all of this much more seamless and sets +bracketed paste mode automatically if the terminal emulator supports it. + +## Delays when using escape key in terminal + +If you live in the command-line, you probably use a so-called _terminal +emulator_ like xterm, gnome-terminal, iTerm2, etc. (opposed to a real +[terminal](https://en.wikipedia.org/wiki/Computer_terminal)). + +Like their ancestors, terminal emulators use [escape +sequences](https://en.wikipedia.org/wiki/Escape_sequence) (or _control +sequences_) to control things like moving the cursor, changing text colors, etc. +They're simply strings of ASCII characters starting with an escape character +(displayed in [caret notation](https://en.wikipedia.org/wiki/Caret_notation) as +`^[`). When such a string arrives, the terminal emulator looks up the +accompanying action in the [terminfo](https://en.wikipedia.org/wiki/Terminfo) +database. + +To make the problem clearer, I'll explain mapping timeouts first. They always +happen when there's ambiguity between mappings: + +```vim +:nnoremap ,a :echo 'foo' +:nnoremap ,ab :echo 'bar' +``` + +Both mappings work as expected, but when typing `,a`, there will be a delay of 1 +second, because Vim waits whether the user keys in another `b` or not. + +Escape sequences pose the same problem: + +- `` is used a lot for returning to normal mode or quitting an action. +- Cursor keys are encoded using escape sequences. +- Vim expects Alt (also called _Meta key_) to send a proper 8-bit + encoding with the high bit set, but many terminal emulators don't support it + (or don't enable it by default) and send an escape sequence instead. + +You can test the above like this: `vim -u NONE -N` and type `i` and +you'll see a sequence inserted that starts with `^[` which denotes the escape +character. + +Putting it in a nutshell, Vim has a hard time distinguishing between a typed +`` character and a proper escape sequence. + +By default, Vim uses `:set timeout timeoutlen=1000`, so it delays on ambiguity +of mappings _and_ key codes by 1 second. This is a sane value for mappings, but +you can define the key code timeout on its own which is the most common +workaround for this entire issue: + +```vim +set timeout " for mappings +set timeoutlen=1000 " default value +set ttimeout " for key codes +set ttimeoutlen=10 " unnoticeable small value +``` + +Under `:h ttimeout` you find a small table showing the relationship between +these options. + +If you're using tmux between Vim and your terminal emulator, also put this in +your `~/.tmux.conf`: + +```tmux +set -sg escape-time 0 +``` + +## Function search undo + +- A search pattern in a command (`/`, `:substitute`, ...) changes the "last used + search pattern". (It's saved in the `/` register; print it with `:echo @/`). +- A simple text change can be redone with `.`. (It's saved in the `.` register; + print it with `:echo @.`). + +Both things are _not_ the case, if you do them from a function, though! Thus you +can't easily highlight words from a function or redo the text changes made by +it. + +Help: `:h function-search-undo` + +# Technical quirks + +## Newline used for NUL + +NUL characters (`\0`) in a file, are stored as newline (`\n`) in memory and +displayed in a buffer as `^@`. + +See `man 7 ascii` and `:h NL-used-for-Nul` for more information. From 7a5270931e1dc68c071bd78ac34a81e3453dfa97 Mon Sep 17 00:00:00 2001 From: chengrui Date: Mon, 27 Mar 2017 15:15:17 +0800 Subject: [PATCH 03/18] translate vim-distributions --- chapter/vim-distributions.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/chapter/vim-distributions.md b/chapter/vim-distributions.md index e69de29..a7f5b8e 100644 --- a/chapter/vim-distributions.md +++ b/chapter/vim-distributions.md @@ -0,0 +1,22 @@ +## 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) From 52f390189eda33469713b4dec3b9c67f3204be53 Mon Sep 17 00:00:00 2001 From: chengrui Date: Mon, 27 Mar 2017 15:16:50 +0800 Subject: [PATCH 04/18] =?UTF-8?q?update=20the=20menu=20of=20=C2=96Miscella?= =?UTF-8?q?neous?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chapter/Miscellaneous.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter/Miscellaneous.md b/chapter/Miscellaneous.md index 3e11dd0..5858b78 100644 --- a/chapter/Miscellaneous.md +++ b/chapter/Miscellaneous.md @@ -1,6 +1,6 @@ # 鏉傞」 -## Additional resources +## 闄勫姞璧勬簮 ## Vim distributions From e1fc131cbac58a8ff7374f52d46c06eb5f0530b5 Mon Sep 17 00:00:00 2001 From: chengrui Date: Mon, 27 Mar 2017 15:22:34 +0800 Subject: [PATCH 05/18] translate vim-distributions --- chapter/vim-distributions.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/chapter/vim-distributions.md b/chapter/vim-distributions.md index a7f5b8e..2b18409 100644 --- a/chapter/vim-distributions.md +++ b/chapter/vim-distributions.md @@ -2,19 +2,14 @@ Vim发行版是集成客制化设定和Vim插件的包 -高阶用户总是知道如何构建自己的编辑器,所以发行版 -一般是针对初学者。 -如果你考虑这方面,那么这就是一个非常辩证的想法: -加入更多需要学的东西,使得学习本身变得简单。 +高阶用户总是知道如何构建自己的编辑器,所以发行版一般是针对初学者。 +如果你考虑这方面,那么这就是一个非常辩证的想法:加入更多需要学的东西,使得学习本身变得简单。 -我知道很多人不想在编辑器上花很多时间(当你卡住时, -你实际上在不停地花时间定制自己的vimrc),但是只有 -正确地去了解Vim,你才能最终从它身上获得高效。 +我知道很多人不想在编辑器上花很多时间(当你卡住时,你实际上在不停地花时间定制自己的vimrc),但是只有正确地去了解Vim,你才能最终从它身上获得高效。 跟我说一遍: "一个程序员需要懂得他的工具。" -无论如何,如果你知道自己在做什么,那你也许能从以下 -几个发行版Vim中获得一些灵感 +无论如何,如果你知道自己在做什么,那你也许能从以下几个发行版Vim中获得一些灵感 - [cream](http://cream.sourceforge.net) - [janus](https://github.com/carlhuda/janus.git) From a2eb95a2cbb0a8d685ef89547b398896c1d9dede Mon Sep 17 00:00:00 2001 From: chengrui Date: Mon, 27 Mar 2017 15:42:53 +0800 Subject: [PATCH 06/18] translate standard-plugins --- chapter/standard-plugins.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/chapter/standard-plugins.md b/chapter/standard-plugins.md index e69de29..4c654f1 100644 --- a/chapter/standard-plugins.md +++ b/chapter/standard-plugins.md @@ -0,0 +1,20 @@ +## 标准插件 + +出乎很多人的意料,Vim自己默认加载了大把大把的插件。启动Vim后,用`:scriptnames`查看所有加载的源文件 + +这些文件多数永远不会被用到,所以请禁止如你所见的以下插件。 +这些插件仍旧会在源文件列出,但是当Vim启动时,只有第一行会被读取,而之后的配置,命令和日志都不会执行。 + +| Plugin | Disable it using.. | Help | +|------------|-------------------------------------|------| +| 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` | From a7d0d3c732169bbfb6bb65fee0038bf67768eabd Mon Sep 17 00:00:00 2001 From: chengrui Date: Mon, 27 Mar 2017 16:04:54 +0800 Subject: [PATCH 07/18] standard-plugins new lines --- chapter/standard-plugins.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chapter/standard-plugins.md b/chapter/standard-plugins.md index 4c654f1..96c419f 100644 --- a/chapter/standard-plugins.md +++ b/chapter/standard-plugins.md @@ -1,8 +1,9 @@ ## 标准插件 -出乎很多人的意料,Vim自己默认加载了大把大把的插件。启动Vim后,用`:scriptnames`查看所有加载的源文件 +出乎很多人的意料,Vim自己默认加载了大把大把的插件。
+启动Vim后,用`:scriptnames`查看所有加载的源文件 -这些文件多数永远不会被用到,所以请禁止如你所见的以下插件。 +这些文件多数永远不会被用到,所以请禁止如你所见的以下插件。
这些插件仍旧会在源文件列出,但是当Vim启动时,只有第一行会被读取,而之后的配置,命令和日志都不会执行。 | Plugin | Disable it using.. | Help | From 8820d1be327160474d3740ea803ca1c45cabb9af Mon Sep 17 00:00:00 2001 From: chengrui Date: Mon, 27 Mar 2017 17:42:56 +0800 Subject: [PATCH 08/18] translate map-capslock-to-control --- chapter/map-capslock-to-control.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/chapter/map-capslock-to-control.md b/chapter/map-capslock-to-control.md index e69de29..70bc368 100644 --- a/chapter/map-capslock-to-control.md +++ 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) 。 + +友情提示:当你习惯这个设定后,你就离不开它了。 + +**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). From 3ab69d22582bf10c3d6195830bb77477cfad8502 Mon Sep 17 00:00:00 2001 From: chengrui Date: Mon, 27 Mar 2017 17:44:24 +0800 Subject: [PATCH 09/18] format modification --- chapter/Miscellaneous.md | 4 ++-- chapter/vim-distributions.md | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/chapter/Miscellaneous.md b/chapter/Miscellaneous.md index 5858b78..8dccf10 100644 --- a/chapter/Miscellaneous.md +++ b/chapter/Miscellaneous.md @@ -2,9 +2,9 @@ ## 闄勫姞璧勬簮 -## Vim distributions +## Vim鍙戣鐗 -## Standard plugins +## 鏍囧噯鎻掍欢 ## Map CapsLock to Control diff --git a/chapter/vim-distributions.md b/chapter/vim-distributions.md index 2b18409..565254f 100644 --- a/chapter/vim-distributions.md +++ b/chapter/vim-distributions.md @@ -3,9 +3,11 @@ Vim发行版是集成客制化设定和Vim插件的包 高阶用户总是知道如何构建自己的编辑器,所以发行版一般是针对初学者。 -如果你考虑这方面,那么这就是一个非常辩证的想法:加入更多需要学的东西,使得学习本身变得简单。 +如果你考虑这方面,那么这就是一个非常辩证的想法:
+加入更多需要学的东西,使得学习本身变得简单。 -我知道很多人不想在编辑器上花很多时间(当你卡住时,你实际上在不停地花时间定制自己的vimrc),但是只有正确地去了解Vim,你才能最终从它身上获得高效。 +我知道很多人不想在编辑器上花很多时间(当你卡住时,你实际上在不停地花时间定制自己的vimrc),
+但是只有正确地去了解Vim,你才能最终从它身上获得高效。 跟我说一遍: "一个程序员需要懂得他的工具。" From 0471d5585e26d7b0bed96faf19909604518837aa Mon Sep 17 00:00:00 2001 From: chengrui Date: Mon, 27 Mar 2017 17:53:14 +0800 Subject: [PATCH 10/18] format modification --- chapter/vim-distributions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter/vim-distributions.md b/chapter/vim-distributions.md index 565254f..5989c6b 100644 --- a/chapter/vim-distributions.md +++ b/chapter/vim-distributions.md @@ -2,7 +2,7 @@ Vim发行版是集成客制化设定和Vim插件的包 -高阶用户总是知道如何构建自己的编辑器,所以发行版一般是针对初学者。 +高阶用户总是知道如何构建自己的编辑器,所以发行版一般是针对初学者。
如果你考虑这方面,那么这就是一个非常辩证的想法:
加入更多需要学的东西,使得学习本身变得简单。 From 451d5fc636fd679091ad9be17dc5e65bc37f99c1 Mon Sep 17 00:00:00 2001 From: chengrui Date: Mon, 27 Mar 2017 18:39:18 +0800 Subject: [PATCH 11/18] finish translating Miscellaneous --- chapter/Miscellaneous.md | 8 ++++---- chapter/easter-eggs.md | 13 +++++++++++++ chapter/standard-plugins.md | 2 +- chapter/why-hjkl-for-navigation.md | 11 +++++++++++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/chapter/Miscellaneous.md b/chapter/Miscellaneous.md index 8dccf10..d9bd5c4 100644 --- a/chapter/Miscellaneous.md +++ b/chapter/Miscellaneous.md @@ -4,11 +4,11 @@ ## Vim鍙戣鐗 -## 鏍囧噯鎻掍欢 +## 鍐呯疆鎻掍欢 -## Map CapsLock to Control +## 鏄犲皠澶у啓閿佸畾閿紙CapsLock锛夊埌鎺у埗閿紙Ctrl锛 -## Easter eggs +## 澶嶆椿鑺傚僵铔 -## Why hjkl for navigation? +## 涓轰粈涔堢敤hjkl绉诲姩鍏夋爣? diff --git a/chapter/easter-eggs.md b/chapter/easter-eggs.md index e69de29..d83607c 100644 --- a/chapter/easter-eggs.md +++ b/chapter/easter-eggs.md @@ -0,0 +1,13 @@ +## 复活节彩蛋 + +| 命令 | 消息 | +|-----------|---------| +| `:Ni!` | `你需要灌木丛?` | +| `:h 'sm'` | `注意:这个缩写是限制级` | +| `:h 42` | `生命,宇宙和一切的意义是什么?不幸的是, 道格拉斯·亚当斯(Douglas Adams),唯一知道这个问题的人现在已经死了。所以现在你可能会想知道死亡的意思是什么……` | +| `:h UserGettingBored` | `什么时候用户会按同一个键42次?好吧,我只是开个玩笑 :-)` | +| `:h bar` | `这不是一个烟斗(原文:Ceci n'est pas une pipe.)。` | +| `:h holy-grail` | `亚瑟,你终究找到了!` | +| `:h map-modes` | `:nunmap命令在修道院外也能用.` | +| `:help!` | `E478:别怕!` (故障? 在使用模块帮助时 (`模块类型=帮助`) 这和 `:h help.txt` 一个效果。) | +| `:smile` | 试一试这个表情 ;-) 添加于 7.4.1005. | diff --git a/chapter/standard-plugins.md b/chapter/standard-plugins.md index 96c419f..23686a4 100644 --- a/chapter/standard-plugins.md +++ b/chapter/standard-plugins.md @@ -1,4 +1,4 @@ -## 标准插件 +## 内置插件 出乎很多人的意料,Vim自己默认加载了大把大把的插件。
启动Vim后,用`:scriptnames`查看所有加载的源文件 diff --git a/chapter/why-hjkl-for-navigation.md b/chapter/why-hjkl-for-navigation.md index e69de29..ac3547f 100644 --- a/chapter/why-hjkl-for-navigation.md +++ b/chapter/why-hjkl-for-navigation.md @@ -0,0 +1,11 @@ +## 为什么用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系统会以`~`代表根目录。 + From 33dd3e4a62b67e6566197663b73e15ae10ecd9e3 Mon Sep 17 00:00:00 2001 From: chengrui Date: Mon, 27 Mar 2017 18:42:36 +0800 Subject: [PATCH 12/18] format modification --- chapter/easter-eggs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chapter/easter-eggs.md b/chapter/easter-eggs.md index d83607c..625b4f9 100644 --- a/chapter/easter-eggs.md +++ b/chapter/easter-eggs.md @@ -6,8 +6,8 @@ | `:h 'sm'` | `注意:这个缩写是限制级` | | `:h 42` | `生命,宇宙和一切的意义是什么?不幸的是, 道格拉斯·亚当斯(Douglas Adams),唯一知道这个问题的人现在已经死了。所以现在你可能会想知道死亡的意思是什么……` | | `:h UserGettingBored` | `什么时候用户会按同一个键42次?好吧,我只是开个玩笑 :-)` | -| `:h bar` | `这不是一个烟斗(原文:Ceci n'est pas une pipe.)。` | +| `:h bar` | `这不是一个烟斗。(原文:Ceci n'est pas une pipe.)` | | `:h holy-grail` | `亚瑟,你终究找到了!` | | `:h map-modes` | `:nunmap命令在修道院外也能用.` | | `:help!` | `E478:别怕!` (故障? 在使用模块帮助时 (`模块类型=帮助`) 这和 `:h help.txt` 一个效果。) | -| `:smile` | 试一试这个表情 ;-) 添加于 7.4.1005. | +| `:smile` | `试一试这个表情 ;-) 添加于 7.4.1005.` | From 768bf7acefba31fa02890fdedc332caf0737f90c Mon Sep 17 00:00:00 2001 From: chengrui Date: Mon, 27 Mar 2017 18:47:10 +0800 Subject: [PATCH 13/18] fix --- chapter/why-hjkl-for-navigation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter/why-hjkl-for-navigation.md b/chapter/why-hjkl-for-navigation.md index ac3547f..394124a 100644 --- a/chapter/why-hjkl-for-navigation.md +++ b/chapter/why-hjkl-for-navigation.md @@ -7,5 +7,5 @@ 键盘布局: [请点击](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-adm-3a-layout.jpg) -这也告诉了我们为什么Unix系统会以`~`代表根目录。 +这也告诉了我们为什么Unix系统会以`~`代表主目录。 From b185c42c3ef877dd8c8d666a3a31833ebf79aa49 Mon Sep 17 00:00:00 2001 From: chengrui Date: Wed, 29 Mar 2017 10:03:28 +0800 Subject: [PATCH 14/18] format modification --- chapter/Miscellaneous.md | 4 +- chapter/easter-eggs.md | 10 +- chapter/map-capslock-to-control.md | 12 +- chapter/origin.md | 281 ----------------------------- chapter/standard-plugins.md | 7 +- chapter/vim-distributions.md | 17 +- chapter/why-hjkl-for-navigation.md | 9 +- 7 files changed, 27 insertions(+), 313 deletions(-) delete mode 100644 chapter/origin.md diff --git a/chapter/Miscellaneous.md b/chapter/Miscellaneous.md index d9bd5c4..3ac4407 100644 --- a/chapter/Miscellaneous.md +++ b/chapter/Miscellaneous.md @@ -2,7 +2,7 @@ ## 闄勫姞璧勬簮 -## Vim鍙戣鐗 +## Vim 鍙戣鐗 ## 鍐呯疆鎻掍欢 @@ -10,5 +10,5 @@ ## 澶嶆椿鑺傚僵铔 -## 涓轰粈涔堢敤hjkl绉诲姩鍏夋爣? +## 涓轰粈涔堢敤 hjkl 绉诲姩鍏夋爣锛 diff --git a/chapter/easter-eggs.md b/chapter/easter-eggs.md index 625b4f9..bb66cbc 100644 --- a/chapter/easter-eggs.md +++ b/chapter/easter-eggs.md @@ -2,12 +2,12 @@ | 命令 | 消息 | |-----------|---------| -| `:Ni!` | `你需要灌木丛?` | +| `:Ni!` | `你需要灌木丛?` | | `:h 'sm'` | `注意:这个缩写是限制级` | | `:h 42` | `生命,宇宙和一切的意义是什么?不幸的是, 道格拉斯·亚当斯(Douglas Adams),唯一知道这个问题的人现在已经死了。所以现在你可能会想知道死亡的意思是什么……` | | `:h UserGettingBored` | `什么时候用户会按同一个键42次?好吧,我只是开个玩笑 :-)` | -| `:h bar` | `这不是一个烟斗。(原文:Ceci n'est pas une pipe.)` | -| `:h holy-grail` | `亚瑟,你终究找到了!` | -| `:h map-modes` | `:nunmap命令在修道院外也能用.` | -| `:help!` | `E478:别怕!` (故障? 在使用模块帮助时 (`模块类型=帮助`) 这和 `:h help.txt` 一个效果。) | +| `:h bar` | `这不是一个烟斗。` | +| `:h holy-grail` | `亚瑟,你终究找到了!` | +| `:h map-modes` | `:nunmap 命令在修道院外也能用.` | +| `:help!` | `E478:别怕!` (故障? 在使用模块帮助时 (`模块类型=帮助`) 这和 `:h help.txt` 一个效果。) | | `:smile` | `试一试这个表情 ;-) 添加于 7.4.1005.` | diff --git a/chapter/map-capslock-to-control.md b/chapter/map-capslock-to-control.md index 70bc368..a5bf1bb 100644 --- a/chapter/map-capslock-to-control.md +++ b/chapter/map-capslock-to-control.md @@ -1,16 +1,16 @@ ## 映射大写锁定键(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) 。 +[重复使力伤害](https://de.wikipedia.org/wiki/Repetitive-Strain-Injury-Syndrom) (ps:为什么将 jk 映射为 esc,而不是 jj,重复点击同一个按键对手指伤害很大)。 友情提示:当你习惯这个设定后,你就离不开它了。 **OSX**: `System Preferences -> Keyboard -> Keyboard Tab -> Modifier Keys`. 变更 -"CapsLock" 为 "Control". +"CapsLock" 为 "Control"。 **Linux**: @@ -20,11 +20,11 @@ keysym Caps_Lock = Control_L add Control = Control_L -用以下命令使之生效
`$ xmodmap ~/.xmodmap`. +用以下命令使之生效
`$ xmodmap ~/.xmodmap`。 替代方法有[caps2esc](https://github.com/oblitum/caps2esc) 或者 -[xcape](https://github.com/alols/xcape). +[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). +请参看 [superuser.com: 在Windows8.1映射大写锁定键到控制键](http://superuser.com/questions/764782/map-caps-lock-to-control-in-windows-8-1)。 diff --git a/chapter/origin.md b/chapter/origin.md deleted file mode 100644 index 44266b5..0000000 --- a/chapter/origin.md +++ /dev/null @@ -1,281 +0,0 @@ -# Miscellaneous - -## Additional resources - -| Resource | Description | -|----------|-------------| -| [Seven habits of effective text editing](http://www.moolenaar.net/habits.html) | By Bram Moolenaar, the author of Vim. | -| [Seven habits of effective text editing 2.0 (PDF)](http://www.moolenaar.net/habits_2007.pdf) | See above. | -| [IBM DeveloperWorks: Scripting the Vim editor](http://www.ibm.com/developerworks/views/linux/libraryview.jsp?sort_order=asc&sort_by=Title&search_by=scripting+the+vim+editor) | Five-part series on Vim scripting. | -| [Learn Vimscript the Hard Way](http://learnvimscriptthehardway.stevelosh.com) | Develop a Vim plugin from scratch. | -| [Practical Vim (2nd Edition)](http://www.amazon.com/Practical-Vim-Edit-Speed-Thought/dp/1680501275/) | Hands down the best book about Vim. | -| [Vimcasts.org](http://vimcasts.org/episodes/archive) | Vim screencasts. | -| [Why, oh WHY, do those #?@! nutheads use vi?](http://www.viemu.com/a-why-vi-vim.html) | Common misconceptions explained. | -| [Your problem with Vim is that you don't grok vi](http://stackoverflow.com/a/1220118) | Concise, informative and correct. A real gem. | - -## Vim distributions - -Vim distributions are bundles of custom settings and plugins for Vim. - -More advanced users know how to configure their editor anyway, so distributions -are mostly targeted at beginners. If you think about that, it's quite -paradoxical though: Making it easier by adding even more things to learn about? - -I know that many people don't want to spend hours and hours on customizing an -editor (and actually you never stop customizing your vimrc when you finally got -hooked), but eventually you only get efficient in Vim when you take the time to -learn it properly. - -Repeat after me: "A programmer should know their tools." - -Anyway, if you know what you're doing, you might draw some inspiration from -looking at a few distributions: - -- [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) - -## Standard plugins - -Surprising to many people, Vim comes with a handful of plugins on its own that -all get loaded by default. Check `:scriptnames` after starting Vim to see all -sourced files. - -Most of them will never get used, so disable them as you see fit. They will -still be shown as sourced, but only the first lines actually get read before Vim -bails out. No further code (mappings, commands, logic) will be processed. - -| Plugin | Disable it using.. | Help | -|------------|-------------------------------------|------| -| 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` | - -## Map CapsLock to Control - -CapsLock belongs to the most useless keys on your keyboard, but it's much easier -to reach than the Control key, since it lies on your [home -row](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-homerow.png). -Mapping CapsLock to Control is a great way to prevent or at least reduce -[RSI](https://de.wikipedia.org/wiki/Repetitive-Strain-Injury-Syndrom) if you -program a lot. - -Attention: When you get used to it, you can't live without it anymore. - -**OSX**: - -`System Preferences -> Keyboard -> Keyboard Tab -> Modifier Keys`. Change -"CapsLock" to "Control". - -**Linux**: - -To change the keys in X, put this in your `~/.xmodmap`: - - remove Lock = Caps_Lock - keysym Caps_Lock = Control_L - add Control = Control_L - -Afterwards source it via `$ xmodmap ~/.xmodmap`. - -An alternative would be using [caps2esc](https://github.com/oblitum/caps2esc) or -[xcape](https://github.com/alols/xcape). - -**Windows**: - -See [superuser.com: Map Caps-Lock to Control in Windows -8.1](http://superuser.com/questions/764782/map-caps-lock-to-control-in-windows-8-1). - -## Easter eggs - -| Command | Message | -|-----------|---------| -| `:Ni!` | `Do you demand a shrubbery?` | -| `:h 'sm'` | `NOTE: Use of the short form is rated PG.` | -| `:h 42` | `What is the meaning of life, the universe and everything? Douglas Adams, the only person who knew what this question really was about is now dead, unfortunately. So now you might wonder what the meaning of death is...` | -| `:h UserGettingBored` | `When the user presses the same key 42 times. Just kidding! :-)` | -| `:h bar` | `Ceci n'est pas une pipe.` | -| `:h holy-grail` | `You found it, Arthur!` | -| `:h map-modes` | `:nunmap can also be used outside of a monastery.` | -| `:help!` | `E478: Don't panic!` (Glitch? When used in a help buffer (`buftype=help`) this works like `:h help.txt` instead.) | -| `:smile` | Try it out yourself. ;-) Added in 7.4.1005. | - -## Why hjkl for navigation? - -When [Bill Joy](https://en.wikipedia.org/wiki/Bill_Joy) created -[vi](https://en.wikipedia.org/wiki/Vi), a predecessor of Vim, he did it on a -[ADM-3A](https://en.wikipedia.org/wiki/ADM-3A) which had no extra cursor buttons -but used, you might already guessed it, hjkl instead. - -Keyboard layout: [click](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-adm-3a-layout.jpg) - -This also shows why `~` is used to denote the home directory on Unix systems. - -# Common problems - -## Editing small files is slow - -There are two things which can have a huge impact on performance: - -1. Complex **regular expressions**. Particular the Ruby syntax file caused - people to have slowdowns in the past. (Also see [Debugging syntax files](#debugging-syntax-files).) -2. **Screen redraws**. Some features force all lines to redraw. - -| Typical culprit | Why? | Solution? | -|-----------------|------|-----------| -| `:set cursorline` | Causes all lines to redraw. | `:set nocursorline` | -| `:set cursorcolumn` | Causes all lines to redraw. | `:set nocursorcolumn` | -| `:set relativenumber` | Causes all lines to redraw. | `:set norelativenumber` | -| `:set foldmethod=syntax` | If the syntax file is slow already, this makes it even worse. | `:set foldmethod=manual`, `:set foldmethod=marker` or [FastFold](https://github.com/Konfekt/FastFold) | -| `:set synmaxcol=3000` | Due to internal representation, Vim has problems with long lines in general. Highlights columns till column 3000. | `:set synmaxcol=200` | -| matchparen.vim | Loaded by default. Uses regular expressions to find the accompanying parenthesis. | Disable plugin: `:h matchparen` | - -**NOTE**: You only need to do this if you experience actual performance -drawbacks. In most cases using the things mentioned above is absolutely fine. - -## Editing huge files is slow - -The biggest issue with big files is, that Vim reads the whole file at once. This -is done due to how buffers are represented internally. -([Discussion on vim_dev@](https://groups.google.com/forum/#!topic/vim_dev/oY3i8rqYGD4/discussion)) - -If you only want to read, `tail hugefile | vim -` is a good workaround. - -If you can live without syntax, settings and plugins for the moment: - -``` -$ vim -u NONE -N -``` - -This should make navigation quite a lot faster, especially since no expensive -regular expressions for syntax highlighting are used. You should also tell Vim -not to use swapfiles and viminfo files to avoid long delays on writing: - -``` -$ vim -n -u NONE -i NONE -N -``` - -Putting it in a nutshell, try to avoid using Vim when intending to write really -huge files. :\ - -## Bracketed paste (or why do I have to set 'paste' all the time?) - -Bracketed paste mode allows terminal emulators to distinguish between typed text -and pasted text. - -Did you ever tried pasting code into Vim and afterwards everything seemed messed -up? - -This only happens if you paste via `cmd+v`, `shift-insert`, `middle-click` etc. -because then you're just throwing text at the terminal emulator. Vim doesn't -know that you just pasted the text, it thinks you're an extremely fast typist. -Accordingly, it tries to indent the lines and fails. - -Obviously this is not an issue, if you paste using Vim's registers, e.g. `"+p`, -because then Vim knows that you're actually pasting. - -To workaround this, you have to `:set paste`, so it gets pasted as-is. See `:h -'paste'` and `:h 'pastetoggle'`. - -If you're fed up with toggling `'paste'` all the time, have a look at this fine -plugin that does it for you: -[bracketed-paste](https://github.com/ConradIrwin/vim-bracketed-paste). - -Additional read from the same author as the plugin: -[here](http://cirw.in/blog/bracketed-paste). - -**Neovim**: Neovim tries to make all of this much more seamless and sets -bracketed paste mode automatically if the terminal emulator supports it. - -## Delays when using escape key in terminal - -If you live in the command-line, you probably use a so-called _terminal -emulator_ like xterm, gnome-terminal, iTerm2, etc. (opposed to a real -[terminal](https://en.wikipedia.org/wiki/Computer_terminal)). - -Like their ancestors, terminal emulators use [escape -sequences](https://en.wikipedia.org/wiki/Escape_sequence) (or _control -sequences_) to control things like moving the cursor, changing text colors, etc. -They're simply strings of ASCII characters starting with an escape character -(displayed in [caret notation](https://en.wikipedia.org/wiki/Caret_notation) as -`^[`). When such a string arrives, the terminal emulator looks up the -accompanying action in the [terminfo](https://en.wikipedia.org/wiki/Terminfo) -database. - -To make the problem clearer, I'll explain mapping timeouts first. They always -happen when there's ambiguity between mappings: - -```vim -:nnoremap ,a :echo 'foo' -:nnoremap ,ab :echo 'bar' -``` - -Both mappings work as expected, but when typing `,a`, there will be a delay of 1 -second, because Vim waits whether the user keys in another `b` or not. - -Escape sequences pose the same problem: - -- `` is used a lot for returning to normal mode or quitting an action. -- Cursor keys are encoded using escape sequences. -- Vim expects Alt (also called _Meta key_) to send a proper 8-bit - encoding with the high bit set, but many terminal emulators don't support it - (or don't enable it by default) and send an escape sequence instead. - -You can test the above like this: `vim -u NONE -N` and type `i` and -you'll see a sequence inserted that starts with `^[` which denotes the escape -character. - -Putting it in a nutshell, Vim has a hard time distinguishing between a typed -`` character and a proper escape sequence. - -By default, Vim uses `:set timeout timeoutlen=1000`, so it delays on ambiguity -of mappings _and_ key codes by 1 second. This is a sane value for mappings, but -you can define the key code timeout on its own which is the most common -workaround for this entire issue: - -```vim -set timeout " for mappings -set timeoutlen=1000 " default value -set ttimeout " for key codes -set ttimeoutlen=10 " unnoticeable small value -``` - -Under `:h ttimeout` you find a small table showing the relationship between -these options. - -If you're using tmux between Vim and your terminal emulator, also put this in -your `~/.tmux.conf`: - -```tmux -set -sg escape-time 0 -``` - -## Function search undo - -- A search pattern in a command (`/`, `:substitute`, ...) changes the "last used - search pattern". (It's saved in the `/` register; print it with `:echo @/`). -- A simple text change can be redone with `.`. (It's saved in the `.` register; - print it with `:echo @.`). - -Both things are _not_ the case, if you do them from a function, though! Thus you -can't easily highlight words from a function or redo the text changes made by -it. - -Help: `:h function-search-undo` - -# Technical quirks - -## Newline used for NUL - -NUL characters (`\0`) in a file, are stored as newline (`\n`) in memory and -displayed in a buffer as `^@`. - -See `man 7 ascii` and `:h NL-used-for-Nul` for more information. diff --git a/chapter/standard-plugins.md b/chapter/standard-plugins.md index 23686a4..fc5073c 100644 --- a/chapter/standard-plugins.md +++ b/chapter/standard-plugins.md @@ -1,12 +1,11 @@ ## 内置插件 -出乎很多人的意料,Vim自己默认加载了大把大把的插件。
-启动Vim后,用`:scriptnames`查看所有加载的源文件 +出乎很多人的意料,Vim自己默认加载了大把大把的插件。启动 Vim 后,用`:scriptnames`查看所有加载的源文件 -这些文件多数永远不会被用到,所以请禁止如你所见的以下插件。
+这些文件多数永远不会被用到,所以请禁止如你所见的以下插件。 这些插件仍旧会在源文件列出,但是当Vim启动时,只有第一行会被读取,而之后的配置,命令和日志都不会执行。 -| Plugin | Disable it using.. | Help | +| 插件 | 禁用 | 帮助 | |------------|-------------------------------------|------| | 2html | `let g:loaded_2html_plugin = 1` | `:h 2html` | | getscript | `let g:loaded_getscriptPlugin = 1` | `:h pi_getscript` | diff --git a/chapter/vim-distributions.md b/chapter/vim-distributions.md index 5989c6b..e2e6752 100644 --- a/chapter/vim-distributions.md +++ b/chapter/vim-distributions.md @@ -1,17 +1,16 @@ -## Vim发行版 +## Vim 配置集合 -Vim发行版是集成客制化设定和Vim插件的包 +Vim 配置集合是集成多多种插件以及相关配置的组合。 -高阶用户总是知道如何构建自己的编辑器,所以发行版一般是针对初学者。
-如果你考虑这方面,那么这就是一个非常辩证的想法:
-加入更多需要学的东西,使得学习本身变得简单。 +高阶用户总是知道如何构建自己的编辑器,所以发行版一般是针对初学者。 +如果你想要尝试,那么将面临一个辩证的想法:加入很多额外的东西来学习 Vim 是否会让这变得更加简单。 -我知道很多人不想在编辑器上花很多时间(当你卡住时,你实际上在不停地花时间定制自己的vimrc),
-但是只有正确地去了解Vim,你才能最终从它身上获得高效。 +我知道很多人不想在配置编辑器上花过多时间(但实际上,当你卡住时,你就会不停地花时间定制自己的 vimrc) +因此,想要节约时间,那么就因该真正的去了解和学习 Vim 原生功能,只有这样你才能中获益。 -跟我说一遍: "一个程序员需要懂得他的工具。" +再次强调一下:“一个程序员应当懂得他的工具”。 -无论如何,如果你知道自己在做什么,那你也许能从以下几个发行版Vim中获得一些灵感 +总之,如果你知道自己在做什么,你也许能从以下几个 Vim 配置集合中获得一些灵感。 - [cream](http://cream.sourceforge.net) - [janus](https://github.com/carlhuda/janus.git) diff --git a/chapter/why-hjkl-for-navigation.md b/chapter/why-hjkl-for-navigation.md index 394124a..28b5288 100644 --- a/chapter/why-hjkl-for-navigation.md +++ b/chapter/why-hjkl-for-navigation.md @@ -1,11 +1,8 @@ -## 为什么用hjkl移动光标? +## 为什么用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作为光标控制键。 +当 [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系统会以`~`代表主目录。 +这也告诉了我们为什么 Unix 系统会以`~`代表主目录。 From c2540eeb964c37fe933a595fffdf0937d2b76cf3 Mon Sep 17 00:00:00 2001 From: chengrui Date: Wed, 29 Mar 2017 10:08:15 +0800 Subject: [PATCH 15/18] change translation of distributions --- chapter/Miscellaneous.md | 2 +- chapter/vim-distributions.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chapter/Miscellaneous.md b/chapter/Miscellaneous.md index 3ac4407..3241844 100644 --- a/chapter/Miscellaneous.md +++ b/chapter/Miscellaneous.md @@ -2,7 +2,7 @@ ## 闄勫姞璧勬簮 -## Vim 鍙戣鐗 +## Vim 閰嶇疆闆嗗悎 ## 鍐呯疆鎻掍欢 diff --git a/chapter/vim-distributions.md b/chapter/vim-distributions.md index e2e6752..8561d01 100644 --- a/chapter/vim-distributions.md +++ b/chapter/vim-distributions.md @@ -2,7 +2,7 @@ Vim 配置集合是集成多多种插件以及相关配置的组合。 -高阶用户总是知道如何构建自己的编辑器,所以发行版一般是针对初学者。 +高阶用户总是知道如何构建自己的编辑器,所以配置集合一般是针对初学者。 如果你想要尝试,那么将面临一个辩证的想法:加入很多额外的东西来学习 Vim 是否会让这变得更加简单。 我知道很多人不想在配置编辑器上花过多时间(但实际上,当你卡住时,你就会不停地花时间定制自己的 vimrc) From 6b9c31ddbef9b48f589688f27341ecd0e9ee8a97 Mon Sep 17 00:00:00 2001 From: chengrui Date: Wed, 29 Mar 2017 18:14:19 +0800 Subject: [PATCH 16/18] translating common-problems and technical-quirks --- chapter/Common problems.md | 12 ++--- chapter/Technical quirks.md | 3 ++ chapter/additional-resources.md | 12 ++--- chapter/bracketed-paste.md | 18 ++++++++ ...elays-when-using-escape-key-in-terminal.md | 44 +++++++++++++++++++ chapter/editing-huge-files-is-slow.md | 20 +++++++++ chapter/editing-small-files-is-slow.md | 17 +++++++ chapter/function-search-undo.md | 8 ++++ chapter/newline-used-for-nul.md | 5 +++ 9 files changed, 127 insertions(+), 12 deletions(-) create mode 100644 chapter/Technical quirks.md create mode 100644 chapter/newline-used-for-nul.md diff --git a/chapter/Common problems.md b/chapter/Common problems.md index 8c33cb4..08260f8 100644 --- a/chapter/Common problems.md +++ b/chapter/Common problems.md @@ -1,11 +1,11 @@ -# Common problems +# 甯歌闂 -## Editing small files is slow +## 缂栬緫灏忔枃浠跺緢鎱 -## Editing huge files is slow +## 缂栬緫澶ф枃浠跺緢鎱 -## Bracketed paste (or why do I have to set 'paste' all the time?) +## 鐩稿悓閮ㄥ垎绮樿创 (瑕佷笉涓轰粈涔堟垜鎬昏璁剧疆鈥樼矘璐粹欙紵) -## Delays when using escape key in terminal +## 浣跨敤缁堢涓 Esc 閿椂鐨勫欢杩 -## Function search undo \ No newline at end of file +## 鏃犳硶閲嶅鍑芥暟涓墽琛岀殑鎼滅储 diff --git a/chapter/Technical quirks.md b/chapter/Technical quirks.md new file mode 100644 index 0000000..7e62e44 --- /dev/null +++ b/chapter/Technical quirks.md @@ -0,0 +1,3 @@ +# 技术怪癖 + +## NUL 符用新行表示 diff --git a/chapter/additional-resources.md b/chapter/additional-resources.md index 944ffab..60ccb3f 100644 --- a/chapter/additional-resources.md +++ b/chapter/additional-resources.md @@ -2,11 +2,11 @@ | 资源名称 | 简介 | |----------|-------------| -| [七个高效的文本编辑习惯](http://www.moolenaar.net/habits.html) | 作者:Bram Moolenaar(即Vim的作者) | +| [七个高效的文本编辑习惯](http://www.moolenaar.net/habits.html) | 作者:Bram Moolenaar(即 Vim 的作者) | | [七个高效的文本编辑习惯2.0(PDF版)](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最佳书籍 | +| [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 +| [为什么是个脚本都用 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 index e69de29..f7356d4 100644 --- a/chapter/bracketed-paste.md +++ 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'` ,看一看这个不错的插件能为你做什么:[粘贴归类](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 index e69de29..d364eff 100644 --- a/chapter/delays-when-using-escape-key-in-terminal.md +++ 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` 还是不会了。 + +退出序列也会引起一样的问题: + +- `` 在返回正常模式或退出指令时被大量使用。 +- 光标键使用了退出序列进行编码 +- Vim 运用 Alt (也被称为 _Meta key_)去发送固定的高位集编码的8位比特,但是很多终端虚拟器不支持(或者默认不启用),而用退出序列代替。 + +你可以用 `vim -u NONE -N` 试一试上面所说的,然后键入 `i` ,你就会看见一串以 `^[`(表征退出码)开头的被输入序列。 + +简而言之,区分键入的 `` 和一个严格意义上的退出序列对 Vim 来说是一个痛苦的过程。 + +默认情况下 `:set timeout timeoutlen=1000` ,Vim 会有1秒的延迟在等 _还有吗_ 的模糊映射。 +对于映射来说,这是一个稳健的值,但是通常为了解决整个问题,你可以自定义键入的超时阈值: + +```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/editing-huge-files-is-slow.md b/chapter/editing-huge-files-is-slow.md index e69de29..e3c0cae 100644 --- a/chapter/editing-huge-files-is-slow.md +++ 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 信息文件,以避免写入时的长延迟。 + +``` +$ 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 index e69de29..a2ac3f3 100644 --- a/chapter/editing-small-files-is-slow.md +++ 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 [FastFold](https://github.com/Konfekt/FastFold) | +| `:set synmaxcol=3000` | 根据内部表示规则, Vim 一般不待见对很长的行。这一设定导致3000列时才会把所在行高亮。 | `:set synmaxcol=200` | +| matchparen.vim | 使用默认加载。使用正则表达式去匹配括回。 | Disable plugin: `:h matchparen` | + +**注意**: 只有当真的遭遇实质的性能缺陷时,你才需要做这些改进。多数情况下,上面提到的这些方面还都凑合。 diff --git a/chapter/function-search-undo.md b/chapter/function-search-undo.md index e69de29..7db6925 100644 --- a/chapter/function-search-undo.md +++ 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/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 From 96e16a6862d8c399beb38fa225b9244b91d2faa8 Mon Sep 17 00:00:00 2001 From: Laotree Date: Wed, 29 Mar 2017 18:21:35 +0800 Subject: [PATCH 17/18] Update editing-small-files-is-slow.md --- chapter/editing-small-files-is-slow.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/chapter/editing-small-files-is-slow.md b/chapter/editing-small-files-is-slow.md index a2ac3f3..0e519c7 100644 --- a/chapter/editing-small-files-is-slow.md +++ b/chapter/editing-small-files-is-slow.md @@ -1,17 +1,17 @@ -## 编辑小文件很慢 +## 缂栬緫灏忔枃浠跺緢鎱 -对性能有重大影响的有两个方面: +瀵规ц兘鏈夐噸澶у奖鍝嶇殑鏈変袱涓柟闈細 -1. 复杂的**正则表达式**。尤其是 Ruby 语法文件导致人们过去一直慢慢吞吞。([Debugging syntax files](#debugging-syntax-files)里也有说明。) -2. **页面刷新**。一些特性强制所有行都刷新。 +1. 澶嶆潅鐨**姝e垯琛ㄨ揪寮**銆傚挨鍏舵槸 Ruby 璇硶鏂囦欢瀵艰嚧浜轰滑杩囧幓涓鐩存參鎱㈠悶鍚炪傦紙[Debugging syntax files](#debugging-syntax-files)閲屼篃鏈夎鏄庛傦級 +2. **椤甸潰鍒锋柊**銆備竴浜涚壒鎬у己鍒舵墍鏈夎閮藉埛鏂般 -| 典型败笔 | 原因? | 解决方法? | +| 鍏稿瀷璐ョ瑪 | 鍘熷洜锛 | 瑙e喅鏂规硶锛 | |-----------------|------|-----------| -| `:set cursorline` | 导致所有行刷新。 | `:set nocursorline` | -| `:set cursorcolumn` | 导致所有行刷新。 | `:set nocursorcolumn` | -| `:set relativenumber` | 导致所有行刷新。 | `:set norelativenumber` | -| `:set foldmethod=syntax` | 语法文件算减速的话,这无异于刹车。 | `:set foldmethod=manual`, `:set foldmethod=marker` or [FastFold](https://github.com/Konfekt/FastFold) | -| `:set synmaxcol=3000` | 根据内部表示规则, Vim 一般不待见对很长的行。这一设定导致3000列时才会把所在行高亮。 | `:set synmaxcol=200` | -| matchparen.vim | 使用默认加载。使用正则表达式去匹配括回。 | Disable plugin: `:h matchparen` | +| `: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` | -**注意**: 只有当真的遭遇实质的性能缺陷时,你才需要做这些改进。多数情况下,上面提到的这些方面还都凑合。 +**娉ㄦ剰**: 鍙湁褰撶湡鐨勯伃閬囧疄璐ㄧ殑鎬ц兘缂洪櫡鏃讹紝浣犳墠闇瑕佸仛杩欎簺鏀硅繘銆傚鏁版儏鍐典笅锛屼笂闈㈡彁鍒扮殑杩欎簺鏂归潰杩橀兘鍑戝悎銆 From a175b24eee113bbe5a0537291d43d28c357fb515 Mon Sep 17 00:00:00 2001 From: Laotree Date: Wed, 29 Mar 2017 18:23:25 +0800 Subject: [PATCH 18/18] fix messy code --- chapter/Technical quirks.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chapter/Technical quirks.md b/chapter/Technical quirks.md index 7e62e44..a36ee9b 100644 --- a/chapter/Technical quirks.md +++ b/chapter/Technical quirks.md @@ -1,3 +1,3 @@ -# 技术怪癖 +# 鎶鏈櫀 -## NUL 符用新行表示 +## NUL 绗︾敤鏂拌琛ㄧず