mirror of
1
0
Fork 0

Updated vim plugins

This commit is contained in:
amix 2013-04-26 13:17:22 -03:00
parent a817e88e35
commit 687184f0bb
45 changed files with 1186 additions and 411 deletions

View File

@ -227,6 +227,19 @@ function! nerdtree#invokeKeyMap(key)
call g:NERDTreeKeyMap.Invoke(a:key)
endfunction
" FUNCTION: nerdtree#loadClassFiles() {{{2
function! nerdtree#loadClassFiles()
runtime lib/nerdtree/path.vim
runtime lib/nerdtree/menu_controller.vim
runtime lib/nerdtree/menu_item.vim
runtime lib/nerdtree/key_map.vim
runtime lib/nerdtree/bookmark.vim
runtime lib/nerdtree/tree_file_node.vim
runtime lib/nerdtree/tree_dir_node.vim
runtime lib/nerdtree/opener.vim
runtime lib/nerdtree/creator.vim
endfunction
" FUNCTION: nerdtree#postSourceActions() {{{2
function! nerdtree#postSourceActions()
call g:NERDTreeBookmark.CacheBookmarks(0)

View File

@ -136,15 +136,7 @@ call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U")
call s:initVariable("g:NERDTreeMapCWD", "CD")
"SECTION: Load class files{{{2
runtime plugin/nerdtree/path.vim
runtime plugin/nerdtree/menu_controller.vim
runtime plugin/nerdtree/menu_item.vim
runtime plugin/nerdtree/key_map.vim
runtime plugin/nerdtree/bookmark.vim
runtime plugin/nerdtree/tree_file_node.vim
runtime plugin/nerdtree/tree_dir_node.vim
runtime plugin/nerdtree/opener.vim
runtime plugin/nerdtree/creator.vim
call nerdtree#loadClassFiles()
" SECTION: Commands {{{1
"============================================================

0
sources_non_forked/vim-expand-region/MIT-LICENSE.txt Executable file → Normal file
View File

0
sources_non_forked/vim-expand-region/README.md Executable file → Normal file
View File

View File

View File

0
sources_non_forked/vim-expand-region/expand-region.gif Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 753 KiB

After

Width:  |  Height:  |  Size: 753 KiB

View File

View File

@ -0,0 +1,2 @@
--color
--format d

View 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"

View File

@ -0,0 +1,97 @@
## 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

View File

@ -0,0 +1,4 @@
source 'https://rubygems.org'
gem 'vimrunner'
gem 'rake'
gem 'rspec'

View 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

View File

49
sources_non_forked/vim-multiple-cursors/README.md Executable file → Normal file
View File

@ -1,4 +1,4 @@
# vim-multiple-cursors
# vim-multiple-cursors [![Build Status](https://travis-ci.org/terryma/vim-multiple-cursors.png)](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.
@ -12,6 +12,11 @@
### Do it backwards too! This is not just a replay of the above gif :)
![Example3](assets/example3.gif?raw=true)
### Add multiple cursors using regexes
![Example4](assets/example4.gif?raw=true)
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
@ -31,31 +36,45 @@ 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.
**NOTE**: The plugin is still somewhat buggy, 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.
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, `Ctrl-n`, `Ctrl-p`, and `Ctrl-x` are mapped by default. If you don't like the plugin taking over your favorite key bindings, then turn off the default with
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 map the 'next', 'previous', 'skip', and 'exit' keys like the following:
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_exit_key="\<Esc>"
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``` (Defaut: 1)
If set to 0, then pressing `g:multi_cursor_exit_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.
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_exit_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.
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:
@ -69,15 +88,14 @@ 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.
- Single key commands that do not terminate properly cause unexpected behavior. For example, if the cursor is on the first character in the buffer and 'b' is pressed.
- Undo behavior is unpredictable
- Performance in terminal vim degrades significantly with more cursors
- Select mode is not implemented
- Buggy when `wrap` is turned on
- Cursor highlighting is off. The last column on the same row as Vim's cursor is not highlighted incorrectly. Setting virtualedit=all might help
## 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!
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
@ -88,3 +106,4 @@ Obviously inspired by Sublime Text's [multiple selection][sublime-multiple-selec
[Vundle]:http://github.com/gmarik/vundle
[Neobundle]:http://github.com/Shougo/neobundle.vim
[emacs-multiple-cursors]:https://github.com/magnars/multiple-cursors.el

