Compare commits
60 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e8cd400a53 | ||
|
7890fd102a | ||
|
9ae28a34e3 | ||
|
7eeafbeaf5 | ||
|
4cad0143f9 | ||
|
5cceeb115f | ||
|
45ad324ed4 | ||
|
73eca6f8b6 | ||
|
6e0496992f | ||
|
44b00f7357 | ||
|
a1ab9dd72a | ||
|
6c2e09bd66 | ||
|
7a89eb0d5a | ||
|
29b9976b94 | ||
|
0f4bf2553c | ||
|
7fdcb36d41 | ||
|
a4665cd968 | ||
|
4d50e005fd | ||
|
4b5485bd6a | ||
|
c9ce46c514 | ||
|
f2122779aa | ||
|
6588b1c406 | ||
|
242d25ca0f | ||
|
882c18232f | ||
|
afa1a2be14 | ||
|
821dc362df | ||
|
2871bbaf57 | ||
|
6be167f4a9 | ||
|
15cf0dc156 | ||
|
01c6a7e93c | ||
|
b862ddf180 | ||
|
f7a9f1a361 | ||
|
387f0c71cb | ||
|
8bebab9728 | ||
|
3979815783 | ||
|
7a75b64f1b | ||
|
df3efb68cc | ||
|
349e147826 | ||
|
b8fb0ba7e6 | ||
|
98f5e0c693 | ||
|
e41e63192b | ||
|
f86d778356 | ||
|
ec0d59b061 | ||
|
5fe5f596ae | ||
|
0e4a3eb843 | ||
|
a27c208959 | ||
|
2b27bec9b5 | ||
|
5ea7550ef9 | ||
|
e0017a31f4 | ||
|
6243b93e22 | ||
|
1f5b6ad939 | ||
|
9df475b401 | ||
|
543333af7e | ||
|
3f054ca818 | ||
|
d4a317d5c3 | ||
|
f854f2c994 | ||
|
e197f87ec9 | ||
|
4903728828 | ||
|
b3a51b2cc2 | ||
|
ad42c9a2c6 |
427
LICENSE
Normal file
427
LICENSE
Normal file
@ -0,0 +1,427 @@
|
||||
Attribution-ShareAlike 4.0 International
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
||||
does not provide legal services or legal advice. Distribution of
|
||||
Creative Commons public licenses does not create a lawyer-client or
|
||||
other relationship. Creative Commons makes its licenses and related
|
||||
information available on an "as-is" basis. Creative Commons gives no
|
||||
warranties regarding its licenses, any material licensed under their
|
||||
terms and conditions, or any related information. Creative Commons
|
||||
disclaims all liability for damages resulting from their use to the
|
||||
fullest extent possible.
|
||||
|
||||
Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and
|
||||
conditions that creators and other rights holders may use to share
|
||||
original works of authorship and other material subject to copyright
|
||||
and certain other rights specified in the public license below. The
|
||||
following considerations are for informational purposes only, are not
|
||||
exhaustive, and do not form part of our licenses.
|
||||
|
||||
Considerations for licensors: Our public licenses are
|
||||
intended for use by those authorized to give the public
|
||||
permission to use material in ways otherwise restricted by
|
||||
copyright and certain other rights. Our licenses are
|
||||
irrevocable. Licensors should read and understand the terms
|
||||
and conditions of the license they choose before applying it.
|
||||
Licensors should also secure all rights necessary before
|
||||
applying our licenses so that the public can reuse the
|
||||
material as expected. Licensors should clearly mark any
|
||||
material not subject to the license. This includes other CC-
|
||||
licensed material, or material used under an exception or
|
||||
limitation to copyright. More considerations for licensors:
|
||||
wiki.creativecommons.org/Considerations_for_licensors
|
||||
|
||||
Considerations for the public: By using one of our public
|
||||
licenses, a licensor grants the public permission to use the
|
||||
licensed material under specified terms and conditions. If
|
||||
the licensor's permission is not necessary for any reason--for
|
||||
example, because of any applicable exception or limitation to
|
||||
copyright--then that use is not regulated by the license. Our
|
||||
licenses grant only permissions under copyright and certain
|
||||
other rights that a licensor has authority to grant. Use of
|
||||
the licensed material may still be restricted for other
|
||||
reasons, including because others have copyright or other
|
||||
rights in the material. A licensor may make special requests,
|
||||
such as asking that all changes be marked or described.
|
||||
Although not required by our licenses, you are encouraged to
|
||||
respect those requests where reasonable. More_considerations
|
||||
for the public:
|
||||
wiki.creativecommons.org/Considerations_for_licensees
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Attribution-ShareAlike 4.0 International Public
|
||||
License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution-ShareAlike 4.0 International Public License ("Public
|
||||
License"). To the extent this Public License may be interpreted as a
|
||||
contract, You are granted the Licensed Rights in consideration of Your
|
||||
acceptance of these terms and conditions, and the Licensor grants You
|
||||
such rights in consideration of benefits the Licensor receives from
|
||||
making the Licensed Material available under these terms and
|
||||
conditions.
|
||||
|
||||
|
||||
Section 1 -- Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Adapter's License means the license You apply to Your Copyright
|
||||
and Similar Rights in Your contributions to Adapted Material in
|
||||
accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. BY-SA Compatible License means a license listed at
|
||||
creativecommons.org/compatiblelicenses, approved by Creative
|
||||
Commons as essentially the equivalent of this Public License.
|
||||
|
||||
d. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
e. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
f. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
g. License Elements means the license attributes listed in the name
|
||||
of a Creative Commons Public License. The License Elements of this
|
||||
Public License are Attribution and ShareAlike.
|
||||
|
||||
h. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
i. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
j. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
k. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
l. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
m. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part; and
|
||||
|
||||
b. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. Additional offer from the Licensor -- Adapted Material.
|
||||
Every recipient of Adapted Material from You
|
||||
automatically receives an offer from the Licensor to
|
||||
exercise the Licensed Rights in the Adapted Material
|
||||
under the conditions of the Adapter's License You apply.
|
||||
|
||||
c. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material (including in modified
|
||||
form), You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
b. ShareAlike.
|
||||
|
||||
In addition to the conditions in Section 3(a), if You Share
|
||||
Adapted Material You produce, the following conditions also apply.
|
||||
|
||||
1. The Adapter's License You apply must be a Creative Commons
|
||||
license with the same License Elements, this version or
|
||||
later, or a BY-SA Compatible License.
|
||||
|
||||
2. You must include the text of, or the URI or hyperlink to, the
|
||||
Adapter's License You apply. You may satisfy this condition
|
||||
in any reasonable manner based on the medium, means, and
|
||||
context in which You Share Adapted Material.
|
||||
|
||||
3. You may not offer or impose any additional or different terms
|
||||
or conditions on, or apply any Effective Technological
|
||||
Measures to, Adapted Material that restrict exercise of the
|
||||
rights granted under the Adapter's License You apply.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material,
|
||||
|
||||
including for purposes of Section 3(b); and
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons is not a party to its public
|
||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
||||
its public licenses to material it publishes and in those instances
|
||||
will be considered the “Licensor.” The text of the Creative Commons
|
||||
public licenses is dedicated to the public domain under the CC0 Public
|
||||
Domain Dedication. Except for the limited purpose of indicating that
|
||||
material is shared under a Creative Commons public license or as
|
||||
otherwise permitted by the Creative Commons policies published at
|
||||
creativecommons.org/policies, Creative Commons does not authorize the
|
||||
use of the trademark "Creative Commons" or any other trademark or logo
|
||||
of Creative Commons without its prior written consent including,
|
||||
without limitation, in connection with any unauthorized modifications
|
||||
to any of its public licenses or any other arrangements,
|
||||
understandings, or agreements concerning use of licensed material. For
|
||||
the avoidance of doubt, this paragraph does not form part of the
|
||||
public licenses.
|
||||
|
||||
Creative Commons may be contacted at creativecommons.org.
|
96
PLUGINS.md
96
PLUGINS.md
@ -1,35 +1,33 @@
|
||||
## 插件列表
|
||||
|
||||
#### [Colorschemes](#colorschemes-1)
|
||||
<!-- vim-markdown-toc GFM -->
|
||||
|
||||
#### [By topic](#by-topic-1)
|
||||
|
||||
- [Alignment](#alignment)
|
||||
- [Building and linting](#building-and-linting)
|
||||
- [Code completion](#code-completion)
|
||||
- [Commenters](#commenters)
|
||||
- [颜色主题](#颜色主题)
|
||||
- [按功能分类](#按功能分类)
|
||||
- [文本对齐](#文本对齐)
|
||||
- [语法检查](#语法检查)
|
||||
- [代码补全](#代码补全)
|
||||
- [Cycle](#cycle)
|
||||
- [Delimiter](#delimiter)
|
||||
- [Fuzzy finders](#fuzzy-finders)
|
||||
- [Grep tools](#grep-tools)
|
||||
- [Indent](#indent)
|
||||
- [Misc](#misc)
|
||||
- [代码注释](#代码注释)
|
||||
- [自动补全括号](#自动补全括号)
|
||||
- [模糊搜索](#模糊搜索)
|
||||
- [文本搜索](#文本搜索)
|
||||
- [代码对齐线](#代码对齐线)
|
||||
- [Navigation](#navigation)
|
||||
- [Plugin managers](#plugin-managers)
|
||||
- [Snippets](#snippets)
|
||||
- [Statusline](#statusline)
|
||||
- [插件管理](#插件管理)
|
||||
- [代码片段](#代码片段)
|
||||
- [状态栏](#状态栏)
|
||||
- [Surround](#surround)
|
||||
- [Taking notes](#taking-notes)
|
||||
- [Testing](#testing)
|
||||
- [Text objects](#text-objects)
|
||||
- [文本对象](#文本对象)
|
||||
- [Tmux](#tmux)
|
||||
- [Undo history](#undo-history)
|
||||
- [Version control](#version-control)
|
||||
- [编辑历史管理](#编辑历史管理)
|
||||
- [版本控制](#版本控制)
|
||||
- [Writing](#writing)
|
||||
|
||||
#### [By filetype](#by-filetype-1)
|
||||
|
||||
- [C and C++](#c-and-c)
|
||||
- [Misc](#misc)
|
||||
- [编程语言](#编程语言)
|
||||
- [C、C++](#cc)
|
||||
- [Clojure](#clojure)
|
||||
- [Elixir](#elixir)
|
||||
- [Go](#go)
|
||||
@ -42,9 +40,11 @@
|
||||
- [TeX](#tex)
|
||||
- [VimL](#viml)
|
||||
|
||||
## Colorschemes
|
||||
<!-- vim-markdown-toc -->
|
||||
|
||||
Here's a list of commonly used colorschemes:
|
||||
### 颜色主题
|
||||
|
||||
以下为一些比较流行的颜色主题:
|
||||
|
||||
- [acme-colors](https://github.com/plan9-for-vimspace/acme-colors)
|
||||
- [apprentice](https://github.com/romainl/Apprentice)
|
||||
@ -69,65 +69,70 @@ Here's a list of commonly used colorschemes:
|
||||
Alternatively, generate your own colorscheme using [themer](https://github.com/mjswensen/themer)
|
||||
or [Colortemplate](https://github.com/lifepillar/vim-colortemplate).
|
||||
|
||||
## By topic
|
||||
### 按功能分类
|
||||
|
||||
#### Alignment
|
||||
#### 文本对齐
|
||||
|
||||
- [tabular](https://github.com/godlygeek/tabular)
|
||||
- [vim-easy-align](https://github.com/junegunn/vim-easy-align)
|
||||
- [vim-lion](https://github.com/tommcdo/vim-lion)
|
||||
|
||||
#### Building and linting
|
||||
#### 语法检查
|
||||
|
||||
- [ale](https://github.com/w0rp/ale)
|
||||
- [neomake](https://github.com/neomake/neomake)
|
||||
- [syntastic](https://github.com/vim-syntastic/syntastic)
|
||||
|
||||
#### Code completion
|
||||
#### 代码补全
|
||||
|
||||
- [VimCompletesMe](https://github.com/ajh17/VimCompletesMe)
|
||||
- [YouCompleteMe](https://github.com/Valloric/YouCompleteMe)
|
||||
- [asyncomplete.vim](https://github.com/prabirshrestha/asyncomplete.vim)
|
||||
- [completion-nvim](https://github.com/nvim-lua/completion-nvim)
|
||||
- [completor.vim](https://github.com/maralla/completor.vim)
|
||||
- [deoplete.nvim](https://github.com/Shougo/deoplete.nvim)
|
||||
- [neocomplete.vim](https://github.com/Shougo/neocomplete.vim)
|
||||
- [nvim-compe](https://github.com/hrsh7th/nvim-compe)
|
||||
- [nvim-completion-manager](https://github.com/roxma/nvim-completion-manager)
|
||||
- [supertab](https://github.com/ervandew/supertab)
|
||||
- [vim-mucomplete](https://github.com/lifepillar/vim-mucomplete)
|
||||
- [VimCompletesMe](https://github.com/ajh17/VimCompletesMe)
|
||||
- [YouCompleteMe](https://github.com/Valloric/YouCompleteMe)
|
||||
|
||||
#### Cycle
|
||||
|
||||
- [switch.vim](https://github.com/AndrewRadev/switch.vim)
|
||||
- [vim-speeddating](https://github.com/tpope/vim-speeddating)
|
||||
|
||||
#### Commenters
|
||||
#### 代码注释
|
||||
|
||||
- [nerdcommenter](https://github.com/scrooloose/nerdcommenter)
|
||||
- [tcomment_vim](https://github.com/tomtom/tcomment_vim)
|
||||
- [vim-commentary](https://github.com/tpope/vim-commentary)
|
||||
|
||||
#### Delimiter
|
||||
#### 自动补全括号
|
||||
|
||||
- [auto-pairs](https://github.com/jiangmiao/auto-pairs)
|
||||
- [delimitMate](https://github.com/Raimondi/delimitMate)
|
||||
- [vim-endwise](https://github.com/tpope/vim-endwise)
|
||||
|
||||
#### Fuzzy finders
|
||||
#### 模糊搜索
|
||||
|
||||
- [leaderf](https://github.com/Yggdroot/LeaderF) (_requires +python3 or +python_)
|
||||
- [denite.nvim](https://github.com/Shougo/denite.nvim) (_requires +python3_)
|
||||
- [vim-clap](https://github.com/liuchengxu/vim-clap/)
|
||||
- [Command-T](https://github.com/wincent/Command-T) (_requires +ruby_)
|
||||
- [ctrlp.vim](https://github.com/ctrlpvim/ctrlp.vim)
|
||||
- [denite.nvim](https://github.com/Shougo/denite.nvim) (_requires +python3_)
|
||||
- [fzf](https://github.com/junegunn/fzf) (and [fzf.vim](https://github.com/junegunn/fzf.vim))
|
||||
- [unite.vim](https://github.com/Shougo/unite.vim)
|
||||
- [vim-fz](https://github.com/mattn/vim-fz)
|
||||
|
||||
#### Grep tools
|
||||
#### 文本搜索
|
||||
|
||||
- [ctrlsf.vim](https://github.com/dyng/ctrlsf.vim)
|
||||
- [ferret](https://github.com/wincent/ferret)
|
||||
- [vim-grepper](https://github.com/mhinz/vim-grepper)
|
||||
- [flygrep](https://github.com/wsdjeg/FlyGrep.vim)
|
||||
|
||||
#### Indent
|
||||
#### 代码对齐线
|
||||
|
||||
- [indentLine](https://github.com/Yggdroot/indentLine)
|
||||
- [vim-indent-guides](https://github.com/nathanaelkane/vim-indent-guides)
|
||||
@ -141,10 +146,11 @@ or [Colortemplate](https://github.com/lifepillar/vim-colortemplate).
|
||||
- [vim-sneak](https://github.com/justinmk/vim-sneak)
|
||||
- [vim-vinegar](https://github.com/tpope/vim-vinegar)
|
||||
- [vimfiler.vim](https://github.com/Shougo/vimfiler.vim) (_depends on other plugins_)
|
||||
- [defx.nvim](https://github.com/Shougo/defx.nvim) (_requires +python3_)
|
||||
|
||||
Also see [fuzzy finders](#fuzzy-finders).
|
||||
|
||||
#### Plugin managers
|
||||
#### 插件管理
|
||||
|
||||
- [apt-vim](https://github.com/egalpin/apt-vim)
|
||||
- [dein.vim](https://github.com/Shougo/dein.vim)
|
||||
@ -154,14 +160,14 @@ Also see [fuzzy finders](#fuzzy-finders).
|
||||
- [vim-plug](https://github.com/junegunn/vim-plug)
|
||||
- [vundle.vim](https://github.com/VundleVim/Vundle.vim)
|
||||
|
||||
#### Snippets
|
||||
#### 代码片段
|
||||
|
||||
- [neosnippet.vim](https://github.com/Shougo/neosnippet.vim) (_depends on other plugins_)
|
||||
- [ultisnips](https://github.com/SirVer/ultisnips)
|
||||
- [vim-snipmate](https://github.com/garbas/vim-snipmate) (_depends on other plugins_)
|
||||
- [xptemplate](https://github.com/drmingdrmer/xptemplate)
|
||||
|
||||
#### Statusline
|
||||
#### 状态栏
|
||||
|
||||
- [lightline.vim](https://github.com/itchyny/lightline.vim)
|
||||
- [powerline](https://github.com/powerline/powerline)
|
||||
@ -187,7 +193,7 @@ Also see [fuzzy finders](#fuzzy-finders).
|
||||
|
||||
- [vim-test](https://github.com/janko-m/vim-test)
|
||||
|
||||
#### Text objects
|
||||
#### 文本对象
|
||||
|
||||
- [targets.vim](https://github.com/wellle/targets.vim)
|
||||
- [vim-exchange](https://github.com/tommcdo/vim-exchange)
|
||||
@ -202,12 +208,13 @@ Also see [fuzzy finders](#fuzzy-finders).
|
||||
- [vim-tmux-navigator](https://github.com/christoomey/vim-tmux-navigator)
|
||||
- [vitality.vim](https://github.com/sjl/vitality.vim)
|
||||
|
||||
#### Undo history
|
||||
#### 编辑历史管理
|
||||
|
||||
- [vim-mundo](https://github.com/simnalamburt/vim-mundo)
|
||||
- [gundo.vim](https://github.com/sjl/gundo.vim)
|
||||
- [undotree](https://github.com/mbbill/undotree)
|
||||
|
||||
#### Version control
|
||||
#### 版本控制
|
||||
|
||||
- [agit.vim](https://github.com/cohama/agit.vim)
|
||||
- [committia.vim](https://github.com/rhysd/committia.vim)
|
||||
@ -223,6 +230,7 @@ Also see [fuzzy finders](#fuzzy-finders).
|
||||
- [vim-lawrencium](https://bitbucket.org/ludovicchabant/vim-lawrencium)
|
||||
- [vim-signify](https://github.com/mhinz/vim-signify)
|
||||
- [vimagit](https://github.com/jreybert/vimagit)
|
||||
- [git-messenger.vim](https://github.com/rhysd/git-messenger.vim/)
|
||||
|
||||
#### Writing
|
||||
|
||||
@ -258,9 +266,9 @@ Also see [fuzzy finders](#fuzzy-finders).
|
||||
- [vim-startify](https://github.com/mhinz/vim-startify)
|
||||
- [vim-unimpaired](https://github.com/tpope/vim-unimpaired)
|
||||
|
||||
## By filetype
|
||||
### 编程语言
|
||||
|
||||
#### C and C++
|
||||
#### C、C++
|
||||
|
||||
- [a.vim](https://github.com/vim-scripts/a.vim)
|
||||
- [clang_complete](https://github.com/Rip-Rip/clang_complete)
|
||||
|
257
README.md
257
README.md
@ -1,15 +1,17 @@
|
||||
# Vim 从入门到精通
|
||||
|
||||
[](https://gitter.im/vim-china/Lobby)
|
||||
[](https://t.me/VimHub)
|
||||
|
||||
> 旨在翻译 vim-galore 的基础上做了更多的补充
|
||||
|
||||
- 原文地址:<https://github.com/mhinz/vim-galore>
|
||||
- 原文作者:Marco Hinz
|
||||
- 本文地址:<https://github.com/wsdjeg/vim-galore-zh_cn>
|
||||
|
||||
**注:转载清保留以上信息**
|
||||
<div align='center'>
|
||||
<h1>Vim 从入门到精通</h1>
|
||||
<div>
|
||||
<a href='https://github.com/mhinz/vim-galore'>English</a> |
|
||||
<a href='http://postd.cc/?s=vim-galore'>Japanese</a> |
|
||||
<a href='https://github.com/lsrdg/vim-galore'>Portuguese</a> |
|
||||
<a href='http://givi.olnd.ru/vim-galore/vim-galore-ru.html'>Russian</a>
|
||||
<div>
|
||||
<br />
|
||||
<sub>Licensed under <a href='https://creativecommons.org/licenses/by-sa/4.0'>CC BY-SA 4.0<a/>.</sub>
|
||||
</div>
|
||||
</div>
|
||||
<br /><br />
|
||||
</div>
|
||||
|
||||
<!-- vim-markdown-toc GFM -->
|
||||
|
||||
@ -18,6 +20,8 @@
|
||||
- [Vim 哲学](#vim-哲学)
|
||||
- [入门](#入门)
|
||||
- [精简的 vimrc](#精简的-vimrc)
|
||||
- [Windows 系统](#windows-系统)
|
||||
- [Linux 或者 Mac OS](#linux-或者-mac-os)
|
||||
- [我正在使用什么样的 Vim](#我正在使用什么样的-vim)
|
||||
- [备忘录](#备忘录)
|
||||
- [基础](#基础)
|
||||
@ -70,17 +74,22 @@
|
||||
- [在 Vim 7 或者更早的版本中安装](#在-vim-7-或者更早的版本中安装)
|
||||
- [简短的介绍](#简短的介绍)
|
||||
- [技巧](#技巧)
|
||||
- [跳至选择的区域另一端](#跳至选择的区域另一端)
|
||||
- [聪明地使用 n 和 N](#聪明地使用-n-和-n)
|
||||
- [聪明地使用命令行历史](#聪明地使用命令行历史)
|
||||
- [智能 Ctrl-l](#智能-ctrl-l)
|
||||
- [禁用错误报警声音和图标](#禁用错误报警声音和图标)
|
||||
- [快速移动当前行](#快速移动当前行)
|
||||
- [快速添加空行](#快速添加空行)
|
||||
- [运行时检测](#运行时检测)
|
||||
- [查看启动时间](#查看启动时间)
|
||||
- [NUL 符用新行表示](#nul-符用新行表示)
|
||||
- [快速编辑自定义宏](#快速编辑自定义宏)
|
||||
- [快速跳转到源(头)文件](#快速跳转到源头文件)
|
||||
- [在 GUI 中快速改变字体大小](#在-gui-中快速改变字体大小)
|
||||
- [根据模式改变光标类型](#根据模式改变光标类型)
|
||||
- [防止水平滑动的时候失去选择](#防止水平滑动的时候失去选择)
|
||||
- [选择当前行至结尾,排除换行符](#选择当前行至结尾排除换行符)
|
||||
- [重新载入保存文件](#重新载入保存文件)
|
||||
- [更加智能的当前行高亮](#更加智能的当前行高亮)
|
||||
- [更快的关键字补全](#更快的关键字补全)
|
||||
@ -94,24 +103,20 @@
|
||||
- [调整日志等级](#调整日志等级)
|
||||
- [查看启动日志](#查看启动日志)
|
||||
- [查看运行时日志](#查看运行时日志)
|
||||
- [Vim脚本调试](#vim脚本调试)
|
||||
- [Vim 脚本调试](#vim-脚本调试)
|
||||
- [语法文件调试](#语法文件调试)
|
||||
- [杂项](#杂项)
|
||||
- [附加资源](#附加资源)
|
||||
- [Vim 配置集合](#vim-配置集合)
|
||||
- [内置插件](#内置插件)
|
||||
- [将 Control 映射到 CapsLock](#将-control-映射到-capslock)
|
||||
- [复活节彩蛋](#复活节彩蛋)
|
||||
- [为何使用 hjkl](#为何使用-hjkl)
|
||||
- [常见问题](#常见问题)
|
||||
- [编辑小文件时很慢](#编辑小文件时很慢)
|
||||
- [编辑大文件的时候很慢](#编辑大文件的时候很慢)
|
||||
- [持续粘贴(为什么我每次都要设置 'paste' 模式)](#持续粘贴为什么我每次都要设置-paste-模式)
|
||||
- [在终端中按 ESC 后有延时](#在终端中按-esc-后有延时)
|
||||
- [无法重复函数中执行的搜索](#无法重复函数中执行的搜索)
|
||||
- [插件列表](#插件列表)
|
||||
- [进阶阅读](#进阶阅读)
|
||||
- [加入我们](#加入我们)
|
||||
- [致谢:](#致谢)
|
||||
- [参考资料](#参考资料)
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
|
||||
@ -119,43 +124,50 @@
|
||||
|
||||
## 什么是 Vim?
|
||||
|
||||
[Vim](https://github.com/vim/vim) 是一个历史悠久的文本编辑器,可以追溯到 [qed](https://en.wikipedia.org/wiki/QED_(text_editor))。[Bram
|
||||
Moolenaar](https://en.wikipedia.org/wiki/Bram_Moolenaar) 于 1991 年发布初始版本。
|
||||
[Vim](https://github.com/vim/vim) 是一个历史悠久的文本编辑器,可以追溯到
|
||||
[qed](<https://en.wikipedia.org/wiki/QED_(text_editor)>)。
|
||||
[Bram Moolenaar](https://en.wikipedia.org/wiki/Bram_Moolenaar) 于
|
||||
1991 年发布初始版本。
|
||||
|
||||
Linux、Mac 用户,可以使用包管理器安装 Vim,对于 Windows 用户,可以从 [我的网盘](https://share.weiyun.com/da2be5937ac0e2bd3abc26355fad1204) 下载。
|
||||
该版本可轻易添加 `python` 、`python3` 、`lua` 等支持,只需要安装 python、lua 即可。
|
||||
|
||||
中文讨论使用相关问题最好使用 [vim_cn](https://groups.google.com/forum/#!forum/vim-cn) 邮件列表或者使用
|
||||
IRC([Freenode](https://freenode.net)) 的 `#vim-china` 频道。同时可以关注 Github 上的 vim-china 中文社区:
|
||||
https://github.com/vim-china/vim-china.github.io
|
||||
Linux、Mac 用户,可以使用包管理器安装 Vim,对于 Windows 用户,可以从
|
||||
[我的网盘](https://www.jianguoyun.com/p/DVBqom8QtY2QCBj7xL0EIAA) 下载。
|
||||
该版本可轻易添加 `python` 、`python3` 、`lua` 等支持,只需要安装 python、lua
|
||||
即可。
|
||||
|
||||
项目在 [Github](https://github.com/vim/vim) 上开发,项目讨论请订阅
|
||||
[vim_dev](https://groups.google.com/forum/#!forum/vim_dev) 邮件列表。
|
||||
[`vim_dev`](https://groups.google.com/forum/#!forum/vim_dev) 邮件列表。
|
||||
|
||||
通过阅读 [Why, oh WHY, do those #?@! nutheads use vi?](http://www.viemu.com/a-why-vi-vim.html) 来对 Vim 进行大致的了解。
|
||||
|
||||
返回主目录 [:arrow_heading_up:](#简介)
|
||||
通过阅读 [Why, oh WHY, do those #?@! nutheads use vi?](http://www.viemu.com/a-why-vi-vim.html)
|
||||
来对 Vim 进行大致的了解。
|
||||
|
||||
## Vim 哲学
|
||||
|
||||
Vim 采用模式编辑的理念,即它提供了多种模式,按键在不同的模式下作用不同。你可以在 _普通模式_ 下浏览文件,在 _插入模式_ 下插入文本,在 _可视模式_ 下选择行,在 _命令模式_ 下执行命令等等。起初这听起来可能很复杂,但是这有一个很大的优点:不需要通过同时按住多个键来完成操作,大多数时候你只需要依次按下这些按键即可。越常用的操作,所需要的按键数量越少。
|
||||
Vim 采用模式编辑的理念,即它提供了多种模式,按键在不同的模式下作用不同。
|
||||
你可以在**普通模式** 下浏览文件,在**插入模式**下插入文本,
|
||||
在**可视模式**下选择行,在**命令模式**下执行命令等等。起初这听起来可能很复杂,
|
||||
但是这有一个很大的优点:不需要通过同时按住多个键来完成操作,
|
||||
大多数时候你只需要依次按下这些按键即可。越常用的操作,所需要的按键数量越少。
|
||||
|
||||
和模式编辑紧密相连的概念是“操作符”和“动作”。_操作符_ 开始一些行为,例如:修改,删除,或者选择文本。之后你要用一个 _动作_ 来指定需要操作的文本区域。比如,要改变括号内的文本,需要执行 `ci(` (读做 _change inner parentheses_);删除整个段落的内容,需要执行 `dap` (读做:_delete
|
||||
around paragraph_)。
|
||||
和模式编辑紧密相连的概念是 **操作符** 和 **动作**。**操作符** 指的是开始某个行为,
|
||||
例如:修改、删除或者选择文本,之后你要用一个 **动作** 来指定需要操作的文本区域。
|
||||
比如,要改变括号内的文本,需要执行 `ci(` (读做 `change inner parentheses`);
|
||||
删除整个段落的内容,需要执行 `dap` (读做:`delete around paragraph`)。
|
||||
|
||||
如果你能看见 Vim 老司机操作,你会发现他们使用 Vim 脚本语言就如同钢琴师弹钢琴一样。复杂的操作只需要几个按键就能完成。他们甚至不用刻意去想,因为这已经成为[肌肉记忆](https://en.wikipedia.org/wiki/Muscle_memory)了。这减少[认识负荷](https://en.wikipedia.org/wiki/Cognitive_load)并帮助人们专注于实际任务。
|
||||
|
||||
返回主目录 [:arrow_heading_up:](#简介)
|
||||
如果你能看见 Vim 老司机操作,你会发现他们使用 Vim 脚本语言就如同钢琴师弹钢琴一样。
|
||||
复杂的操作只需要几个按键就能完成。他们甚至不用刻意去想,因为这已经成为[肌肉记忆](https://en.wikipedia.org/wiki/Muscle_memory)了。
|
||||
这减少[认识负荷](https://en.wikipedia.org/wiki/Cognitive_load)并帮助人们专注于实际任务。
|
||||
|
||||
## 入门
|
||||
|
||||
Vim 自带一个交互式的教程,内含你需要了解的最基础的信息,你可以通过终端运行以下命令打开教程:
|
||||
|
||||
```
|
||||
$ vimtutor
|
||||
```
|
||||
|
||||
不要因为这个看上去很无聊而跳过,按照此教程多练习。你以前用的 IDE 或者其他编辑器很少是有“模式”概念的,因此一开始你会很难适应模式切换。但是你 Vim 使用的越多,[肌肉记忆](https://en.wikipedia.org/wiki/Muscle_memory) 将越容易形成。
|
||||
|
||||
Vim 基于一个 [vi](https://en.wikipedia.org/wiki/Vi) 克隆,叫做 [Stevie](https://en.wikipedia.org/wiki/Stevie_(text_editor)),支持两种运行模式:"compatible" 和 "nocompatible"。在兼容模式下运行 Vim 意味着使用 vi 的默认设置,而不是 Vim 的默认设置。除非你新建一个用户的 `vimrc` 或者使用 `vim -N` 命令启动 Vim,否则就是在兼容模式下运行 Vim!请大家不要在兼容模式下运行 Vim。
|
||||
Vim 基于一个 [vi](https://en.wikipedia.org/wiki/Vi) 克隆,叫做 [Stevie](<https://en.wikipedia.org/wiki/Stevie_(text_editor)>),支持两种运行模式:"compatible" 和 "nocompatible"。在兼容模式下运行 Vim 意味着使用 vi 的默认设置,而不是 Vim 的默认设置。除非你新建一个用户的 `vimrc` 或者使用 `vim -N` 命令启动 Vim,否则就是在兼容模式下运行 Vim!请大家不要在兼容模式下运行 Vim。
|
||||
|
||||
下一步
|
||||
|
||||
@ -171,7 +183,44 @@ Vim 基于一个 [vi](https://en.wikipedia.org/wiki/Vi) 克隆,叫做 [Stevie]
|
||||
|
||||
## 精简的 vimrc
|
||||
|
||||
用户的 vimrc 配置文件可以放在 `~/.vimrc`,或者为了更好的分离放在 `~/.vim/vimrc`,后者更便于通过版本控制软件备份和同步整个配置,比方说 Github。
|
||||
Vim 启动是会按照一定的优先顺序来搜索配置文件,这个顺序,可以通过 `:version` 命令查看。下面分 Windows 系统,
|
||||
和 \*niux 系统分别来说明 Vim 是如何载入配置文件的。
|
||||
|
||||
### Windows 系统
|
||||
|
||||
```
|
||||
system vimrc file: "$VIM\vimrc"
|
||||
user vimrc file: "$HOME\_vimrc"
|
||||
2nd user vimrc file: "$HOME\vimfiles\vimrc"
|
||||
3rd user vimrc file: "$VIM\_vimrc"
|
||||
user exrc file: "$HOME\_exrc"
|
||||
2nd user exrc file: "$VIM\_exrc"
|
||||
system gvimrc file: "$VIM\gvimrc"
|
||||
user gvimrc file: "$HOME\_gvimrc"
|
||||
2nd user gvimrc file: "$HOME\vimfiles\gvimrc"
|
||||
3rd user gvimrc file: "$VIM\_gvimrc"
|
||||
defaults file: "$VIMRUNTIME\defaults.vim"
|
||||
system menu file: "$VIMRUNTIME\menu.vim"
|
||||
```
|
||||
|
||||
我们只看上面这一段,Vim 会优先读取 user vimrc file: `$HOME\_vimrc`, 当这一文件不存在是,
|
||||
Vim 再去寻找 2nd user vimrc file: `$HOME\vimfiles\vimrc`; 倘若这个文件还是不存在,那么 Vim
|
||||
会去继续寻找 3rd user vimrc file: `$VIM\_vimrc`。 了解以上顺序后,就不会再因为 Vim
|
||||
总是不读取配置文件而感到烦恼了。
|
||||
|
||||
### Linux 或者 Mac OS
|
||||
|
||||
同 Windows 系统类似,也可以使用 `:version` 命令查看 vim 载入配置的优先顺序。
|
||||
|
||||
```
|
||||
系统 vimrc 文件: "/etc/vimrc"
|
||||
用户 vimrc 文件: "$HOME/.vimrc"
|
||||
第二用户 vimrc 文件: "~/.vim/vimrc"
|
||||
用户 exrc 文件: "$HOME/.exrc"
|
||||
defaults file: "$VIMRUNTIME/defaults.vim"
|
||||
$VIM 预设值: "/etc"
|
||||
$VIMRUNTIME 预设值: "/usr/share/vim/vim81"
|
||||
```
|
||||
|
||||
你可以在网上找到许多精简的 vimrc 配置文件,我的版本可能并不是最简单的版本,但是我的版本提供了一套我认为良好的,非常适合入门的设置。
|
||||
|
||||
@ -179,7 +228,7 @@ Vim 基于一个 [vi](https://en.wikipedia.org/wiki/Vi) 克隆,叫做 [Stevie]
|
||||
|
||||
精简的 vimrc 地址:[minimal-vimrc](contents/minimal-vimrc.vim)
|
||||
|
||||
如果你有兴趣,这里是我(原作者)的 [vimrc](https://github.com/mhinz/dotfiles/blob/master/vim/vimrc)。
|
||||
如果你有兴趣,这里是我(原作者)的 [vimrc](https://github.com/mhinz/dotfiles/blob/master/.vim/vimrc)。
|
||||
|
||||
**建议**:大多数插件作者都维护不止一个插件并且将他们的 vimrc 放在 Github 上展示(通常放在叫做 "vim-config" 或者 "dotfiles" 的仓库中),所以当你发现你喜欢的插件时,去插件维护者的 Github 主页看看有没有这样的仓库。
|
||||
|
||||
@ -210,10 +259,12 @@ endif
|
||||
|
||||
相关帮助:
|
||||
|
||||
```
|
||||
:h :version
|
||||
:h feature-list
|
||||
:h +feature-list
|
||||
:h has-patch
|
||||
```
|
||||
|
||||
返回主目录 [:arrow_heading_up:](#简介)
|
||||
|
||||
@ -223,7 +274,6 @@ endif
|
||||
|
||||
- <http://people.csail.mit.edu/vgod/vim/vim-cheat-sheet-en.png>
|
||||
- <https://cdn.shopify.com/s/files/1/0165/4168/files/preview.png>
|
||||
- <http://www.nathael.org/Data/vi-vim-cheat-sheet.svg>
|
||||
- <http://michael.peopleofhonoronly.com/vim/vim_cheat_sheet_for_programmers_screen.png>
|
||||
- <http://www.rosipov.com/images/posts/vim-movement-commands-cheatsheet.png>
|
||||
|
||||
@ -291,10 +341,10 @@ Vim 是一个文本编辑器。每次文本都是作为**缓冲区**的一部分
|
||||
|
||||
## 按键映射
|
||||
|
||||
使用 `:map` 命令家族你可以定义属于你自己的快捷键。该家族的每一个命令都限定在特定的模式下。从技术上来说 Vim 自带高达 12 中模式,其中 6 种可以被映射。另外一些命令作用于多种模式:
|
||||
使用 `:map` 命令家族你可以定义属于你自己的快捷键。该家族的每一个命令都限定在特定的模式下。从技术上来说 Vim 自带高达 12 种模式,其中 6 种可以被映射。另外一些命令作用于多种模式:
|
||||
|
||||
| 递归 | 非递归 | 模式 |
|
||||
| --------- | ------------ | -------------------------------- |
|
||||
| -------- | ------------ | -------------------------------- |
|
||||
| `:map` | `:noremap` | normal, visual, operator-pending |
|
||||
| `:nmap` | `:nnoremap` | normal |
|
||||
| `:xmap` | `:xnoremap` | visual |
|
||||
@ -334,7 +384,7 @@ Vim 是一个文本编辑器。每次文本都是作为**缓冲区**的一部分
|
||||
:nnoremap a b
|
||||
```
|
||||
|
||||
经验法则:除非递归是必须的,否则总是使用非递归映射。
|
||||
经验法则:除递归映射是必须的,否则总是使用非递归映射。
|
||||
|
||||
通过不给一个右值来检查你的映射。比如`:nmap` 显示所以普通模式下的映射,`:nmap <leader>` 显示所有以 `<leader>` 键开头的普通模式下的映射。
|
||||
|
||||
@ -358,13 +408,15 @@ Vim 是一个文本编辑器。每次文本都是作为**缓冲区**的一部分
|
||||
nnoremap <leader>h :helpgrep<space>
|
||||
```
|
||||
|
||||
这样,我们只需要先按 <kbd>\\</kbd> 然后连续按 <kbd>\\h</kbd> 就可以激活这个映射 `:helpgrep<space>`。如果你想通过先按 <kbd>空格</kbd> 键来触发,只需要这样做:
|
||||
这样,我们只需要先按 <kbd>\\</kbd> 然后按 <kbd>h</kbd> 就可以激活这个映射 `:helpgrep<space>`。如果你想通过先按 <kbd>空格</kbd> 键来触发,只需要这样做:
|
||||
|
||||
```vim
|
||||
let mapleader = ' '
|
||||
let g:mapleader = ' '
|
||||
nnoremap <leader>h :helpgrep<space>
|
||||
```
|
||||
|
||||
此处建议使用 `g:mapleader`,因为在 Vim 脚本中,函数外的变量缺省的作用域是全局变量,但是在函数内缺省作用域是局部变量,而设置快捷键前缀需要修改全局变量 `g:mapleader` 的值。
|
||||
|
||||
另外,还有一个叫 `<localleader>` 的,可以把它理解为局部环境中的 `<leader>`,默认值依然为 <kbd>\\</kbd>。当我们需要只对某一个条件下(比如,特定文件类型的插件)的缓冲区设置特别的 `<leader>` 键,那么我们就可以通过修改当前环境下的 `<localleader>` 来实现。
|
||||
|
||||
**注意**:如果你打算设置 Leader 键,请确保在设置按键映射之前,先设置好 Leader 键。如果你先设置了含有 Leader 键的映射,然后又修改了 Leader 键,那么之前映射内的 Leader 键是不会因此而改变的。你可以通过执行 `:nmap <leader>` 来查看普通模式中已绑定给 Leader 键的所有映射。
|
||||
@ -380,9 +432,9 @@ nnoremap <leader>h :helpgrep<space>
|
||||
Vim 为我们提供了如下的寄存器:
|
||||
|
||||
| 类型 | 标识 | 读写者 | 是否为只读 | 包含的字符来源 |
|
||||
| ------------------- | ------------------ | ------ | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| ------------------- | ------------------ | ------ | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Unnamed | `"` | vim | 否 | 最近一次的复制或删除操作 (`d`, `c`, `s`, `x`, `y`) |
|
||||
| Numbered | `0`至`9` | vim | 否 | 寄存器 `0`: 最近一次复制。寄存器 `1`: 最近一次删除。寄存器 `2`: 倒数第二次删除,以此类推。对于寄存器 `1` 至 `9`,他们其实是只读的最多包含 9 个元素的队列。这里的队列即为数据类型 [queue](https://en.wikipedia.org/wiki/Queue_(abstract_data_type)) |
|
||||
| Numbered | `0`至`9` | vim | 否 | 寄存器 `0`: 最近一次复制。寄存器 `1`: 最近一次删除。寄存器 `2`: 倒数第二次删除,以此类推。对于寄存器 `1` 至 `9`,他们其实是只读的最多包含 9 个元素的队列。这里的队列即为数据类型 [queue](<https://en.wikipedia.org/wiki/Queue_(abstract_data_type)>) |
|
||||
| Small delete | `-` | vim | 否 | 最近一次行内删除 |
|
||||
| Named | `a`至`z`, `A`至`Z` | 用户 | 否 | 如果你通过复制操作存储文本至寄存器 `a`,那么 `a` 中的文本就会被完全覆盖。如果你存储至 `A`,那么会将文本添加给寄存器 `a`,不会覆盖之前已有的文本 |
|
||||
| Read-only | `:`与`.`和`%` | vim | 是 | `:`: 最近一次使用的命令,`.`: 最近一次添加的文本,`%`: 当前的文件名 |
|
||||
@ -485,14 +537,14 @@ Vim 为我们提供了如下的寄存器:
|
||||
|
||||
如果想跳转到指定的标注,你可以先按下 `'` / `g'` 或者 `` ` `` / `` g` `` 然后按下标注名。
|
||||
|
||||
如果你想定义当前文件中的标注,可以先按下 `m` 再按下标注名。比如,按下 `mm` 就可以把当前位置标注为 `m`。在这之后,如果你的光标切换到了文件的其他位置,只需要通过 `'m` 或者 `\`m`即可回到刚才标注的行。区别在于,`'m`会跳转回被标记行的第一个非空字符,而`\`m`会跳转回被标记行的被标记列。根据 viminfo 的设置,你可以在退出 Vim 的时候保留小写字符标注。请参阅`:h viminfo-'\` 来获取更多帮助。
|
||||
如果你想定义当前文件中的标注,可以先按下 `m` 再按下标注名。比如,按下 `mm` 就可以把当前位置标注为 `m`。在这之后,如果你的光标切换到了文件的其他位置,只需要通过 `'m` 或者 `` `m ``即可回到刚才标注的行。区别在于,`'m`会跳转回被标记行的第一个非空字符,而`` `m ``会跳转回被标记行的被标记列。根据 viminfo 的设置,你可以在退出 Vim 的时候保留小写字符标注。请参阅`:h viminfo-'` 来获取更多帮助。
|
||||
|
||||
如果你想定义全局的标注,可以先按下 `m` 再按下大写英文字符。比如,按下 `mM` 就可以把当前文件的当前位置标注为 `M`。在这之后,就算你切换到其他的缓冲区,依然可以通过 `'M` 或 `\`M\` 跳转回来。
|
||||
如果你想定义全局的标注,可以先按下 `m` 再按下大写英文字符。比如,按下 `mM` 就可以把当前文件的当前位置标注为 `M`。在这之后,就算你切换到其他的缓冲区,依然可以通过 `'M` 或 `` `M `` 跳转回来。
|
||||
|
||||
关于跳转,还有以下的方式:
|
||||
|
||||
| 按键 | 跳转至 |
|
||||
| --------------- | ---------------------------------------------- |
|
||||
| ---------------- | ---------------------------------------------- |
|
||||
| `'[` 与 `` `[ `` | 上一次修改或复制的第一行或第一个字符 |
|
||||
| `']` 与 `` `] `` | 上一次修改或复制的最后一行或最后一个字符 |
|
||||
| `'<` 与 `` `< `` | 上一次在可视模式下选取的第一行或第一个字符 |
|
||||
@ -557,7 +609,7 @@ Vim 在插入模式中为我们提供了多种补全方案。如果有多个补
|
||||
|
||||
以下会列出一些常用的动作。你也可以通过 `:h navigation` 来获取更多的帮助。
|
||||
|
||||
**操作符**是对某个区域文本执行的操作。比如,`d`、`~`、`gU` 和 `>` 都是操作符。这些操作符既可以在普通模式下使用,也可以在可视模式下使用。在普通模式中,顺序是先按操作符,再按动作指令,比如 `>j`。在可是模式中,选中区域后直接按操作符就可以,比如 `Vjd`。
|
||||
**操作符**是对某个区域文本执行的操作。比如,`d`、`~`、`gU` 和 `>` 都是操作符。这些操作符既可以在普通模式下使用,也可以在可视模式下使用。在普通模式中,顺序是先按操作符,再按动作指令,比如 `>j`。在可视模式中,选中区域后直接按操作符就可以,比如 `Vjd`。
|
||||
|
||||
与动作一样,操作符也可以搭配数字使用,比如 `2gUw` 可以将当前单词以及下一个单词转成大写。由于动作和操作符都可以搭配数字使用,因此 `2gU2w` 与执行两次 `gU2w` 效果是相同的。
|
||||
|
||||
@ -641,7 +693,7 @@ Vim 中的跳转命令,包括 `'`、`` ` ``、`G`、`/`、`?`、`n`、`N`、`%
|
||||
|
||||
Vim 会记录文本改变之前的状态。因此,你可以使用「撤销」操作 <kbd>u</kbd> 来取消更改,也可以通过「重做」操作 <kbd>Ctrl + r</kbd> 来恢复更改。
|
||||
|
||||
值得注意的是,Vim 采用 [tree](https://en.wikipedia.org/wiki/Tree_(data_structure)) 数据结构来存储内容变更的历史记录,而不是采用 [queue](https://en.wikipedia.org/wiki/Queue_(abstract_data_type))。你的每次改动都会成为存储为树的节点。而且,除了第一次改动(根节点),之后的每次改动都可以找到一个对应的父节点。每一个节点都会记录改动的内容和时间。其中,「分支」代表从任一节点到根节点的路径。当你进行了撤销操作,然后又输入了新的内容,这时候就相当于创建了分支。这个原理和 git 中的 branch(分支)十分类似。
|
||||
值得注意的是,Vim 采用 [tree](<https://en.wikipedia.org/wiki/Tree_(data_structure)>) 数据结构来存储内容变更的历史记录,而不是采用 [queue](<https://en.wikipedia.org/wiki/Queue_(abstract_data_type)>)。你的每次改动都会成为存储为树的节点。而且,除了第一次改动(根节点),之后的每次改动都可以找到一个对应的父节点。每一个节点都会记录改动的内容和时间。其中,「分支」代表从任一节点到根节点的路径。当你进行了撤销操作,然后又输入了新的内容,这时候就相当于创建了分支。这个原理和 git 中的 branch(分支)十分类似。
|
||||
|
||||
考虑以下这一系列按键操作:
|
||||
|
||||
@ -902,7 +954,7 @@ Vim 自带了一套很完善的帮助文档,它们是一个个有固定排版
|
||||
|
||||
经过一些微小的改动后,重新发布到了这里。
|
||||
|
||||
* * *
|
||||
---
|
||||
|
||||
如果你知道你想要找什么,使用帮助系统的搜索会更简单一些,因为搜索出的主题都带有固定的格式。
|
||||
|
||||
@ -1034,7 +1086,7 @@ autocmd VimEnter * nested edit $MYVIMRC
|
||||
|
||||
### 剪贴板的使用(Windows, OSX)
|
||||
|
||||
Windows 自带了[剪贴板](https://msdn.microsoft.com/en-us/library/windows/desktop/ms649012(v=vs.85).aspx),OSX 则带了一个[粘贴板](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/PasteboardGuide106/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008100-SW1)
|
||||
Windows 自带了[剪贴板](<https://msdn.microsoft.com/en-us/library/windows/desktop/ms649012(v=vs.85).aspx>),OSX 则带了一个[粘贴板](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/PasteboardGuide106/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008100-SW1)
|
||||
|
||||
在这两个系统中都可以用大家习惯用的 `ctrl+c / cmd+c` 复制选择的文本,然后在另外一个应用中用 `ctrl+v / cmd+v` 进行粘贴。
|
||||
|
||||
@ -1273,7 +1325,7 @@ set virtualedit=all
|
||||
|
||||
使用 `:!` 启动一个新任务。如果你想列出当前工作目录下的所有文件,可以使用 `:!ls`。 用 `|` 来将结果通过管道重定向,如:`:!ls -l | sort | tail -n5`。
|
||||
|
||||
没有使用范围时(译者注:范围就是 `:` 和 `!` 之间的内容,`.` 表示当前行,`+4` 表示向下偏移4行,`$` 表示最末行等,多行时用 `,` 将它们分开,如 `.,$` 表示从当前行到末行),`:!` 会显示在一个可滚动的窗口中(译者注:在 GVim 和在终端里运行的结果稍有不同)。相反的,如果指定了范围,这些行会被[过滤](https://en.wikipedia.org/wiki/Filter_(software))。这意味着它们会通过管道被重定向到过滤程序的 [stdin](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_.28stdin.29),在处理后再通过过滤程序的 [stdout](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_.28stdout.29) 输出,用输出结果替换范围内的文本。例如:为接下来的5行文本添加行号,可以使用:
|
||||
没有使用范围时(译者注:范围就是 `:` 和 `!` 之间的内容,`.` 表示当前行,`+4` 表示向下偏移 4 行,`$` 表示最末行等,多行时用 `,` 将它们分开,如 `.,$` 表示从当前行到末行),`:!` 会显示在一个可滚动的窗口中(译者注:在 GVim 和在终端里运行的结果稍有不同)。相反的,如果指定了范围,这些行会被[过滤](<https://en.wikipedia.org/wiki/Filter_(software)>)。这意味着它们会通过管道被重定向到过滤程序的 [stdin](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_.28stdin.29),在处理后再通过过滤程序的 [stdout](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_.28stdout.29) 输出,用输出结果替换范围内的文本。例如:为接下来的 5 行文本添加行号,可以使用:
|
||||
|
||||
```vim
|
||||
:.,+4!nl -ba -w1 -s' '
|
||||
@ -1428,6 +1480,15 @@ autocmd FileType python let b:match_words = '\<if\>:\<elif\>:\<else\>'
|
||||
|
||||
# 技巧
|
||||
|
||||
## 跳至选择的区域另一端
|
||||
|
||||
在使用 `v` 或者 `V` 选择某段文字后,可以用 `o` 或者 `O` 按键跳至选择区域的开头或者结尾。
|
||||
|
||||
```
|
||||
:h v_o
|
||||
:h v_O
|
||||
```
|
||||
|
||||
## 聪明地使用 n 和 N
|
||||
|
||||
<kbd>n</kbd> 与 <kbd>N</kbd> 的实际跳转方向取决于使用 `/` 还是 `?` 来执行搜索,其中 `/` 是向后搜索,`?` 是向前搜索。一开始我(原作者)觉得这里很难理解。
|
||||
@ -1492,6 +1553,47 @@ nnoremap ]<space> :<c-u>put =repeat(nr2char(10), v:count1)<cr>
|
||||
|
||||
设置之后,连续按下 <kbd>5</kbd> <kbd>\[</kbd> <kbd>空格</kbd> 在当前行上方插入 5 个空行。
|
||||
|
||||
### 运行时检测
|
||||
|
||||
需要的特性:+profile
|
||||
|
||||
Vim 提供了一个内置的运行时检查功能,能够找出运行慢的代码。
|
||||
|
||||
`:profile` 命令后面跟着子命令来确定要查看什么。
|
||||
|
||||
如果你想查看所有的:
|
||||
|
||||
```Vim
|
||||
:profile start /tmp/profile.log
|
||||
:profile file *
|
||||
:profile func *
|
||||
<do something in Vim>
|
||||
<quit Vim>
|
||||
```
|
||||
|
||||
Vim 不断地在内存中检查信息,只在退出的时候输出出来。(Neovim 已经解决了这个问题用 `:profile dump` 命令)
|
||||
|
||||
看一下 `/tmp/profile.log` 文件,检查时运行的所有代码都会被显示出来,包括每一行代码运行的频率和时间。
|
||||
|
||||
大多数代码都是用户不熟悉的插件代码,如果你是在解决一个确切的问题,
|
||||
直接跳到这个日志文件的末尾,那里有 `FUNCTIONS SORTED ON TOTAL TIME` 和 `FUNCTIONS SORTED ON SELF TIME` 两个部分,如果某个 function 运行时间过长一眼就可以看到。
|
||||
|
||||
### 查看启动时间
|
||||
|
||||
感觉 Vim 启动的慢?到了研究几个数字的时候了:
|
||||
|
||||
```vim
|
||||
vim --startuptime /tmp/startup.log +q && vim /tmp/startup.log
|
||||
```
|
||||
|
||||
第一栏是最重要的因为它显示了**绝对运行时间**,如果在前后两行之间时间差有很大的跳跃,那么是第二个文件太大或者含有需要检查的错误的 VimL 代码。
|
||||
|
||||
## NUL 符用新行表示
|
||||
|
||||
文件中的 NUL 符 (`\0`),在内存中被以新行(`\n`)保存,在缓存空间中显示为 `^@`。
|
||||
|
||||
更多信息请参看 `man 7 ascii` 和 `:h NL-used-for-Nul` 。
|
||||
|
||||
## 快速编辑自定义宏
|
||||
|
||||
这个功能真的很实用!下面的映射,就是在一个新的命令行窗口中读取某一个寄存器(默认为 `*`)。当你设置完成后,只需要按下 <kbd>回车</kbd> 即可让它生效。
|
||||
@ -1561,6 +1663,18 @@ xnoremap > >gv
|
||||
|
||||
设置好之后,在可视模式中使用 `>>>>>` 就不会再出现上面提到的问题了。
|
||||
|
||||
## 选择当前行至结尾,排除换行符
|
||||
|
||||
在 Vim 里,我们可以同过 `v$` 选择当前行至结尾,但此时会把最后一个换行符也选中,通常需要按额外的 `h` 来取消最后选中最后一个换行符号。
|
||||
Vim 提供了一个 `g_` 快捷键,可以移动光标至最后一个非空字符。因此,为达到次效果,可以使用 `vg_`。当然,如果觉得按三个键比较麻烦,
|
||||
可以添加一个映射:
|
||||
|
||||
```vim
|
||||
nnoremap L g_
|
||||
```
|
||||
|
||||
这样就可以通过 `vL` 达到一样的效果了。
|
||||
|
||||
## 重新载入保存文件
|
||||
|
||||
通过[自动命令](#自动命令),你可以在保存文件的同时触发一些其他功能。比如,如果这个文件是一个配置文件,那么就重新载入;或者你还可以对这个文件进行代码风格检查。
|
||||
@ -1772,7 +1886,6 @@ Vim现在正在使用的另一个比较有用的方法是增加debug信息输出
|
||||
|
||||
`:debug`命令可以和[verbose](#verbosity)选项一起使用。
|
||||
|
||||
|
||||
## 语法文件调试
|
||||
|
||||
语法文件由于包含错误的或者复制的正则表达式,常常会使得 Vim 的运行较慢。如果 Vim 在编译的时候包含了`+profile` [feature](#what-kind-of-vim-am-i-running)特性,就可以给用户提供一个超级好用的`:syntime`命令。
|
||||
@ -1783,12 +1896,11 @@ Vim现在正在使用的另一个比较有用的方法是增加debug信息输出
|
||||
:syntime off
|
||||
:syntime report
|
||||
```
|
||||
|
||||
输出结果包含了很多的度量维度。比如,你可以通过结果知道哪些正则表达式耗时太久需要被优化;哪些正则表达式一直在别使用但重来没有一次成功匹配。
|
||||
|
||||
请查阅`:h :syntime`。
|
||||
|
||||
|
||||
|
||||
# 杂项
|
||||
|
||||
## 附加资源
|
||||
@ -1806,13 +1918,13 @@ Vim现在正在使用的另一个比较有用的方法是增加debug信息输出
|
||||
|
||||
## Vim 配置集合
|
||||
|
||||
## 内置插件
|
||||
目前,网上有很多流行 Vim 配置集合,对于 Vim 配置集合,个人认为有利有弊。
|
||||
对于维护的比较好的配置,比如 [SpaceVim](http://spacevim.org/cn/) 还是值得尝试的,可以节省很多自行配置的时间。
|
||||
当然,网上还有很多其他很流行的配置,比如:
|
||||
|
||||
## 将 Control 映射到 CapsLock
|
||||
|
||||
## 复活节彩蛋
|
||||
|
||||
## 为何使用 hjkl
|
||||
- [k-vim](https://github.com/wklken/k-vim)
|
||||
- [amix's vimrc](https://github.com/amix/vimrc)
|
||||
- [janus](https://github.com/carlhuda/janus)
|
||||
|
||||
## 常见问题
|
||||
|
||||
@ -1861,7 +1973,10 @@ $ vim -n -u NONE -i NONE -N
|
||||
|
||||
你有没有遇到过往 Vim 里粘贴代码之后被搞的一团糟?
|
||||
|
||||
这在你使用 `cmd+v`、`shirt-insert`、`middle-click` 等进行粘贴的时候才会发生。因为那样的话你只是向终端模拟器扔了一大堆的文本。 Vim 并不知道你刚刚是粘贴的文本,它以为你在飞速的输入。于是它想缩进这些行但是失败了。
|
||||
这在你使用 `cmd+v`、`shirt-insert`、`middle-click` 等进行粘贴的时候才会发生。
|
||||
因为那样的话你只是向终端模拟器扔了一大堆的文本。
|
||||
Vim 并不知道你刚刚是粘贴的文本,它以为你在飞速的输入。
|
||||
于是它想缩进这些行但是失败了。
|
||||
|
||||
这明显不是个问题,如果你用 Vim 的寄存器粘贴,如:`"+p` ,这时 Vim 就知道了你在粘贴,就不会导致格式错乱了。
|
||||
|
||||
@ -1922,13 +2037,15 @@ set ttimeoutlen=10 " unnoticeable small value
|
||||
|
||||
帮助文档:`:h function-search-undo`。
|
||||
|
||||
## [插件列表](PLUGINS.md)
|
||||
## 进阶阅读
|
||||
|
||||
- [Vim 插件开发指南](https://github.com/wsdjeg/vim-plugin-dev-guide)
|
||||
- [常用插件列表](PLUGINS.md)
|
||||
|
||||
## 加入我们
|
||||
|
||||
可以协助我们核对翻译,或者从[章节列表](CONTRIBUTING.md)中认领章节进行翻译。
|
||||
|
||||
## 致谢:
|
||||
## 参考资料
|
||||
|
||||
- [Linux 中国翻译组](https://github.com/LCTT)
|
||||
- [掘金翻译计划](https://github.com/xitu/gold-miner)
|
||||
- [Nifty Little Nvim Techniques to Make My Life Easier -- Series 1](https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/)
|
||||
|
@ -1,7 +0,0 @@
|
||||
## Debugging
|
||||
- 常用技巧
|
||||
- 复杂度
|
||||
- 查看启动时间
|
||||
- 运行时检测
|
||||
- 检查Vim脚本
|
||||
- 检查语法文件
|
@ -1,6 +0,0 @@
|
||||
## 新行用于NUL
|
||||
|
||||
一个文件中的NUL字符(`\0`),是以换行符(`\n`)在内存中被存储的同时在显示的时候以`^@`呈现。
|
||||
|
||||
查阅`man 7 ascii`和`:h NL-used-for-Nul`获取更多相关信息。
|
||||
|
@ -1,23 +0,0 @@
|
||||
### 运行时检测
|
||||
|
||||
需要的特性:+profile
|
||||
|
||||
Vim 提供了一个内置的运行时检查功能,能够找出运行慢的代码。
|
||||
|
||||
```:profile``` 命令后面跟着子命令来确定要查看什么。
|
||||
|
||||
如果你想查看所有的:
|
||||
|
||||
```Vim
|
||||
:profile start /tmp/profile.log
|
||||
:profile file *
|
||||
:profile func *
|
||||
<do something in Vim>
|
||||
<quit Vim>
|
||||
```
|
||||
|
||||
Vim 不断地在内存中检查信息,只在退出的时候输出出来。(Neovim 已经解决了这个问题用 ```:profile dump``` 命令)
|
||||
|
||||
看一下 ```/tmp/profile.log``` 文件,检查时运行的所有代码都会被显示出来,包括每一行代码运行的频率和时间。
|
||||
|
||||
大多数代码都是用户不熟悉的插件代码,如果你是在解决一个确切的问题,直接跳到这个日志文件的末尾,那里有 ```FUNCTIONS SORTED ON TOTAL TIME``` 和 ```FUNCTIONS SORTED ON SELF TIME``` 两个部分,如果某个function运行时间过长一眼就可以看到。
|
@ -1,10 +0,0 @@
|
||||
### 查看启动时间
|
||||
|
||||
感觉Vim启动的慢?到了研究几个数字的时候了:
|
||||
|
||||
```vim
|
||||
vim --startuptime /tmp/startup.log +q && vim /tmp/startup.log
|
||||
```
|
||||
|
||||
第一栏是最重要的因为它显示了**绝对运行时间**,如果在前后两行之间时间差有很大的跳跃,那么是第二个文件太大或者含有需要检查的错误的VimL代码。
|
||||
|
@ -1,3 +1,8 @@
|
||||
# 技术怪癖
|
||||
|
||||
## NUL 符用新行表示
|
||||
|
||||
文件中的 NUL 符 (`\0`) 在内存中会被存储为换行符 (`\n`) 且
|
||||
在缓冲区中显示为 `^@`.
|
||||
|
||||
在 `man 7 ascii` 和 `:h NL-used-for-Nul` 中查看更多信息。
|
||||
|
@ -1,18 +1,18 @@
|
||||
## 粘贴归类 (要不为什么我总要设置‘粘贴’?)
|
||||
## 粘贴归类 (要不为什么我总要设置‘粘贴’?)
|
||||
|
||||
粘贴归类模式使得终端虚拟器可以区分键入文本和粘贴文本。
|
||||
粘贴归类模式使得终端虚拟器可以区分键入文本和粘贴文本。
|
||||
|
||||
你是否曾经尝试过向 Vim 粘贴过代码,结果弄得一团糟?
|
||||
你是否曾经尝试过向 Vim 粘贴过代码,结果弄得一团糟?
|
||||
|
||||
这只会在你通过 `cmd+v`, `shift-insert`, `middle-click` 等等命令进行粘贴时发生。
|
||||
因为那时你只是在向终端虚拟器里丢文本。Vim 并不知道你在粘贴文本,它天真地认为你是一个熟练的打字员。因此,它尝试排版,但是失败了。
|
||||
这只会在你通过 `cmd+v`, `shift-insert`, `middle-click` 等等命令进行粘贴时发生。
|
||||
因为那时你只是在向终端虚拟器里丢文本。Vim 并不知道你在粘贴文本,它天真地认为你是一个熟练的打字员。因此,它尝试排版,但是失败了。
|
||||
|
||||
如果你使用 Vim 命令集里的粘贴,比如 `"+p` ,那这就不会成为问题,因为 Vim 知道你做的是粘贴操作。
|
||||
如果你使用 Vim 命令集里的粘贴,比如 `"+p` ,那这就不会成为问题,因为 Vim 知道你做的是粘贴操作。
|
||||
|
||||
为了解决这个,你需要设置粘贴 `:set paste` ,以便获取粘贴现状。 参考 `:h 'paste'` 和 `:h 'pastetoggle'`.
|
||||
为了解决这个,你需要设置粘贴 `:set paste` ,以便获取粘贴现状。 参考 `:h 'paste'` 和 `:h 'pastetoggle'`.
|
||||
|
||||
如果你已经受够了不停地切换 `'paste'` ,看一看这个不错的插件能为你做什么:[粘贴归类](https://github.com/ConradIrwin/vim-bracketed-paste)。
|
||||
如果你已经受够了不停地切换 `'paste'` ,看一看这个不错的插件能为你做什么:[粘贴归类](https://github.com/ConradIrwin/vim-bracketed-paste)。
|
||||
|
||||
插件作者的拓展阅读:[欢迎点击](http://cirw.in/blog/bracketed-paste).
|
||||
插件作者的拓展阅读:[欢迎点击](http://cirw.in/blog/bracketed-paste).
|
||||
|
||||
**Neovim**: Neovim 努力无缝地完成这些工作,并在终端虚拟器支持时自动设定粘贴归类模式。
|
||||
**Neovim**: Neovim 努力无缝地完成这些工作,并在终端虚拟器支持时自动设定粘贴归类模式。
|
||||
|
@ -1,44 +0,0 @@
|
||||
## 使用终端中 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'<cr>
|
||||
:nnoremap ,ab :echo 'bar'<cr>
|
||||
```
|
||||
|
||||
两个映射都有可能,键入 `,a` ,就会有一秒钟的延迟,因为 Vim 会等待用户会再键入 `b` 还是不会了。
|
||||
|
||||
退出序列也会引起一样的问题:
|
||||
|
||||
- `<esc>` 在返回正常模式或退出指令时被大量使用。
|
||||
- 光标键使用了退出序列进行编码
|
||||
- Vim 运用 <kbd>Alt</kbd> (也被称为 _Meta key_)去发送固定的高位集编码的8位比特,但是很多终端虚拟器不支持(或者默认不启用),而用退出序列代替。
|
||||
|
||||
你可以用 `vim -u NONE -N` 试一试上面所说的,然后键入 `i<c-v><left>` ,你就会看见一串以 `^[`(表征退出码)开头的被输入序列。
|
||||
|
||||
简而言之,区分键入的 `<esc>` 和一个严格意义上的退出序列对 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
|
||||
```
|
@ -1,13 +0,0 @@
|
||||
## 复活节彩蛋
|
||||
|
||||
| 命令 | 消息 |
|
||||
|-----------|---------|
|
||||
| `: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.` |
|
@ -1,20 +1,20 @@
|
||||
## 编辑大文件很慢
|
||||
## 编辑大文件很慢
|
||||
|
||||
大文件最大的问题,就是 Vim 会一次性读取整个文件。这一过程的完成取决于内部如何提供缓存空间。
|
||||
([Vim 开发的讨论](https://groups.google.com/forum/#!topic/vim_dev/oY3i8rqYGD4/discussion))
|
||||
大文件最大的问题,就是 Vim 会一次性读取整个文件。这一过程的完成取决于内部如何提供缓存空间。
|
||||
([Vim 开发的讨论](https://groups.google.com/forum/#!topic/vim_dev/oY3i8rqYGD4/discussion))
|
||||
|
||||
如果你只是想读取, `tail hugefile | vim -` 会是一个很好的解决方法.
|
||||
如果你只是想读取, `tail hugefile | vim -` 会是一个很好的解决方法.
|
||||
|
||||
如果不用语法,设定和插件,你也能生活自理一段时间:
|
||||
如果不用语法,设定和插件,你也能生活自理一段时间:
|
||||
|
||||
```
|
||||
$ vim -u NONE -N
|
||||
```
|
||||
|
||||
这将使得导航明显提速,因为代价高昂的语法高亮正则表达式不再被使用。你也应该让 Vim 不要使用交换文件和 Vim 信息文件,以避免写入时的长延迟。
|
||||
这将使得导航明显提速,因为代价高昂的语法高亮正则表达式不再被使用。你也应该让 Vim 不要使用交换文件和 Vim 信息文件,以避免写入时的长延迟。
|
||||
|
||||
```
|
||||
$ vim -n -u NONE -i NONE -N
|
||||
```
|
||||
|
||||
简而言之,真的写入超大文件的时候尽量别用 Vim。 :\
|
||||
简而言之,真的写入超大文件的时候尽量别用 Vim。 :\
|
||||
|
@ -1,8 +1,8 @@
|
||||
## 无法重复函数中执行的搜索
|
||||
## 无法重复函数中执行的搜索
|
||||
|
||||
- 一个命令的搜索关键词(`/`, `:代替`, ...)改变了“上一次搜索所用的关键词”。(这个改变保存在 `/` 的注册表里;使用 `:echo @/` 可以打印出来)
|
||||
- 一个简单的文本修改可以用 `.` 再次执行。(这个执行保存在 `.` 的注册表里;使用 `:echo @.` 可以打印出来)
|
||||
- 一个命令的搜索关键词(`/`, `:代替`, ...)改变了“上一次搜索所用的关键词”。(这个改变保存在 `/` 的注册表里;使用 `:echo @/` 可以打印出来)
|
||||
- 一个简单的文本修改可以用 `.` 再次执行。(这个执行保存在 `.` 的注册表里;使用 `:echo @.` 可以打印出来)
|
||||
|
||||
如果你在一个函数里做以上操作,两件都_not_会是那么回事儿。所以你不能简单地在一个函数里高亮词汇同时再用这个函数做文本修改。
|
||||
如果你在一个函数里做以上操作,两件都_not_会是那么回事儿。所以你不能简单地在一个函数里高亮词汇同时再用这个函数做文本修改。
|
||||
|
||||
帮助: `:h function-search-undo`
|
||||
帮助: `:h function-search-undo`
|
@ -1,30 +1,30 @@
|
||||
## 映射大写锁定键(CapsLock)到控制键(Ctrl)
|
||||
## 映射大写锁定键(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,重复点击同一个按键对手指伤害很大)。
|
||||
大写锁定键属于键盘上最少用到的按键,但是它要比控制键更加容易按到,
|
||||
因为它位于你手放在键盘时的[起始行](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"。
|
||||
`System Preferences -> Keyboard -> Keyboard Tab -> Modifier Keys`. 变更
|
||||
"CapsLock" 为 "Control"。
|
||||
|
||||
**Linux**:
|
||||
|
||||
为了使按键生效,请把以下几行放入 `~/.xmodmap` 文件:
|
||||
为了使按键生效,请把以下几行放入 `~/.xmodmap` 文件:
|
||||
|
||||
remove Lock = Caps_Lock
|
||||
keysym Caps_Lock = Control_L
|
||||
add Control = Control_L
|
||||
|
||||
用以下命令使之生效<br> `$ xmodmap ~/.xmodmap`。
|
||||
用以下命令使之生效<br> `$ xmodmap ~/.xmodmap`。
|
||||
|
||||
替代方法有[caps2esc](https://github.com/oblitum/caps2esc) 或者
|
||||
[xcape](https://github.com/alols/xcape)。
|
||||
替代方法有[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)。
|
||||
请参看 [superuser.com: 在Windows8.1映射大写锁定键到控制键](http://superuser.com/questions/764782/map-caps-lock-to-control-in-windows-8-1)。
|
||||
|
@ -1,5 +0,0 @@
|
||||
## NUL 符用新行表示
|
||||
|
||||
文件中的 NUL 符 (`\0`),在内存中被以新行(`\n`)保存,在缓存空间中显示为 `^@`。
|
||||
|
||||
更多信息请参看 `man 7 ascii` 和 `:h NL-used-for-Nul` 。
|
@ -1,11 +1,11 @@
|
||||
## 内置插件
|
||||
## 内置插件
|
||||
|
||||
出乎很多人的意料,Vim自己默认加载了大把大把的插件。启动 Vim 后,用`:scriptnames`查看所有加载的源文件
|
||||
出乎很多人的意料,Vim自己默认加载了大把大把的插件。启动 Vim 后,用`:scriptnames`查看所有加载的源文件
|
||||
|
||||
这些文件多数永远不会被用到,所以请禁止如你所见的以下插件。
|
||||
这些插件仍旧会在源文件列出,但是当Vim启动时,只有第一行会被读取,而之后的配置,命令和日志都不会执行。
|
||||
这些文件多数永远不会被用到,所以请禁止如你所见的以下插件。
|
||||
这些插件仍旧会在源文件列出,但是当Vim启动时,只有第一行会被读取,而之后的配置,命令和日志都不会执行。
|
||||
|
||||
| 插件 | 禁用 | 帮助 |
|
||||
| 插件 | 禁用 | 帮助 |
|
||||
|------------|-------------------------------------|------|
|
||||
| 2html | `let g:loaded_2html_plugin = 1` | `:h 2html` |
|
||||
| getscript | `let g:loaded_getscriptPlugin = 1` | `:h pi_getscript` |
|
||||
|
@ -1,16 +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)
|
||||
|
@ -1,8 +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)
|
||||
键盘布局: [请点击](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-adm-3a-layout.jpg)
|
||||
|
||||
这也告诉了我们为什么 Unix 系统会以`~`代表主目录。
|
||||
这也告诉了我们为什么 Unix 系统会以`~`代表主目录。
|
||||
|
||||
|
@ -53,11 +53,11 @@ endif
|
||||
" Put all temporary files under the same directory.
|
||||
" https://github.com/mhinz/vim-galore#handling-backup-swap-undo-and-viminfo-files
|
||||
set backup
|
||||
set backupdir =$HOME/.vim/files/backup/
|
||||
set backupdir =$HOME/.vim/files/backup//
|
||||
set backupext =-vimbackup
|
||||
set backupskip =
|
||||
set directory =$HOME/.vim/files/swap//
|
||||
set updatecount =100
|
||||
set undofile
|
||||
set undodir =$HOME/.vim/files/undo/
|
||||
set undodir =$HOME/.vim/files/undo//
|
||||
set viminfo ='100,n$HOME/.vim/files/info/viminfo
|
||||
|
Loading…
x
Reference in New Issue
Block a user