mirror of
https://github.com/amix/vimrc
synced 2025-06-23 06:35:01 +08:00
Updated plugins and added vim-jade
This commit is contained in:
@ -1,7 +1,11 @@
|
||||
sudo: false
|
||||
language: ruby
|
||||
rvm:
|
||||
- 1.9.3
|
||||
before_install: sudo apt-get install vim-gtk
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- vim-gtk
|
||||
|
||||
before_script:
|
||||
- "export DISPLAY=:99.0"
|
||||
- "sh -e /etc/init.d/xvfb start"
|
||||
|
@ -1,17 +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)
|
||||
diff-lcs (1.2.5)
|
||||
rake (10.4.2)
|
||||
rspec (3.4.0)
|
||||
rspec-core (~> 3.4.0)
|
||||
rspec-expectations (~> 3.4.0)
|
||||
rspec-mocks (~> 3.4.0)
|
||||
rspec-core (3.4.1)
|
||||
rspec-support (~> 3.4.0)
|
||||
rspec-expectations (3.4.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.4.0)
|
||||
rspec-mocks (3.4.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.4.0)
|
||||
rspec-support (3.4.1)
|
||||
vimrunner (0.3.1)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@ -20,3 +25,6 @@ DEPENDENCIES
|
||||
rake
|
||||
rspec
|
||||
vimrunner
|
||||
|
||||
BUNDLED WITH
|
||||
1.10.6
|
||||
|
@ -13,7 +13,7 @@
|
||||
- *[Known Issues](#known-issues)*
|
||||
- [Changelog](#changelog)
|
||||
- [Contributing](#contributing)
|
||||
- [Credit](#credit)
|
||||
- [Credit](#credit)
|
||||
|
||||
###Contributors
|
||||
- [eapache](https://github.com/eapache)
|
||||
@ -138,6 +138,15 @@ normal mode will "fail to replay" when multiple cursors are active. For example,
|
||||
changing it from `{}` to `{'d':1}` makes normal-mode mappings beginning with `d`
|
||||
(such as `dw` to delete a word) work in multi-cursor mode.
|
||||
|
||||
### ```g:multi_cursor_visual_maps``` (Default: see below)
|
||||
Default value: `{'i':1, 'a':1, 'f':1, 'F':1, 't':1, 'T':1}`
|
||||
|
||||
Any key in this map (values are ignored) will cause multi-cursor _Visual_ mode
|
||||
to pause for map completion just like normal vim. Otherwise keys mapped in
|
||||
visual mode will "fail to replay" when multiple cursors are active. For example,
|
||||
changing it from `{}` to `{'i':1}` makes visual-mode mappings beginning with `i`
|
||||
(such as `it` to select an "inner tag block") work in multi-cursor mode.
|
||||
|
||||
The default list contents should work for anybody, unless they have remapped a
|
||||
key from an operator-pending command to a non-operator-pending command or
|
||||
vice versa.
|
||||
@ -150,9 +159,9 @@ such as `j` as if they were operator-pending commands can break things.
|
||||
|
||||
### ```Multiple_cursors_before/Multiple_cursors_after``` (Default: `nothing`)
|
||||
|
||||
Other plugins may trigger on keypresses when in insert mode. These plugins
|
||||
Other plugins may trigger on keypresses when in insert mode. These plugins
|
||||
generally provide a means to toggle their active state. These hooks allow
|
||||
the user to provide functions in their .vimrc to do this when multiple-cursor-mode
|
||||
the user to provide functions in their .vimrc to do this when multiple-cursor-mode
|
||||
is entered.
|
||||
|
||||
For example, if you are using [Neocomplete](https://github.com/Shougo/neocomplete.vim),
|
||||
@ -193,11 +202,6 @@ highlight link multiple_cursors_visual Visual
|
||||
|
||||
## Known Issues
|
||||
- Select mode is not implemented
|
||||
- `I` and `A` do not work in Visual mode yet (See [#55](../../issues/55))
|
||||
|
||||
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.
|
||||
|
||||
**NOTE**: Vim's Visual Block mode also supports `I` and `A` commands, however they do not work in this plugin's Visual mode at the moment. For now, to use `I` and `A`, switch to Normal mode by pressing `v` first.
|
||||
|
||||
## Changelog
|
||||
See [CHANGELOG.md](CHANGELOG.md)
|
||||
@ -219,6 +223,4 @@ Obviously inspired by Sublime Text's [multiple selection][sublime-multiple-selec
|
||||
[emacs-multiple-cursors]:https://github.com/magnars/multiple-cursors.el
|
||||
|
||||
|
||||
|
||||
[](https://bitdeli.com/free "Bitdeli Badge")
|
||||
|
||||
|
@ -268,6 +268,7 @@ function! s:Cursor.new(position)
|
||||
let obj = copy(self)
|
||||
let obj.position = copy(a:position)
|
||||
let obj.visual = []
|
||||
let obj.saved_visual = []
|
||||
" Stores text that was yanked after any commands in Normal or Visual mode
|
||||
let obj.paste_buffer_text = getreg('"')
|
||||
let obj.paste_buffer_type = getregtype('"')
|
||||
@ -332,6 +333,7 @@ endfunction
|
||||
|
||||
" Remove the visual selection and its highlight
|
||||
function! s:Cursor.remove_visual_selection() dict
|
||||
let self.saved_visual = deepcopy(self.visual)
|
||||
let self.visual = []
|
||||
" TODO(terryma): Move functionality into separate class
|
||||
call s:cm.remove_highlight(self.visual_hi_id)
|
||||
@ -409,6 +411,7 @@ function! s:CursorManager.reset(restore_view, restore_setting, ...) dict
|
||||
let self.saved_winview = []
|
||||
let self.start_from_find = 0
|
||||
let s:char = ''
|
||||
let s:saved_char = ''
|
||||
if a:restore_setting
|
||||
call self.restore_user_settings()
|
||||
endif
|
||||
@ -626,6 +629,13 @@ function! s:CursorManager.restore_user_settings() dict
|
||||
call setreg('"', s:paste_buffer_temporary_text, s:paste_buffer_temporary_type)
|
||||
endfunction
|
||||
|
||||
" Reposition all cursors to the start or end of their region
|
||||
function! s:CursorManager.reposition_all_within_region(start) dict
|
||||
for c in self.cursors
|
||||
call c.update_position(c.saved_visual[a:start ? 0 : 1])
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" Reselect the current cursor's region in visual mode
|
||||
function! s:CursorManager.reapply_visual_selection() dict
|
||||
call s:select_in_visual_mode(self.get_current().visual)
|
||||
@ -670,6 +680,9 @@ endfunction
|
||||
|
||||
" This is the last user input that we're going to replicate, in its string form
|
||||
let s:char = ''
|
||||
" This is either `I` or `A`, as input in Visual mode, that we're going to use
|
||||
" to make the appropriate transition into Insert mode
|
||||
let s:saved_char = ''
|
||||
" This is the mode the user is in before s:char
|
||||
let s:from_mode = ''
|
||||
" This is the mode the user is in after s:char
|
||||
@ -898,12 +911,34 @@ endfunction
|
||||
" to be called to continue the fanout process
|
||||
function! s:detect_bad_input()
|
||||
if !s:valid_input
|
||||
" To invoke the appropriate `<Plug>(multiple-cursors-apply)` mapping, we
|
||||
" need to revert back to the mode the user was in when the input was entered
|
||||
call s:revert_mode(s:to_mode, s:from_mode)
|
||||
" We ignore the bad input and force invoke s:apply_user_input_next
|
||||
call feedkeys("\<Plug>(multiple-cursors-apply)")
|
||||
let s:bad_input += 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Complete transition into Insert mode when `I` or `A` is input in Visual mode
|
||||
function! s:handle_visual_IA_to_insert()
|
||||
if !empty(s:saved_char) && s:char =~# 'v\|V' && s:to_mode ==# 'n'
|
||||
if s:saved_char ==# 'I'
|
||||
call s:cm.reposition_all_within_region(1)
|
||||
endif
|
||||
call feedkeys(tolower(s:saved_char))
|
||||
let s:saved_char = ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Begin transition into Insert mode when `I` or `A` is input in Visual mode
|
||||
function! s:handle_visual_IA_to_normal()
|
||||
if s:char =~# 'I\|A' && s:from_mode =~# 'v\|V'
|
||||
let s:saved_char = s:char
|
||||
let s:char = s:from_mode " spoof a 'v' or 'V' input to transiton from Visual into Normal mode
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Apply the user input at the next cursor location
|
||||
function! s:apply_user_input_next(mode)
|
||||
let s:valid_input = 1
|
||||
@ -931,6 +966,7 @@ function! s:apply_user_input_next(mode)
|
||||
call s:update_visual_markers(s:cm.get_current().visual)
|
||||
endif
|
||||
call feedkeys("\<Plug>(multiple-cursors-wait)")
|
||||
call s:handle_visual_IA_to_insert()
|
||||
else
|
||||
" Continue to next
|
||||
call feedkeys("\<Plug>(multiple-cursors-input)")
|
||||
@ -1050,8 +1086,8 @@ endfunction
|
||||
let s:retry_keys = ""
|
||||
function! s:display_error()
|
||||
if s:bad_input == s:cm.size()
|
||||
\ && s:from_mode ==# 'n'
|
||||
\ && has_key(g:multi_cursor_normal_maps, s:char[0])
|
||||
\ && ((s:from_mode ==# 'n' && has_key(g:multi_cursor_normal_maps, s:char[0]))
|
||||
\ || (s:from_mode =~# 'v\|V' && has_key(g:multi_cursor_visual_maps, s:char[0])))
|
||||
" we couldn't replay it anywhere but we're told it's the beginning of a
|
||||
" multi-character map like the `d` in `dw`
|
||||
let s:retry_keys = s:char
|
||||
@ -1124,6 +1160,7 @@ function! s:wait_for_user_input(mode)
|
||||
let s:char = s:retry_keys . s:saved_keys
|
||||
if len(s:saved_keys) == 0
|
||||
let s:char .= s:get_char()
|
||||
call s:handle_visual_IA_to_normal()
|
||||
else
|
||||
let s:saved_keys = ""
|
||||
endif
|
||||
|
@ -177,6 +177,16 @@ normal mode will "fail to replay" when multiple cursors are active. For example,
|
||||
changing it from `{}` to `{'d':1}` makes normal-mode mappings beginning with `d`
|
||||
(such as `dw` to delete a word) work in multi-cursor mode.
|
||||
|
||||
*g:multi_cursor_visual_maps* (Default: )
|
||||
|
||||
Default value: `{'i':1, 'a':1, 'f':1, 'F':1, 't':1, 'T':1}`
|
||||
|
||||
Any key in this map (values are ignored) will cause multi-cursor _Visual_ mode
|
||||
to pause for map completion just like normal vim. Otherwise keys mapped in
|
||||
visual mode will "fail to replay" when multiple cursors are active. For example,
|
||||
changing it from `{}` to `{'i':1}` makes visual-mode mappings beginning with `i`
|
||||
(such as `it` to select an "inner tag block") work in multi-cursor mode.
|
||||
|
||||
The default list contents should work for anybody, unless they have remapped a
|
||||
key from an operator-pending command to a non-operator-pending command or
|
||||
vice versa.
|
||||
|
@ -42,11 +42,14 @@ let s:settings_if_default = {
|
||||
|
||||
let s:default_insert_maps = {}
|
||||
let s:default_normal_maps = {'!':1, '@':1, '=':1, 'q':1, 'r':1, 't':1, 'T':1, 'y':1, '[':1, ']':1, '\':1, 'd':1, 'f':1, 'F':1, 'g':1, '"':1, 'z':1, 'c':1, 'm':1, '<':1, '>':1}
|
||||
let s:default_visual_maps = {'i':1, 'a':1, 'f':1, 'F':1, 't':1, 'T':1}
|
||||
|
||||
let g:multi_cursor_insert_maps =
|
||||
\ get(g:, 'multi_cursor_insert_maps', s:default_insert_maps)
|
||||
let g:multi_cursor_normal_maps =
|
||||
\ get(g:, 'multi_cursor_normal_maps', s:default_normal_maps)
|
||||
let g:multi_cursor_visual_maps =
|
||||
\ get(g:, 'multi_cursor_visual_maps', s:default_visual_maps)
|
||||
|
||||
call s:init_settings(s:settings)
|
||||
|
||||
|
@ -17,7 +17,7 @@ def before(string)
|
||||
end
|
||||
|
||||
def after(string)
|
||||
get_file_content().should eq normalize_string_indent(string)
|
||||
expect(get_file_content()).to eq normalize_string_indent(string)
|
||||
end
|
||||
|
||||
def type(string)
|
||||
@ -163,6 +163,32 @@ describe "Multiple Cursors when normal_maps is empty" do
|
||||
|
||||
end
|
||||
|
||||
describe "Multiple Cursors when visual_maps is empty" do
|
||||
let(:filename) { 'test.txt' }
|
||||
let(:options) { ['let g:multi_cursor_visual_maps = {}'] }
|
||||
|
||||
# Operator-pending commands are handled correctly thanks to their inclusion
|
||||
# in `g:multi_cursor_visual_maps`.
|
||||
#
|
||||
# When an operator-pending command like 'f' is missing from that setting's
|
||||
# value, then it should result in a no-op, but we should still remain in
|
||||
# multicursor mode.
|
||||
specify "#visual mode 'i'" do
|
||||
before <<-EOF
|
||||
hello world x
|
||||
hello world x
|
||||
EOF
|
||||
|
||||
type 'fw<C-n><C-n>fx<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello x
|
||||
hello x
|
||||
EOF
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "Multiple Cursors" do
|
||||
let(:filename) { 'test.txt' }
|
||||
let(:options) { [] }
|
||||
@ -417,6 +443,216 @@ describe "Multiple Cursors" do
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#visual mode 'i'" do
|
||||
before <<-EOF
|
||||
hi (hello world jan) bye
|
||||
hi (hello world feb) bye
|
||||
hi (hello world mar) bye
|
||||
EOF
|
||||
|
||||
type 'fw<C-n><C-n><C-n>ibcone<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hi (one) bye
|
||||
hi (one) bye
|
||||
hi (one) bye
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#visual mode 'a'" do
|
||||
before <<-EOF
|
||||
hi (hello world jan) bye
|
||||
hi (hello world feb) bye
|
||||
hi (hello world mar) bye
|
||||
EOF
|
||||
|
||||
type 'fw<C-n><C-n><C-n>abcone<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hi one bye
|
||||
hi one bye
|
||||
hi one bye
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#visual mode 'f'" do
|
||||
before <<-EOF
|
||||
hi (hello world jan) bye
|
||||
hi (hello world feb) bye
|
||||
hi (hello world mar) bye
|
||||
EOF
|
||||
|
||||
type 'fw<C-n><C-n><C-n>f)cone<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hi (hello one bye
|
||||
hi (hello one bye
|
||||
hi (hello one bye
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#visual mode 'F'" do
|
||||
before <<-EOF
|
||||
hi (hello world jan) bye
|
||||
hi (hello world feb) bye
|
||||
hi (hello world mar) bye
|
||||
EOF
|
||||
|
||||
type 'fw<C-n><C-n><C-n>F(cbefore<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hi beforeorld jan) bye
|
||||
hi beforeorld feb) bye
|
||||
hi beforeorld mar) bye
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#visual mode 't'" do
|
||||
before <<-EOF
|
||||
hello.jan
|
||||
hello hi.feb
|
||||
hello hi bye.mar
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n><C-n>t.cone<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
one.jan
|
||||
one.feb
|
||||
one.mar
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#visual mode 'T'" do
|
||||
before <<-EOF
|
||||
jan.world
|
||||
feb.hi world
|
||||
mar.bye hi world
|
||||
EOF
|
||||
|
||||
type 'fw<C-n><C-n><C-n>T.cbefore<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
jan.beforeorld
|
||||
feb.beforeorld
|
||||
mar.beforeorld
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#visual line mode 'f'" do
|
||||
before <<-EOF
|
||||
hello jan world
|
||||
hello feb world
|
||||
hello mar world
|
||||
EOF
|
||||
|
||||
type '<C-n><C-n><C-n>VfwvAafter<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello jan wafterorld
|
||||
hello feb wafterorld
|
||||
hello mar wafterorld
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#visual mode 'I'" do
|
||||
before <<-EOF
|
||||
hello world jan
|
||||
hello world feb
|
||||
hello world mar
|
||||
EOF
|
||||
|
||||
type 'w<C-n><C-n><C-n>Ibefore<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello beforeworld jan
|
||||
hello beforeworld feb
|
||||
hello beforeworld mar
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#visual mode 'A'" do
|
||||
before <<-EOF
|
||||
hello world jan
|
||||
hello world feb
|
||||
hello world mar
|
||||
EOF
|
||||
|
||||
type 'w<C-n><C-n><C-n>Aafter<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello worldafter jan
|
||||
hello worldafter feb
|
||||
hello worldafter mar
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#resize regions visual mode 'I'" do
|
||||
before <<-EOF
|
||||
hello world jan
|
||||
hello world feb
|
||||
hello world mar
|
||||
EOF
|
||||
|
||||
type 'w<C-n><C-n><C-n>hhhIbefore<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello beforeworld jan
|
||||
hello beforeworld feb
|
||||
hello beforeworld mar
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#resize regions visual mode 'A'" do
|
||||
before <<-EOF
|
||||
hello world jan
|
||||
hello world feb
|
||||
hello world mar
|
||||
EOF
|
||||
|
||||
type 'w<C-n><C-n><C-n>hhhAbefore<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello wobeforerld jan
|
||||
hello wobeforerld feb
|
||||
hello wobeforerld mar
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#no word boundries visual mode 'I'" do
|
||||
before <<-EOF
|
||||
hello hibye world
|
||||
hello hibye world
|
||||
hello hibye world
|
||||
EOF
|
||||
|
||||
vim.normal ':MultipleCursorsFind bye<CR>'
|
||||
type 'Ibefore<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello hibeforebye world
|
||||
hello hibeforebye world
|
||||
hello hibeforebye world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#variable-length regions visual mode 'I'" do
|
||||
before <<-EOF
|
||||
hello hii world
|
||||
hello hiiii world
|
||||
hello hiiiiii world
|
||||
EOF
|
||||
|
||||
vim.normal ':MultipleCursorsFind \<hi*\><CR>'
|
||||
type 'Ibefore<Esc>'
|
||||
|
||||
after <<-EOF
|
||||
hello beforehii world
|
||||
hello beforehiiii world
|
||||
hello beforehiiiiii world
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "#normal mode 'I'" do
|
||||
before <<-EOF
|
||||
hello
|
||||
|
Reference in New Issue
Block a user