View File

@ -0,0 +1,5 @@
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec

View File

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 101 KiB

View File

Before

Width:  |  Height:  |  Size: 265 KiB

After

Width:  |  Height:  |  Size: 265 KiB

View File

Before

Width:  |  Height:  |  Size: 182 KiB

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 KiB

File diff suppressed because it is too large Load Diff

View File

@ -61,36 +61,68 @@ 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.
**NOTE**: The plugin is still somewhat buggy, 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.
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, CTRL-N, CTRL-P, and CTRL-X are mapped by default. If you don't
like the plugin taking over your favorite key bindings, then turn off the
default with >
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_exit_key* (Default: "\<Esc>")
*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_exit_key="\<Esc>"
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*
@ -98,14 +130,14 @@ 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_exit_key| in Visual mode will not
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_exit_key| in Insert mode will not
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.
@ -128,15 +160,8 @@ like the following in your vimrc: >
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.
- Single key commands that do not terminate properly cause unexpected
behavior. For example, if the cursor is on the first character in the buffer
and 'b' is pressed.
- Undo behavior is unpredictable
- Performance in terminal vim degrades significantly with more cursors
- Select mode is not implemented
- Buggy when wrap is turned on
- Cursor highlighting is off. The last column on the same row as Vim's cursor
is not highlighted incorrectly. Setting virtualedit=all might help
==============================================================================
6. Contributing *multiple-cursors-contributing*

View File

