mirror of
https://github.com/amix/vimrc
synced 2025-07-08 01:25:00 +08:00
renamed sources_non_forked folder to bundle
This commit is contained in:
2
bundle/vim-multiple-cursors/.rspec
Normal file
2
bundle/vim-multiple-cursors/.rspec
Normal file
@ -0,0 +1,2 @@
|
||||
--color
|
||||
--format d
|
7
bundle/vim-multiple-cursors/.travis.yml
Normal file
7
bundle/vim-multiple-cursors/.travis.yml
Normal file
@ -0,0 +1,7 @@
|
||||
language: ruby
|
||||
rvm:
|
||||
- 1.9.3
|
||||
before_install: sudo apt-get install vim-gtk
|
||||
before_script:
|
||||
- "export DISPLAY=:99.0"
|
||||
- "sh -e /etc/init.d/xvfb start"
|
109
bundle/vim-multiple-cursors/CHANGELOG.md
Normal file
109
bundle/vim-multiple-cursors/CHANGELOG.md
Normal file
@ -0,0 +1,109 @@
|
||||
## 2.2 (06/10/2013)
|
||||
Bugfixes:
|
||||
- Fix plugin break in PASTE mode. This fixes #44.
|
||||
|
||||
## 2.1 (04/26/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Fix 1 regression where cursors could potentially get out of sync in insert mode
|
||||
|
||||
Features:
|
||||
- Added some logic to debug latency. Fanning out to 30 cursors in insert mode with my vimrc took over 300ms. It's like than 20ms with a plain vimrc. Need to debug what setting is causing the slowing down in insert mode and inform users.
|
||||
|
||||
## 2.0 (04/24/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Fix inconsistent undo behavior. Changes made in multicursor insert mode are now undone together. This fixes #22.
|
||||
- Single key commands that do not terminate properly no longer cause ghostly cursors to linger on screen. An error message is now displayed informing the user the number of cursor locations that the input cannot be properly played back at. This fixes #28.
|
||||
|
||||
## 1.16 (04/23/2013)
|
||||
|
||||
Features:
|
||||
- Add integration tests using vimrunner. Hook up travis-ci to run continous integration on commit.
|
||||
|
||||
## 1.15 (04/22/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Fix plugin causing error bell. This fixes #29.
|
||||
|
||||
## 1.14 (04/22/2013)
|
||||
|
||||
Features:
|
||||
- Allow users to separate start key from next key. (credit: @xanderman)
|
||||
|
||||
## 1.13 (04/22/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Add support for switching to visual line mode from inside multicursor mode
|
||||
- Fix highlight issue where extra character at end of line is highlighted for visual selections covering more than 2 lines.
|
||||
|
||||
## 1.12 (04/19/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Fix tab character causing highlight errors. This fixes #18 and fixes #32
|
||||
|
||||
## 1.11 (04/18/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Fix regression where `C-n` doesn't exhibit correct behavior when all matches have been found
|
||||
- Clear echo messages when a new input is received
|
||||
|
||||
## 1.10 (04/17/2013)
|
||||
|
||||
Bugfixes:
|
||||
- `O` works now in normal mode. This fixes #24
|
||||
- Turn on `lazyredraw` during multicursor mode to prevent the sluggish screen redraws
|
||||
|
||||
Features:
|
||||
- Add command **MultipleCursorsFind** to add multiple virtual cursors using regexp. This closes #20
|
||||
|
||||
## 1.9 (04/17/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Fix starting multicursor mode in visual line mode. This fixes #25
|
||||
- Major refactoring to avoid getting in and out of visual mode as much as possible
|
||||
|
||||
## 1.8 (04/16/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Fix regression that causes call stack to explode with too many cursors
|
||||
|
||||
## 1.7 (04/15/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Finally fix the annoying highlighting problem when the last virtual cursor is on the last character of the line. The solution is a hack, but it should be harmless
|
||||
|
||||
## 1.6 (04/15/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Stop chaining dictionary function calls. This fixes #10 and #11
|
||||
|
||||
## 1.5 (04/15/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Exit Vim's visual mode before waiting for user's next input. This fixes #14
|
||||
|
||||
## 1.4 (04/14/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Don't use clearmatches(). It clears highlighting from other plugins. This fixes #13
|
||||
|
||||
## 1.3 (04/14/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Change mapping from using expression-quote syntax to using raw strings
|
||||
|
||||
## 1.2 (04/14/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Restore view when exiting from multicursor mode. This fixes #5
|
||||
- Remove the unnecessary user level mapping for 'prev' and 'skip' in visual mode, since we can purely detect those keys from multicursor mode
|
||||
|
||||
## 1.1 (04/14/2013)
|
||||
|
||||
Bugfixes:
|
||||
- Stop hijacking escape key in normal mode. This fixes #1, #2, and #3
|
||||
|
||||
## 1.0 (04/13/2013)
|
||||
|
||||
Initial release
|
4
bundle/vim-multiple-cursors/Gemfile
Normal file
4
bundle/vim-multiple-cursors/Gemfile
Normal file
@ -0,0 +1,4 @@
|
||||
source 'https://rubygems.org'
|
||||
gem 'vimrunner'
|
||||
gem 'rake'
|
||||
gem 'rspec'
|
22
bundle/vim-multiple-cursors/Gemfile.lock
Normal file
22
bundle/vim-multiple-cursors/Gemfile.lock
Normal file
@ -0,0 +1,22 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
diff-lcs (1.2.4)
|
||||
rake (10.0.4)
|
||||
rspec (2.13.0)
|
||||
rspec-core (~> 2.13.0)
|
||||
rspec-expectations (~> 2.13.0)
|
||||
rspec-mocks (~> 2.13.0)
|
||||
rspec-core (2.13.1)
|
||||
rspec-expectations (2.13.0)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
rspec-mocks (2.13.1)
|
||||
vimrunner (0.3.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
rake
|
||||
rspec
|
||||
vimrunner
|
20
bundle/vim-multiple-cursors/MIT-LICENSE.txt
Normal file
20
bundle/vim-multiple-cursors/MIT-LICENSE.txt
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright 2013 Terry Ma
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
112
bundle/vim-multiple-cursors/README.md
Normal file
112
bundle/vim-multiple-cursors/README.md
Normal file
@ -0,0 +1,112 @@
|
||||
# vim-multiple-cursors [](https://travis-ci.org/terryma/vim-multiple-cursors)
|
||||
|
||||
## About
|
||||
[There](https://github.com/paradigm/vim-multicursor) [have](https://github.com/felixr/vim-multiedit) [been](https://github.com/hlissner/vim-multiedit) [many](https://github.com/adinapoli/vim-markmultiple) [attempts](https://github.com/AndrewRadev/multichange.vim) at bringing Sublime Text's awesome [multiple selection][sublime-multiple-selection] feature into Vim, but none so far have been in my opinion a faithful port that is simplistic to use, yet powerful and intuitive enough for an existing Vim user. [vim-multiple-cursors] is yet another attempt at that.
|
||||
|
||||
### It's great for quick refactoring
|
||||

|
||||
|
||||
### Add a cursor to each line of your visual selection
|
||||

|
||||
|
||||
### Do it backwards too! This is not just a replay of the above gif :)
|
||||

|
||||
|
||||
### Add multiple cursors using regexes
|
||||

|
||||
|
||||
To see what keystrokes are used for the above example, see [this issue](https://github.com/terryma/vim-multiple-cursors/issues/39).
|
||||
|
||||
## Features
|
||||
- Live update in Insert mode
|
||||
- One key to rule it all! See [Quick Start](#quick-start) on what the key does in different scenarios
|
||||
- Works in Normal, Insert, and Visual mode for SINGLE key command
|
||||
|
||||
## Installation
|
||||
Install using [Pathogen], [Vundle], [Neobundle], or your favorite Vim package manager.
|
||||
|
||||
## Quick Start
|
||||
Out of the box, all you need to know is a single key `Ctrl-n`. Pressing the key in Normal mode highlights the current word under the cursor in Visual mode and places a virtual cursor at the end of it. Pressing it again finds the next ocurrence and places another virtual cursor at the end of the visual selection. If you select multiple lines in Visual mode, pressing the key puts a virtual cursor at every line and leaves you in Normal mode.
|
||||
|
||||
After you've marked all your locations with `Ctrl-n`, you can change the visual selection with normal Vim motion commands in Visual mode. You could go to Normal mode by pressing `v` and wield your motion commands there. Single key command to switch to Insert mode such as `c` or `s` from Visual mode or `i`, `a`, `I`, `A` in Normal mode should work without any issues.
|
||||
|
||||
At any time, you can press `<Esc>` to exit back to regular Vim.
|
||||
|
||||
Two additional keys are also mapped:
|
||||
- `Ctrl-p` in Visual mode will remove the current virtual cursor and go back to the previous virtual cursor location. This is useful if you are trigger happy with `Ctrl-n` and accidentally went too far.
|
||||
- `Ctrl-x` in Visual mode will remove the current virtual cursor and skip to the next virtual cursor location. This is useful if you don't want the current selection to be a candidate to operate on later.
|
||||
|
||||
You can also add multiple cursors using a regular expression. The command `MultipleCursorsFind` accepts a range and a pattern, and it will create a virtual cursor at the end of every match within the range. If no range is passed in, then it defaults to the entire buffer.
|
||||
|
||||
**NOTE:** If at any time you have lingering cursors on screen, you can press `Ctrl-n` in Normal mode and it will remove all prior cursors before starting a new one.
|
||||
|
||||
## Mapping
|
||||
Out of the box, only the single key `Ctrl-n` is mapped in regular Vim's Normal mode and Visual mode to provide the functionality mentioned above. `Ctrl-n`, `Ctrl-p`, `Ctrl-x`, and `<Esc>` are mapped in the special multicursor mode once you've added at least one virtual cursor to the buffer. If you don't like the plugin taking over your favorite key bindings, you can turn off the default with
|
||||
```
|
||||
let g:multi_cursor_use_default_mapping=0
|
||||
```
|
||||
|
||||
You can then map the 'next', 'previous', 'skip', and 'exit' keys like the following:
|
||||
```
|
||||
" Default mapping
|
||||
let g:multi_cursor_next_key='<C-n>'
|
||||
let g:multi_cursor_prev_key='<C-p>'
|
||||
let g:multi_cursor_skip_key='<C-x>'
|
||||
let g:multi_cursor_quit_key='<Esc>'
|
||||
```
|
||||
|
||||
By default, the 'next' key is also used to enter multicursor mode. If you want to use a different key to start multicursor mode than for selecting the next location, do like the following:
|
||||
```
|
||||
" Map start key separately from next key
|
||||
let g:multi_cursor_start_key='<F6>'
|
||||
```
|
||||
|
||||
**IMPORTANT:** Please note that currently only single keystrokes and special keys can be mapped. This contraint is also the reason why multikey commands such as `ciw` do not work and cause unexpected behavior in Normal mode. This means that a mapping like `<Leader>n` will NOT work correctly. For a list of special keys that are supported, see `help :key-notation`
|
||||
|
||||
**NOTE:** Please make sure to always map something to `g:multi_cursor_quit_key`, otherwise you'll have a tough time quitting from multicursor mode.
|
||||
|
||||
**NOTE:** Prior to version 1.3, the recommended way to map the keys is using the expressoin quote syntax in Vim, using something like `"\<C-n>"` or `"\<Esc>"` (see h: expr-quote). After 1.3, the recommended way is to use a raw string like above. If your key mappings don't appear to work, give the new syntax a try.
|
||||
|
||||
## Setting
|
||||
Currently there're two additional global settings one can tweak:
|
||||
### ```g:multi_cursor_exit_from_visual_mode``` (Default: 1)
|
||||
|
||||
If set to 0, then pressing `g:multi_cursor_quit_key` in _Visual_ mode will not quit and delete all existing cursors. This is useful if you want to press Escape and go back to Normal mode, and still be able to operate on all the cursors.
|
||||
|
||||
### ```g:multi_cursor_exit_from_insert_mode``` (Default: 1)
|
||||
If set to 0, then pressing `g:multi_cursor_quit_key` in _Insert_ mode will not quit and delete all existing cursors. This is useful if you want to press Escape and go back to Normal mode, and still be able to operate on all the cursors.
|
||||
|
||||
### Highlight
|
||||
The plugin uses the highlight group `multiple_cursors_cursor` and `multiple_cursors_visual` to highlight the virtual cursors and their visual selections respectively. You can customize them by putting something similar like the following in your vimrc:
|
||||
|
||||
```
|
||||
" Default highlighting (see help :highlight and help :highlight-link)
|
||||
highlight multiple_cursors_cursor term=reverse cterm=reverse gui=reverse
|
||||
highlight link multiple_cursors_visual Visual
|
||||
```
|
||||
|
||||
## Issues
|
||||
- Multi key commands like `ciw` do not work at the moment
|
||||
- All user input typed before Vim is able to fan out the last operation to all cursors is lost. This is a implementation decision to keep the input perfectly synced in all locations, at the cost of potentially losing user input.
|
||||
- Select mode is not implemented
|
||||
|
||||
## Changelog
|
||||
See [CHANGELOG.md](CHANGELOG.md)
|
||||
|
||||
## Contributing
|
||||
As one can see, there're still many issues to be resolved, patches and suggestions are always welcome! A list of open feature requests can be found [here](../../issues?labels=enhancement&state=open).
|
||||
|
||||
## Credit
|
||||
Obviously inspired by Sublime Text's [multiple selection][sublime-multiple-selection] feature, also encouraged by Emac's [multiple cursors][emacs-multiple-cursors] implemetation by Magnar Sveen
|
||||
|
||||
[vim-multiple-cursors]:http://github.com/terryma/vim-multiple-cursors
|
||||
[sublime-multiple-selection]:http://www.sublimetext.com/docs/2/multiple_selection_with_the_keyboard.html
|
||||
[Pathogen]:http://github.com/tpope/vim-pathogen
|
||||
[Vundle]:http://github.com/gmarik/vundle
|
||||
[Neobundle]:http://github.com/Shougo/neobundle.vim
|
||||
[emacs-multiple-cursors]:https://github.com/magnars/multiple-cursors.el
|
||||
|
||||
|
||||
|
||||
[](https://bitdeli.com/free "Bitdeli Badge")
|
||||
|
11
bundle/vim-multiple-cursors/Rakefile
Normal file
11
bundle/vim-multiple-cursors/Rakefile
Normal file
@ -0,0 +1,11 @@
|
||||
require 'rspec/core/rake_task'
|
||||
|
||||
RSpec::Core::RakeTask.new(:spec) do |t|
|
||||
t.pattern = 'spec/multiple_cursors_spec.rb'
|
||||
end
|
||||
|
||||
RSpec::Core::RakeTask.new(:benchmark) do |t|
|
||||
t.pattern = 'spec/benchmark_spec.rb'
|
||||
end
|
||||
|
||||
task :default => :spec
|
BIN
bundle/vim-multiple-cursors/assets/example1.gif
Normal file
BIN
bundle/vim-multiple-cursors/assets/example1.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 101 KiB |
BIN
bundle/vim-multiple-cursors/assets/example2.gif
Normal file
BIN
bundle/vim-multiple-cursors/assets/example2.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 265 KiB |
BIN
bundle/vim-multiple-cursors/assets/example3.gif
Normal file
BIN
bundle/vim-multiple-cursors/assets/example3.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 182 KiB |
BIN
bundle/vim-multiple-cursors/assets/example4.gif
Normal file
BIN
bundle/vim-multiple-cursors/assets/example4.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 532 KiB |
1023
bundle/vim-multiple-cursors/autoload/multiple_cursors.vim
Normal file
1023
bundle/vim-multiple-cursors/autoload/multiple_cursors.vim
Normal file
File diff suppressed because it is too large
Load Diff
198
bundle/vim-multiple-cursors/doc/multiple_cursors.txt
Normal file
198
bundle/vim-multiple-cursors/doc/multiple_cursors.txt
Normal file
@ -0,0 +1,198 @@
|
||||
*vim-multiple-cursors.txt* True Sublime Text multiple selection in Vim
|
||||
|
||||
____ _ __
|
||||
____ ___ __ __/ / /_(_)___ / /__ _______ ________________ __________
|
||||
/ __ `__ \/ / / / / __/ / __ \/ / _ \ / ___/ / / / ___/ ___/ __ \/ ___/ ___/
|
||||
/ / / / / / /_/ / / /_/ / /_/ / / __/ / /__/ /_/ / / (__ ) /_/ / / (__ )
|
||||
/_/ /_/ /_/\__,_/_/\__/_/ .___/_/\___/ \___/\__,_/_/ /____/\____/_/ /____/
|
||||
/_/
|
||||
|
||||
|
||||
Reference Manual~
|
||||
|
||||
|
||||
==============================================================================
|
||||
|
||||
CONTENTS *multiple-cursors-contents*
|
||||
1.Intro...................................|multiple-cursors-intro|
|
||||
2.Usage...................................|multiple-cursors-usage|
|
||||
3.Mappings................................|multiple-cursors-mappings|
|
||||
4.Global Options..........................|multiple-cursors-global-options|
|
||||
5.Issues..................................|multiple-cursors-issues|
|
||||
6.Contributing............................|multiple-cursors-contributing|
|
||||
7.License.................................|multiple-cursors-license|
|
||||
8.Credit..................................|multiple-cursors-credit|
|
||||
9.References..............................|multiple-cursors-references|
|
||||
|
||||
==============================================================================
|
||||
1. Intro *multiple-cursors-intro*
|
||||
|
||||
There [1] have [2] been [3] many [4] attempts [5] at bringing Sublime Text's
|
||||
awesome multiple selection [6] feature into Vim, but none so far have been in
|
||||
my opinion a faithful port that is simplistic to use, yet powerful and
|
||||
intuitive enough for an existing Vim user. *vim-multiple-cursors* is yet
|
||||
another attempt at that.
|
||||
|
||||
==============================================================================
|
||||
2. Usage *multiple-cursors-usage*
|
||||
|
||||
Out of the box, all you need to know is a single key CTRL-N. Pressing the key
|
||||
in Normal mode highlights the current word under the cursor in Visual mode and
|
||||
places a virtual cursor at the end of it. Pressing it again finds the next
|
||||
ocurrence and places another virtual cursor at the end of the visual
|
||||
selection. If you select multiple lines in Visual mode, pressing the key puts
|
||||
a virtual cursor at every line and leaves you in Normal mode.
|
||||
|
||||
After you've marked all your locations with CTRL-N, you can change the visual
|
||||
selection with normal Vim motion commands in Visual mode. You could go to
|
||||
Normal mode by pressing v and wield your motion commands there. Single key
|
||||
command to switch to Insert mode such as `c` or `s` from Visual mode or `i`,
|
||||
`a`, `I`, `A` in Normal mode should work without any issues.
|
||||
|
||||
At any time, you can press <Esc> to exit back to regular Vim.
|
||||
|
||||
Two additional keys are also mapped:
|
||||
|
||||
CTRL-P in Visual mode will remove the current virtual cursor and go back to
|
||||
the previous virtual cursor location. This is useful if you are trigger happy
|
||||
with Ctrl-n and accidentally went too far.
|
||||
|
||||
CTRL-X in Visual mode will remove the current virtual cursor and skip to the
|
||||
next virtual cursor location. This is useful if you don't want the current
|
||||
selection to be a candidate to operate on later.
|
||||
|
||||
You can also add multiple cursors using a regular expression. The command
|
||||
*MultipleCursorsFind* accepts a range and a pattern, and it will create a
|
||||
virtual cursor at the end of every match within the range. If no range is
|
||||
passed in, then it defaults to the entire buffer.
|
||||
|
||||
NOTE: If at any time you have lingering cursors on screen, you can press
|
||||
CTRL-N in Normal mode and it will remove all prior cursors before starting a
|
||||
new one.
|
||||
|
||||
==============================================================================
|
||||
3. Mappings *multiple-cursors-mappings*
|
||||
|
||||
*g:multi_cursor_use_default_mapping* (Default: 1)
|
||||
|
||||
Out of the box, only the single key CTRL-N is mapped in regular Vim's Normal
|
||||
mode and Visual mode to provide the functionality mentioned above. CTRL-N,
|
||||
CTRL-P, CTRL-X, and <ESC> are mapped in the special multicursor mode once
|
||||
you've added at least one virtual cursor to the buffer. If you don't like the
|
||||
plugin taking over your favorite key bindings, you can turn off the default
|
||||
with >
|
||||
|
||||
let g:multi_cursor_use_default_mapping=0
|
||||
<
|
||||
|
||||
*g:multi_cursor_next_key* (Default: '<C-n>')
|
||||
*g:multi_cursor_prev_key* (Default: '<C-p>')
|
||||
*g:multi_cursor_skip_key* (Default: '<C-x>')
|
||||
*g:multi_cursor_quit_key* (Default: '<Esc>')
|
||||
You can map the 'next', 'previous', 'skip', and 'exit' keys like the
|
||||
following: >
|
||||
|
||||
" Default mapping
|
||||
let g:multi_cursor_next_key='<C-n>'
|
||||
let g:multi_cursor_prev_key='<C-p>'
|
||||
let g:multi_cursor_skip_key='<C-x>'
|
||||
let g:multi_cursor_quit_key='<Esc>'
|
||||
<
|
||||
|
||||
*g:multi_cursor_start_key* (Default: 'g:multi_cursor_next_key')
|
||||
By default, the same key is used to enter multicursor mode as to select the
|
||||
next cursor location. If you want to use a different key to start multicursor
|
||||
mode than for selecting the next location, do like the following: >
|
||||
|
||||
" Map start key separately from next key
|
||||
let g:multi_cursor_start_key='<F6>'
|
||||
<
|
||||
|
||||
IMPORTANT: Please note that currently only single keystroes and special
|
||||
keys can be mapped. This contraint is also the reason why multikey commands
|
||||
such as `ciw` do not work and cause unexpected behavior in Normal mode. This
|
||||
means that a mapping like `<Leader>n` will NOT work correctly. For a list of
|
||||
special keys that are supported, see |key-notation|
|
||||
|
||||
NOTE: Please make sure to always map something to |g:multi_cursor_quit_key|,
|
||||
otherwise you'll have a tough time quitting from multicursor mode.
|
||||
|
||||
NOTE: Prior to version 1.3, the recommended way to map the keys is using the
|
||||
expressoin quote syntax in Vim, using something like `"\<C-n>"` or `"\<Esc>"`
|
||||
(see h: expr-quote). After 1.3, the recommended way is to use a raw string
|
||||
like above. If your key mappings don't appear to work, give the new syntax a
|
||||
try.
|
||||
|
||||
==============================================================================
|
||||
4. Global Options *multiple-cursors-global-options*
|
||||
|
||||
Currently there're two additional global settings one can tweak:
|
||||
|
||||
*g:multi_cursor_exit_from_visual_mode* (Defaut: 1)
|
||||
|
||||
If set to 0, then pressing |g:multi_cursor_quit_key| in Visual mode will not
|
||||
quit and delete all existing cursors. This is useful if you want to press
|
||||
Escape and go back to Normal mode, and still be able to operate on all the
|
||||
cursors.
|
||||
|
||||
*g:multi_cursor_exit_from_insert_mode* (Default: 1)
|
||||
|
||||
If set to 0, then pressing |g:multi_cursor_quit_key| in Insert mode will not
|
||||
quit and delete all existing cursors. This is useful if you want to press
|
||||
Escape and go back to Normal mode, and still be able to operate on all the
|
||||
cursors.
|
||||
|
||||
The plugin uses the highlight group `multiple_cursors_cursor` and
|
||||
`multiple_cursors_visual` to highlight the virtual cursors and their visual
|
||||
selections respectively. You can customize them by putting something similar
|
||||
like the following in your vimrc: >
|
||||
|
||||
" Default highlighting (see help :highlight and help :highlight-link)
|
||||
highlight multiple_cursors_cursor term=reverse cterm=reverse gui=reverse
|
||||
highlight link multiple_cursors_visual Visual
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
5. Issues *multiple-cursors-issues*
|
||||
|
||||
- Multi key commands like ciw do not work at the moment
|
||||
- All user input typed before Vim is able to fan out the last operation to all
|
||||
cursors is lost. This is a implementation decision to keep the input
|
||||
perfectly synced in all locations, at the cost of potentially losing user
|
||||
input.
|
||||
- Select mode is not implemented
|
||||
|
||||
==============================================================================
|
||||
6. Contributing *multiple-cursors-contributing*
|
||||
|
||||
The project is hosted on Github. Patches, feature requests and suggestions are
|
||||
always welcome!
|
||||
|
||||
Find the latest version of the plugin here:
|
||||
http://github.com/terryma/vim-multiple-cursors
|
||||
|
||||
==============================================================================
|
||||
7. License *multiple-cursors-license*
|
||||
|
||||
The project is licensed under the MIT license [7]. Copyrigth 2013 Terry Ma
|
||||
|
||||
==============================================================================
|
||||
8. Credit *multiple-cursors-credit*
|
||||
|
||||
The plugin is obviously inspired by Sublime Text's awesome multiple selection
|
||||
[6] feature. Some inspiration was also taken from Emac's multiple cursors [8]
|
||||
implementation.
|
||||
|
||||
==============================================================================
|
||||
9. References *multiple-cursors-references*
|
||||
|
||||
[1] https://github.com/paradigm/vim-multicursor
|
||||
[2] https://github.com/felixr/vim-multiedit
|
||||
[3] https://github.com/hlissner/vim-multiedit
|
||||
[4] https://github.com/adinapoli/vim-markmultiple
|
||||
[5] https://github.com/AndrewRadev/multichange.vim
|
||||
[6] http://www.sublimetext.com/docs/2/multiple_selection_with_the_keyboard.html
|
||||
[7] http://opensource.org/licenses/MIT
|
||||
[8] https://github.com/magnars/multiple-cursors.el
|
||||
|
||||
vim:tw=78:sw=4:ft=help:norl:
|
66
bundle/vim-multiple-cursors/plugin/multiple_cursors.vim
Normal file
66
bundle/vim-multiple-cursors/plugin/multiple_cursors.vim
Normal file
@ -0,0 +1,66 @@
|
||||
"===============================================================================
|
||||
" File: multiple_cursors.vim
|
||||
" Author: Terry Ma
|
||||
" Description: Emulate Sublime Text's multi selection feature
|
||||
" Potential Features:
|
||||
" - Create a blinking cursor effect? Good place to do it would be instead of
|
||||
" waiting for user input, cycle through the highlight
|
||||
" - Integrate with the status line? Maybe show a special multicursor mode?
|
||||
" - Support mouse? Ctrl/Cmd click to set cursor?
|
||||
"===============================================================================
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! s:init_settings(settings)
|
||||
for [key, value] in items(a:settings)
|
||||
let sub = ''
|
||||
if type(value) == 0
|
||||
let sub = '%d'
|
||||
elseif type(value) == 1
|
||||
let sub = '"%s"'
|
||||
endif
|
||||
let fmt = printf("let g:multi_cursor_%%s=get(g:, 'multi_cursor_%%s', %s)",
|
||||
\ sub)
|
||||
exec printf(fmt, key, key, value)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" Settings
|
||||
let s:settings = {
|
||||
\ 'exit_from_visual_mode': 1,
|
||||
\ 'exit_from_insert_mode': 1,
|
||||
\ 'use_default_mapping': 1,
|
||||
\ 'debug_latency': 0,
|
||||
\ }
|
||||
|
||||
let s:settings_if_default = {
|
||||
\ 'quit_key': '<Esc>',
|
||||
\ 'next_key': '<C-n>',
|
||||
\ 'prev_key': '<C-p>',
|
||||
\ 'skip_key': '<C-x>',
|
||||
\ }
|
||||
|
||||
call s:init_settings(s:settings)
|
||||
|
||||
if g:multi_cursor_use_default_mapping
|
||||
call s:init_settings(s:settings_if_default)
|
||||
endif
|
||||
|
||||
if !exists('g:multi_cursor_start_key') && exists('g:multi_cursor_next_key')
|
||||
let g:multi_cursor_start_key = g:multi_cursor_next_key
|
||||
endif
|
||||
|
||||
" External mappings
|
||||
if exists('g:multi_cursor_start_key')
|
||||
exec 'nnoremap <silent> '.g:multi_cursor_start_key.
|
||||
\' :call multiple_cursors#new("n")<CR>'
|
||||
exec 'xnoremap <silent> '.g:multi_cursor_start_key.
|
||||
\' :<C-u>call multiple_cursors#new("v")<CR>'
|
||||
endif
|
||||
|
||||
" Commands
|
||||
command! -nargs=1 -range=% MultipleCursorsFind
|
||||
\ call multiple_cursors#find(<line1>, <line2>, <q-args>)
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
141
bundle/vim-multiple-cursors/spec/benchmark_spec.rb
Normal file
141
bundle/vim-multiple-cursors/spec/benchmark_spec.rb
Normal file
@ -0,0 +1,141 @@
|
||||
require 'vimrunner'
|
||||
require 'vimrunner/rspec'
|
||||
|
||||
Vimrunner::RSpec.configure do |config|
|
||||
|
||||
# Use a single Vim instance for the test suite. Set to false to use an
|
||||
# instance per test (slower, but can be easier to manage).
|
||||
config.reuse_server = false
|
||||
|
||||
# Decide how to start a Vim instance. In this block, an instance should be
|
||||
# spawned and set up with anything project-specific.
|
||||
config.start_vim do
|
||||
# vim = Vimrunner.start
|
||||
# vim = Vimrunner::Server.new("/usr/local/bin/vim").start
|
||||
|
||||
# Or, start a GUI instance:
|
||||
vim = Vimrunner.start_gvim
|
||||
|
||||
# Setup your plugin in the Vim instance
|
||||
plugin_path = File.expand_path('../..', __FILE__)
|
||||
vim.add_plugin(plugin_path, 'plugin/multiple_cursors.vim')
|
||||
|
||||
# The returned value is the Client available in the tests.
|
||||
vim
|
||||
end
|
||||
end
|
||||
|
||||
def set_file_content(string)
|
||||
string = normalize_string_indent(string)
|
||||
File.open(filename, 'w'){ |f| f.write(string) }
|
||||
vim.edit filename
|
||||
end
|
||||
|
||||
def get_file_content()
|
||||
vim.write
|
||||
IO.read(filename).strip
|
||||
end
|
||||
|
||||
def before(string)
|
||||
set_file_content(string)
|
||||
end
|
||||
|
||||
def after(string)
|
||||
get_file_content().should eq normalize_string_indent(string)
|
||||
type ":q<CR>"
|
||||
end
|
||||
|
||||
def type(string)
|
||||
string.scan(/<.*?>|./).each do |key|
|
||||
if /<.*>/.match(key)
|
||||
vim.feedkeys "\\#{key}"
|
||||
else
|
||||
vim.feedkeys key
|
||||
end
|
||||
end
|
||||
sleep 0.2
|
||||
end
|
||||
|
||||
describe "Multiple Cursors" do
|
||||
let(:filename) { 'test.txt' }
|
||||
|
||||
specify "#benchmark" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
# type ':profile start /tmp/test.result<CR>'
|
||||
# type ':profile! file *multiple_cursors.vim<CR>'
|
||||
type ':let g:multi_cursor_debug_latency=1<CR>'
|
||||
|
||||
type 'VG<C-n>Vchellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello<Esc>'
|
||||
|
||||
type ':echo multiple_cursors#get_latency_debug_file()<CR>'
|
||||
sleep 3
|
||||
latency_file = vim.command 'echo multiple_cursors#get_latency_debug_file()'
|
||||
puts 'latency file = ' + latency_file
|
||||
|
||||
after <<-EOF
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello
|
||||
EOF
|
||||
end
|
||||
|
||||
end
|
288
bundle/vim-multiple-cursors/spec/multiple_cursors_spec.rb
Normal file
288
bundle/vim-multiple-cursors/spec/multiple_cursors_spec.rb
Normal file
@ -0,0 +1,288 @@
|
||||
require 'spec_helper'
|
||||
|
||||
def set_file_content(string)
|
||||
string = normalize_string_indent(string)
|
||||
File.open(filename, 'w'){ |f| f.write(string) }
|
||||
vim.edit filename
|
||||
end
|
||||
|
||||
def get_file_content()
|
||||
vim.write
|
||||
IO.read(filename).strip
|
||||
end
|
||||
|
||||
def before(string)
|
||||
set_file_content(string)
|
||||
end
|
||||
|
||||
def after(string)
|
||||
get_file_content().should eq normalize_string_indent(string)
|
||||
end
|
||||
|
||||
def type(string)
|
||||
string.scan(/<.*?>|./).each do |key|
|
||||
if /<.*>/.match(key)
|
||||
vim.feedkeys "\\#{key}"
|
||||
else
|
||||
vim.feedkeys key
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "Multiple Cursors" do
|
||||
let(:filename) { 'test.txt' }
|
||||
|
||||
specify "#multiline replacement" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n><C-n>cworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world
|
||||
world
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#single line replacement" do
|
||||
before <<-EOF
|
||||
hello hello hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n><C-n>cworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world world world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#mixed line replacement" do
|
||||
before <<-EOF
|
||||
hello hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n><C-n>cworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world world
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#new line in insert mode" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>chello<CR>world<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello
|
||||
world
|
||||
hello
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#new line in insert mode middle of line" do
|
||||
before <<-EOF
|
||||
hello world
|
||||
hello world
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>vlxi<cr><Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello
|
||||
world
|
||||
hello
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#normal mode 'o'" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>voworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello
|
||||
world
|
||||
hello
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#normal mode 'O'" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>vOworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world
|
||||
hello
|
||||
world
|
||||
hello
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#find command basic" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
vim.normal ':MultipleCursorsFind hello<CR>'
|
||||
type 'cworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#visual line mode replacement" do
|
||||
before <<-EOF
|
||||
hello world
|
||||
hello world
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>Vchi!<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hi!
|
||||
hi!
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#skip key" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n><C-x>cworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world
|
||||
hello
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#prev key" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n><C-n><C-p>cworld<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world
|
||||
world
|
||||
hello
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#normal mode 'I'" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>vIworld <Esc>'
|
||||
|
||||
after <<-EOF
|
||||
world hello
|
||||
world hello
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#normal mode 'A'" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>vA world<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello world
|
||||
hello world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#undo" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>cworld<Esc>u'
|
||||
|
||||
after <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
end
|
||||
|
||||
# 'd' is an operator pending command, which are not supported at the moment.
|
||||
# This should result in a nop, but we should still remain in multicursor mode.
|
||||
specify "#normal mode 'd'" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n>vdx<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hell
|
||||
hell
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#multiline visual mode" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type 'Vj<C-n>A world<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello world
|
||||
hello world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#set paste mode" do
|
||||
before <<-EOF
|
||||
hello
|
||||
hello
|
||||
EOF
|
||||
|
||||
type ':set paste<CR><C-n><C-n>cworld<Esc>:set nopaste<CR>'
|
||||
|
||||
after <<-EOF
|
||||
world
|
||||
world
|
||||
EOF
|
||||
end
|
||||
|
||||
end
|
25
bundle/vim-multiple-cursors/spec/spec_helper.rb
Normal file
25
bundle/vim-multiple-cursors/spec/spec_helper.rb
Normal file
@ -0,0 +1,25 @@
|
||||
require 'vimrunner'
|
||||
require 'vimrunner/rspec'
|
||||
|
||||
Vimrunner::RSpec.configure do |config|
|
||||
|
||||
# Use a single Vim instance for the test suite. Set to false to use an
|
||||
# instance per test (slower, but can be easier to manage).
|
||||
config.reuse_server = true
|
||||
|
||||
# Decide how to start a Vim instance. In this block, an instance should be
|
||||
# spawned and set up with anything project-specific.
|
||||
config.start_vim do
|
||||
# vim = Vimrunner.start
|
||||
|
||||
# Or, start a GUI instance:
|
||||
vim = Vimrunner.start_gvim
|
||||
|
||||
# Setup your plugin in the Vim instance
|
||||
plugin_path = File.expand_path('../..', __FILE__)
|
||||
vim.add_plugin(plugin_path, 'plugin/multiple_cursors.vim')
|
||||
|
||||
# The returned value is the Client available in the tests.
|
||||
vim
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user