nerdcommenter/README.md

131 lines
3.5 KiB
Markdown
Raw Normal View History

2012-03-26 23:32:56 +08:00
# Installation
2012-03-26 23:12:53 +08:00
The NERD Commenter requires Vim 7 or higher is comprised of 2 files:
2012-03-26 23:42:40 +08:00
plugin/NERD_commenter.vim
doc/NERD_commenter.txt
2012-03-26 23:12:53 +08:00
## Via Plugin Manager (Recommended)
#### Pathogen Install
###### Unix
```sh
git clone https://github.com/scrooloose/nerdcommenter.git ~/.vim/bundle
```
2012-03-26 23:32:56 +08:00
###### Neovim
2012-03-26 23:32:56 +08:00
```sh
git clone https://github.com/scrooloose/nerdcommenter.git ~/.config/nvim/bundle
```
#### Vim-Plug Install
1. Add `Plug 'Plug scrooloose/nerdcommenter'` to your .vimrc file.
2. Reload .vimrc (`:so %` from vimrc, or just restart vim)
3. Run `:PlugInstall`
#### Vundle Install
2015-02-15 23:44:28 +08:00
1. Add `Plugin 'scrooloose/nerdcommenter'` to your .vimrc file.
2. Run `:BundleInstall`
#### NeoBundle Install
1. Add `NeoBundle 'scrooloose/nerdcommenter'` to your .vimrc file.
2. Run `:NeoUpdate``
#### Post Install
After the **'Classic'** or **'Pathogen'** install, make sure that you have filetype plugins enabled, as the script makes use of
2012-03-26 23:36:43 +08:00
**|'commentstring'|** where possible (which is usually set in a filetype plugin).
See **|filetype-plugin-on|** for details, but basically, stick this in your vimrc:
2012-03-26 23:42:40 +08:00
filetype plugin on
2012-03-26 23:32:56 +08:00
## Install Manually
#### Vim
###### Unix
```sh
git clone https://github.com/scrooloose/nerdcommenter.git ~/.vim/plugin
```
###### Windows (PowerShell)
```powershell
md ~\vimfiles\plugin
$uri = 'https://raw.githubusercontent.com/scrooloose/nerdcommenter/master/plugin/NERD_commenter.vim'
(New-Object Net.WebClient).DownloadFile($uri, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("~\vimfiles\autoload\NERD_commenter.vim"))
```
#### Neovim
```sh
git clone https://github.com/scrooloose/nerdcommenter.git ~/.config/nvim/plugin
```
2012-03-26 23:32:56 +08:00
# Usage
2012-03-26 23:12:53 +08:00
The following key mappings are provided by default (there is also a menu
provided that contains menu items corresponding to all the below mappings):
2012-03-26 23:32:56 +08:00
Most of the following mappings are for normal/visual mode only. The |NERDComInsertComment| mapping is for insert mode only.
2012-03-26 23:12:53 +08:00
2012-03-26 23:32:56 +08:00
**[count]\<leader\>cc |NERDComComment|**
2012-03-26 23:12:53 +08:00
Comment out the current line or text selected in visual mode.
2012-03-26 23:36:43 +08:00
**[count]\<leader\>cn |NERDComNestedComment|**
Same as \<leader\>cc but forces nesting.
2012-03-26 23:12:53 +08:00
**[count]\<leader\>c\<space\> |NERDComToggleComment|**
2012-03-26 23:12:53 +08:00
Toggles the comment state of the selected line(s). If the topmost selected
line is commented, all selected lines are uncommented and vice versa.
2012-03-26 23:36:43 +08:00
**[count]\<leader\>cm |NERDComMinimalComment|**
2012-03-26 23:12:53 +08:00
Comments the given lines using only one set of multipart delimiters.
2012-03-26 23:36:43 +08:00
**[count]\<leader\>ci |NERDComInvertComment|**
2012-03-26 23:12:53 +08:00
Toggles the comment state of the selected line(s) individually.
2012-03-26 23:36:43 +08:00
**[count]\<leader\>cs |NERDComSexyComment|**
2012-03-26 23:12:53 +08:00
Comments out the selected lines ``sexily''
2012-03-26 23:36:43 +08:00
**[count]\<leader\>cy |NERDComYankComment|**
Same as \<leader\>cc except that the commented line(s) are yanked first.
2012-03-26 23:12:53 +08:00
2012-03-26 23:36:43 +08:00
**\<leader\>c$ |NERDComEOLComment|**
2012-03-26 23:12:53 +08:00
Comments the current line from the cursor to the end of line.
2012-03-26 23:36:43 +08:00
**\<leader\>cA |NERDComAppendComment|**
2012-03-26 23:12:53 +08:00
Adds comment delimiters to the end of line and goes into insert mode between
them.
2012-03-26 23:32:56 +08:00
**|NERDComInsertComment|**
2012-03-26 23:12:53 +08:00
Adds comment delimiters at the current cursor position and inserts between.
Disabled by default.
2012-03-26 23:36:43 +08:00
**\<leader\>ca |NERDComAltDelim|**
2012-03-26 23:12:53 +08:00
Switches to the alternative set of delimiters.
2012-03-26 23:36:43 +08:00
**[count]\<leader\>cl**
**[count]\<leader\>cb |NERDComAlignedComment|**
2012-03-26 23:12:53 +08:00
Same as |NERDComComment| except that the delimiters are aligned down the
2012-03-26 23:36:43 +08:00
left side (\<leader\>cl) or both sides (\<leader\>cb).
2012-03-26 23:12:53 +08:00
2012-03-26 23:36:43 +08:00
**[count]\<leader\>cu |NERDComUncommentLine|**
2012-03-26 23:12:53 +08:00
Uncomments the selected line(s).