@ -1,9 +1,11 @@
MultipleCursorsFind multiple_cursors.txt /*MultipleCursorsFind*
g:multi_cursor_exit_from_insert_mode multiple_cursors.txt /*g:multi_cursor_exit_from_insert_mode*
g:multi_cursor_exit_from_visual_mode multiple_cursors.txt /*g:multi_cursor_exit_from_visual_mode*
g:multi_cursor_exit_key multiple_cursors.txt /*g:multi_cursor_exit_key*
g:multi_cursor_next_key multiple_cursors.txt /*g:multi_cursor_next_key*
g:multi_cursor_prev_key multiple_cursors.txt /*g:multi_cursor_prev_key*
g:multi_cursor_quit_key multiple_cursors.txt /*g:multi_cursor_quit_key*
g:multi_cursor_skip_key multiple_cursors.txt /*g:multi_cursor_skip_key*
g:multi_cursor_start_key multiple_cursors.txt /*g:multi_cursor_start_key*
g:multi_cursor_use_default_mapping multiple_cursors.txt /*g:multi_cursor_use_default_mapping*
multiple-cursors-contents multiple_cursors.txt /*multiple-cursors-contents*
multiple-cursors-contributing multiple_cursors.txt /*multiple-cursors-contributing*

View File

@ -2,45 +2,11 @@
" File: multiple_cursors.vim
" Author: Terry Ma
" Description: Emulate Sublime Text's multi selection feature
" Issues:
" - Performance in terminal vim degrades significantly with more cursors
" - 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.
" - Multi key commands is not supported
" - Single key commands that do not terminate properly cause unexpected
" behavior. For example, if the cursor is on the first character in the buffer
" and 'b' is pressed.
" - Undo behavior is unpredictable
" - Select mode is not implemented
" - There is a bug with selection and highlight when wrap is on
"
" 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?
"
" Features:
" - Real time update of cursor locations
" - In normal mode, pressing <C-n> will highlight the current word under cursor,
" and places a 'multicursor' at the end of the word, and goes to visual mode
" - In visual mode, right after the above operation, pressing <C-n> again will
" search for the word forward, and places a new cursor at the end of the
" resulting search, one can continue to do this in Visual mode, this resembles
" the Cmd-D feature of Sublime
" - In insert mode, insert operations are captures and replayed at all the
" cursor locations
" - Pressing <Esc> in Normal mode quits multicursor mode and clears all cursors
" - Normal mode single keystroke commands work:
" - Works: 'w,e,i,p,a,h,j,k,l,x,v,b'
" - Does not work: ''
" - Replace mode just seems to work
" - Visual mode
" - Works: 'w,e,b,h,j,k,l,o'
" - Does not work: 'A, I', because <C-o> does not get it out of normal mode
" for these commands. It takes two
"===============================================================================
let s:save_cpo = &cpo
set cpo&vim
@ -67,10 +33,10 @@ let s:settings = {
\ }
let s:settings_if_default = {
\ 'quit_key': "\<Esc>",
\ 'next_key': "\<C-n>",
\ 'prev_key': "\<C-p>",
\ 'skip_key': "\<C-x>",
\ 'quit_key': '<Esc>',
\ 'next_key': '<C-n>',
\ 'prev_key': '<C-p>',
\ 'skip_key': '<C-x>',
\ }
call s:init_settings(s:settings)
@ -79,21 +45,21 @@ 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_next_key')
exec 'nnoremap <silent> '.g:multi_cursor_next_key.
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_next_key.
exec 'xnoremap <silent> '.g:multi_cursor_start_key.
\' :<C-u>call multiple_cursors#new("v")<CR>'
endif
if exists('g:multi_cursor_prev_key')
exec 'xnoremap <silent> '.g:multi_cursor_prev_key.
\' :<C-u>call multiple_cursors#prev()<CR>'
endif
if exists('g:multi_cursor_skip_key')
exec 'xnoremap <silent> '.g:multi_cursor_skip_key.
\' :<C-u>call multiple_cursors#skip()<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

View File

@ -0,0 +1,259 @@
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
end

View 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

View File

@ -14,7 +14,7 @@ In other words: upstream of snipmate is almost dead. (Better to say Marc Weber i
:Author: `Michael Sanders`_
:Maintainer: `Adnan Zafar`_ & `Rok Garbas`_ & `Marc Weber`_
:Homepage: http://www.vim.org/scripts/script.php?script_id=2540
:Contributors: `MarcWeber`_, `lilydjwg`_, `henrik`_, `steveno`_, `asymmetric`_, `jherdman`_, `ironcamel`_, `honza`_, `jb55`_, `robhudson`_, `kozo2`_, `MicahElliott`_, `darkwise`_, `redpill`_, `thisgeek`_, `sickill`_, `pose`_, `marutanm`_, `r00k`_, `jbernard`_, `holizz`_, `muffinresearch`_, `statik`_, `taq`_, `alderz`_, `pielgrzym`_
:Contributors: `MarcWeber`_, `lilydjwg`_, `henrik`_, `steveno`_, `asymmetric`_, `jherdman`_, `ironcamel`_, `honza`_, `jb55`_, `robhudson`_, `kozo2`_, `MicahElliott`_, `darkwise`_, `redpill`_, `thisgeek`_, `sickill`_, `pose`_, `marutanm`_, `r00k`_, `jbernard`_, `holizz`_, `muffinresearch`_, `statik`_, `taq`_, `alderz`_, `radicalbit`_, `pielgrzym`_
.. contents::
@ -254,3 +254,4 @@ TODO / Future
.. _`taq`: https://github.com/taq
.. _`vim.org`: http://www.vim.org/scripts/script.php?script_id=2540
.. _`GitHub`: http://github.com/msanders/snipmate.vim
.. _`radicalbit`: https://github.com/radicalbit

View File

@ -1,54 +1,51 @@
" These are the mappings for snipMate.vim. Putting it here ensures that it
" will be mapped after other plugins such as supertab.vim.
if !exists('loaded_snips') || exists('s:did_snips_mappings')
finish
endif
let s:did_snips_mappings = 1
" save and reset 'cpo'
" snipMate maps
" These maps are created here in order to make sure we can reliably create maps
" after SuperTab.
let s:save_cpo = &cpo
set cpo&vim
" This is put here in the 'after' directory in order for snipMate to override
" other plugin mappings (e.g., supertab).
"
" To adjust the tirgger key see (:h snipMate-trigger)
"
if !exists('g:snips_trigger_key')
let g:snips_trigger_key = '<tab>'
function! s:map_if_not_mapped(lhs, rhs, mode)
let l:unique = s:overwrite ? '' : ' <unique>'
if !hasmapto(a:rhs, a:mode)
silent! exe a:mode . 'map' . l:unique a:lhs a:rhs
endif
endfunction
if !exists('g:snips_no_mappings') || !g:snips_no_mappings
if exists('g:snips_trigger_key')
echom 'g:snips_trigger_key is deprecated. See :h snipMate-mappings'
exec 'imap <unique>' g:snips_trigger_key '<Plug>snipMateTrigger'
exec 'smap <unique>' g:snips_trigger_key '<Plug>snipMateSNext'
exec 'xmap <unique>' g:snips_trigger_key '<Plug>snipMateVisual'
else
" Remove SuperTab map if it exists
let s:overwrite = maparg('<Tab>', 'i') ==? '<Plug>SuperTabForward'
call s:map_if_not_mapped('<Tab>', '<Plug>snipMateNextOrTrigger', 'i')
call s:map_if_not_mapped('<Tab>', '<Plug>snipMateNextOrTrigger', 's')
let s:overwrite = 0
call s:map_if_not_mapped('<Tab>', '<Plug>snipMateVisual', 'x')
endif
if !exists('g:snips_trigger_key_backwards')
let g:snips_trigger_key_backwards = '<s-' . substitute(g:snips_trigger_key, '[<>]', '', 'g') . '>'
if exists('g:snips_trigger_key_backwards')
echom 'g:snips_trigger_key_backwards is deprecated. See :h snipMate-mappings'
exec 'imap <unique>' g:snips_trigger_key_backwards '<Plug>snipMateIBack'
exec 'smap <unique>' g:snips_trigger_key_backwards '<Plug>snipMateSBack'
else
let s:overwrite = maparg('<S-Tab>', 'i') ==? '<Plug>SuperTabBackward'
call s:map_if_not_mapped('<S-Tab>', '<Plug>snipMateBack', 'i')
call s:map_if_not_mapped('<S-Tab>', '<Plug>snipMateBack', 's')
let s:overwrite = 0
endif
exec 'ino <silent> ' . g:snips_trigger_key . ' <c-r>=snipMate#TriggerSnippet()<cr>'
exec 'snor <silent> ' . g:snips_trigger_key . ' <esc>i<right><c-r>=snipMate#TriggerSnippet()<cr>'
exec 'ino <silent> ' . g:snips_trigger_key_backwards . ' <c-r>=snipMate#BackwardsSnippet()<cr>'
exec 'snor <silent> ' . g:snips_trigger_key_backwards . ' <esc>i<right><c-r>=snipMate#BackwardsSnippet()<cr>'
exec 'ino <silent> <c-r>' . g:snips_trigger_key . ' <c-r>=snipMate#ShowAvailableSnips()<cr>'
" maybe there is a better way without polluting registers ?
exec 'xnoremap ' . g:snips_trigger_key. ' s<c-o>:let<space>g:snipmate_content_visual=getreg('1')<cr>'
" The default mappings for these are annoying & sometimes break snipMate.
" You can change them back if you want, I've put them here for convenience.
snor <bs> b<bs>
snor <right> <esc>a
snor <left> <esc>bi
snor ' b<bs>'
snor ` b<bs>`
snor % b<bs>%
snor U b<bs>U
snor ^ b<bs>^
snor \ b<bs>\
snor <c-x> b<bs><c-x>
" By default load snippets in snippets_dir
if empty(snippets_dir)
finish
call s:map_if_not_mapped('<C-R><Tab>', '<Plug>snipMateShow', 'i')
endif
" restore 'cpo'
" FIXME: Without this map, <BS> in select mode deletes the current selection and
" returns to normal mode. This doesn't update placeholders. Ideally there's some
" way to update the placeholders without this otherwise useless map.
silent! snoremap <unique> <BS> b<BS><Esc>
let &cpo = s:save_cpo
" vim:noet:sw=4:ts=4:ft=vim
" vim:noet:

View File

@ -339,7 +339,6 @@ function! s:state_proto.update_vars(change)
let newWord = strpart(getline('.'), self.start_col - 1, newWordLen)
let changeLen = a:change
let curLine = line('.')
let startCol = col('.')
let oldStartSnip = self.start_col
let updateTabStops = changeLen != 0
let i = 0
@ -370,6 +369,12 @@ function! s:state_proto.update_vars(change)
" subtract another -1 to exclude the col'th element
call setline(lnum, theline[0:(col-2)] . newWord . theline[(col+self.end_col-self.start_col-a:change-1):])
endfor
" Reposition the cursor in case a var updates on the same line but before
" the current tabstop
if oldStartSnip != self.start_col
call cursor(0, col('.') + self.start_col - oldStartSnip)
endif
endfunction
" should be moved to utils or such?

View File

@ -356,18 +356,28 @@ If you would like your snippets to be expanded using spaces instead of tabs,
just enable 'expandtab' and set 'softtabstop' to your preferred amount of
spaces. If 'softtabstop' is not set, 'shiftwidth' is used instead.
*snipMate-trigger*
snipMate comes with a setting to configure the key that is used to trigger
snipMate. To configure the key set g:snips_trigger_key to something other than
<tab>,e.g. <c-space> use:
*snipMate-mappings*
The mappings snipMate uses can be customized with the |:map| commands. For
example, to change the key that triggers snippets and moves to the next
tabstop, >
let g:snips_trigger_key='<c-space>'
:imap <C-J> <Plug>snipMateNextOrTrigger
:smap <C-J> <Plug>snipMateNextOrTrigger
<
The list of possible <Plug> mappings is as follows:
snipMate will try to automatically configure backwards trigger to prepend shift
key infront, e.g. <s-tab> or <s-c-space>. You can manually configure backward
trigger using:
<Plug>snipMateNextOrTrigger Jumps to the next tab stop or, if none exists,
try to expand a snippet. Use in both insert
and select modes.
let g:snips_trigger_key_backwards='<c-space>'
<Plug>snipMateBack Jump to the previous tab stop, if it exists.
Use in both insert and select modes.
<Plug>snipMateShow Show all available snippets (that start with
the previous text, if it exists). Use in
insert mode.
<Plug>snipMateVisual |snipMate-visual-selection-support|
==============================================================================
FEATURES *snipMate-features*

View File

@ -14,6 +14,9 @@ if exists('loaded_snips') || &cp || version < 700
endif
let loaded_snips = 1
if !exists('snips_author') | let snips_author = 'Me' | endif
" save and reset 'cpo'
let s:save_cpo = &cpo
set cpo&vim
try
call funcref#Function('')
@ -33,6 +36,14 @@ au FileType snippet setl noet nospell
au BufRead,BufNewFile *.snippets set ft=snippets
au FileType snippets setl noet nospell fdm=expr fde=getline(v:lnum)!~'^\\t\\\\|^$'?'>1':1
inoremap <silent> <Plug>snipMateNextOrTrigger <C-R>=snipMate#TriggerSnippet()<CR>
snoremap <silent> <Plug>snipMateNextOrTrigger <Esc>a<C-R>=snipMate#TriggerSnippet()<CR>
inoremap <silent> <Plug>snipMateBack <C-R>=snipMate#BackwardsSnippet()<CR>
snoremap <silent> <Plug>snipMateBack <Esc>a<C-R>=snipMate#BackwardsSnippet()<CR>
inoremap <silent> <Plug>snipMateShow <C-R>=snipMate#ShowAvailableSnips()<CR>
" FIXME: <Plug>snipMateVisual pollutes register(s)
xnoremap <silent> <Plug>snipMateVisual s<C-O>:let g:snipmate_content_visual=getreg('1')<CR>
" config which can be overridden (shared lines)
if !exists('g:snipMate')
let g:snipMate = {}
@ -80,4 +91,7 @@ fun! BackwardSnippet()
return snipMate#BackwardsSnippet()
endf
" restore 'cpo'
let &cpo = s:save_cpo
" vim:noet:sw=4:ts=4:ft=vim

View File

@ -5,8 +5,8 @@ Snipmate & UltiSnip Snippets
This repository contains snippets files for various programming languages.
It is community-maintained and many people have contributed snippet files and other
improvements already.
It is community-maintained and many people have contributed snippet files and
other improvements already.
Contents
========
@ -82,6 +82,7 @@ to maintain snippets for a language, please get in touch.
* Markdown - [honza](http://github.com/honza)
* Ruby - [taq](http://github.com/taq)
* PHP - [chrisyue](http://github.com/chrisyue)
* Scala - [gorodinskiy](https://github.com/gorodinskiy)
Contributing notes
------------------

View File

@ -14,9 +14,9 @@ def textmate_var(var, snip):
lookup = dict(
TM_RAILS_TEMPLATE_START_RUBY_EXPR = snip.opt('g:tm_rails_template_start_ruby_expr', '<%= '),
TM_RAILS_TEMPLATE_END_RUBY_EXPR = snip.opt('g:tm_rails_template_end_ruby_expr', ' %>'),
TM_RAILS_TEMPLATE_START_RUBY_INLINE = snip.opt('g:tm_rails_template_start_ruby_inline', ' %>'),
TM_RAILS_TEMPLATE_START_RUBY_INLINE = snip.opt('g:tm_rails_template_start_ruby_inline', '<% '),
TM_RAILS_TEMPLATE_END_RUBY_INLINE = snip.opt('g:tm_rails_template_end_ruby_inline', ' %>'),
TM_RAILS_TEMPLATE_END_RUBY_BLOCK = 'end'
TM_RAILS_TEMPLATE_END_RUBY_BLOCK = '<% end %>'
)
snip.rv = lookup[var]

View File

@ -6,33 +6,33 @@ snippet forindo
# Array comprehension
snippet fora
for ${1:name} in ${2:array}
${3:// body...}
${3:# body...}
# Object comprehension
snippet foro
for ${1:key}, ${2:value} of ${3:object}
${4:// body...}
${4:# body...}
# Range comprehension (inclusive)
snippet forr
for ${1:name} in [${2:start}..${3:finish}]
${4:// body...}
${4:# body...}
snippet forrb
for ${1:name} in [${2:start}..${3:finish}] by ${4:step}
${5:// body...}
${5:# body...}
# Range comprehension (exclusive)
snippet forrex
for ${1:name} in [${2:start}...${3:finish}]
${4:// body...}
${4:# body...}
snippet forrexb
for ${1:name} in [${2:start}...${3:finish}] by ${4:step}
${5:// body...}
${5:# body...}
# Function
snippet fun
(${1:args}) ->
${2:// body...}
${2:# body...}
# Function (bound)
snippet bfun
(${1:args}) =>
${2:// body...}
${2:# body...}
# Class
snippet cla class ..
class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
@ -55,17 +55,17 @@ snippet cla class .. extends .. constructor: ..
# If
snippet if
if ${1:condition}
${2:// body...}
${2:# body...}
# If __ Else
snippet ife
if ${1:condition}
${2:// body...}
${2:# body...}
else
${3:// body...}
${3:# body...}
# Else if
snippet elif
else if ${1:condition}
${2:// body...}
${2:# body...}
# Ternary If
snippet ifte
if ${1:condition} then ${2:value} else ${3:other}
@ -76,7 +76,7 @@ snippet unl
snippet swi
switch ${1:object}
when ${2:value}
${3:// body...}
${3:# body...}
# Log
snippet log

View File

@ -50,7 +50,7 @@ snippet cs
snippet ct
<%= content_tag '${1:DIV}', ${2:content}${3:,options} %>
snippet ff
<% form_for @${1:model} do |f| %>
<%= form_for @${1:model} do |f| %>
${2}
<% end %>
snippet ffcb
@ -58,7 +58,7 @@ snippet ffcb
snippet ffe
<% error_messages_for :${1:model} %>
<% form_for @${2:model} do |f| %>
<%= form_for @${2:model} do |f| %>
${3}
<% end %>
snippet ffff
@ -78,7 +78,7 @@ snippet ffta
snippet fftf
<%= ${1:f}.text_field :${2:attribute} %>
snippet fields
<% fields_for :${1:model}, @$1 do |${2:f}| %>
<%= fields_for :${1:model}, @$1 do |${2:f}| %>
${3}
<% end %>
snippet i18

View File

@ -9,6 +9,18 @@ snippet <?e
# this one is for php5.4
snippet <?=
<?=${1}?>
snippet ?=
<?= ${1} ?>
snippet ?
<?php ${1} ?>
snippet ?f
<?php foreach ($${1:vars} as $${2:$var}): ?>
${3}
<?php endforeach ?>
snippet ?i
<?php if ($${1:var}): ?>
${2}
<?php endif ?>
snippet ns
namespace ${1:Foo\Bar\Baz};
${2}
@ -16,9 +28,9 @@ snippet use
use ${1:Foo\Bar\Baz};
${2}
snippet c
${1:abstract }class ${2:`Filename()`}
class ${1:`Filename()`}
{
${3}
${2}
}
snippet i
interface ${1:`Filename()`}
@ -34,9 +46,9 @@ snippet f
}
# method
snippet m
${1:abstract }${2:protected}${3: static} function ${4:foo}(${5:array }${6:$bar})
${1:protected} function ${2:foo}()
{
${7}
${3}
}
# setter method
snippet sm
@ -382,3 +394,12 @@ snippet rett
return true;
snippet retf
return false;
snippet am
$${1:foo} = array_map(function($${2:v}) {
${3}
return $$2;
}, $$1);
snippet aw
array_walk($${1:foo}, function(&$${2:v}, $${3:k}) {
$$2 = ${4};
});