Ⅰ. 插件描述
a better (hopefully) :Join command in vimⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'sk1418/join'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'sk1418/join'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'sk1418/join'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/sk1418/join
Ⅳ. 文档说明
Join README file
__ _ __
/ /___ (_)___ / /
__ / / __ \/ / __ \ / /
/ /_/ / /_/ / / / / / /_/
\____/\____/_/_/ /_/ (_)
-Do better Join in vim
Join
(http://www.vim.org/scripts/script.php?script_id=4516)
Join provides more powerful line join features than the build-in :join.
Features
Except for all features provided by the build-in :join command, Join can:
- Join lines with separator (string)
- Join lines with or without trimming the leading/trailing whitespaces
- Join lines with negative count (backwards join)
- Join lines in reverse
- Join lines and keep joined lines (without removing joined lines)
- Join lines with any combinations of above options
Usage
If you are impatient, move your eyes down to the Examples and Screenshots section. :)
Join plugin defines only one command: :Join. If there is no other customer command (by other plugins maybe) starts with J, :J is also available for :Join.
The command format is:
:[range]Join[!] [separator] [count] [flags]
Short explanation: (detailed command description please check :h Join)
all arguments are optional. If one argument was not given, the default value will be used:
arg | Default value
range | current line
count | 1
bang | ""
separator| " "flags | ""
- all given arguments must be separated by space
rangefollows Vim's range definitionseparatormust be the 1st argument, and could be any string. It must be quoted by"or', depends on if an escaped special character is required.- the order of last two argument: count and flags are free. e.g
:Join 5 rkand:Join rk 5, both are valid. countcould be negative number. In this case Join will do backwards join.flags:r : (reverse) join lines in reverse
k : (keep) don't remove joined line after join- If you don't give
[separator]and[flags]also give only positive[count], the:Joinworks as same as build-in:join
Examples & Screenshots
For detailed explainations, please check :h Join
| Before | command & description | After |
|---|---|---|
![]() | :J ', ' 3<br/>Join with:<br/>sep<br/>count | ![]() |
![]() | :J '-' 3 r<br/>Join with:<br/>sep<br/>count<br/>reverse | ![]() |
![]() | :J '-' 3 k<br/>Join with:<br/>sep<br/>count<br/>keep | ![]() |
![]() | :J '-' 3 kr<br/>Join with:<br/>sep<br/>count<br/>keep<br/>reverse | ![]() |
![]() | :J -3<br/>Join with:<br/>negative count | ![]() |
![]() | :J -3 r<br/>Join with:<br/>negative count<br/>reverse | ![]() |
![]() | :J -3 kr<br/>Join with:<br/>negative count<br/>reverse<br/>keep | ![]() |
![]() | :2,5J "'\"\t" k<br/>Join with:<br/>range<br/>special sep<br/>keep | ![]() |
![]() | :2,5J "# " rk<br/>Join with:<br/>range<br/>sep<br/>keep<br/>reverse | ![]() |
![]() | :5,7J 3<br/>Join with:<br/>range<br/>count | ![]() |
![]() | :5,7J -3<br/>Join with:<br/>range<br/>negative count | ![]() |
vim: ft=markdown sw=2 ts=2 fdm=marker expandtab











