Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
adinapoli committed Nov 25, 2012
2 parents 8df7ded + 7d9ceaa commit 8f2b099
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 38 deletions.
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright (C) 2012 Alfredo Di Napoli

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.

Vim, arguably the best text-editor in the world.

Inspired from magnars' mark-multiple plugin.
65 changes: 27 additions & 38 deletions plugin/markmultiple.vim
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
" Copyright (C) 2012 Alfredo Di Napoli
"
" 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.
"
" Vim, arguably the best text-editor in the world.
"
" Inspired from magnars' mark-multiple plugin.
"
if exists("g:loaded_mark_multiple") || &cp
finish
endif

let g:loaded_mark_multiple = 1
let s:keepcpo = &cpo
set cpo&vim

if !exists("g:mark_multiple_started")
let g:mark_multiple_started = 0
Expand Down Expand Up @@ -51,12 +33,14 @@ endif

" Leave space for user customization.
if !exists("g:mark_multiple_trigger")
let g:mark_mutiple_trigger = "<C-n>"
let g:mark_multiple_trigger = "<C-n>"
endif


:execute "nnoremap ". g:mark_mutiple_trigger ." :call MarkMultiple()<CR>"
:execute "vnoremap ". g:mark_mutiple_trigger ." :call MarkMultiple()<CR>"
if g:mark_multiple_trigger != ''
:execute "nnoremap ". g:mark_multiple_trigger ." :call MarkMultiple()<CR>"
:execute "xnoremap ". g:mark_multiple_trigger ." :call MarkMultiple()<CR>"
endif
au InsertLeave * call MarkMultipleSubstitute()


Expand Down Expand Up @@ -105,26 +89,26 @@ fun! MarkMultipleSetCursor()

" Try to match an enclosing bracket/tag. If
" nothing changes, I'm (almost) sure I'm on a plain word.
normal %
normal! %
if getpos('.')[2] == original_position[2]
:execute "normal F "
normal l
:execute "normal! F "
normal! l
let g:mark_multiple_curpos = original_position
return
endif

" If moved two are the cases:
" It went forward to the next bracket/tag. In that case, fallback
" It went forward to the next bracket/tag. In that case, fall back
" to the original position.
if getpos('.')[2] > original_position[2]
call setpos('.', original_position)
:execute "normal F "
normal l
:execute "normal! F "
normal! l
let g:mark_multiple_curpos = original_position
return

else
normal l
normal! l
let g:mark_multiple_curpos = getpos('.')
return
endif
Expand Down Expand Up @@ -154,11 +138,10 @@ fun! MarkMultipleNormal()
if g:mark_multiple_started
let g:mark_multiple_searching = 1
"Go to the next word
\<Esc>
call setpos('.', g:mark_multiple_curpos)

"Search for the next word, but disable search highlighting
normal *
normal! *
nohlsearch
endif

Expand Down Expand Up @@ -205,7 +188,7 @@ endfunction

fun! MarkMultipleValidSubstitution(chars_on_the_line)

"Exploit the lenght of the prev line to determine if
"Exploit the length of the prev line to determine if
"something was changed
let prev_chars = g:mark_multiple_current_chars_on_the_line
if a:chars_on_the_line <= (prev_chars - len(g:mark_multiple_word))
Expand All @@ -222,5 +205,11 @@ endfunction


fun! SelectWord()
normal viw
silent! normal! zO
normal! viw
endfunction

let &cpo = s:keepcpo
unlet s:keepcpo

" vim: et sw=4

0 comments on commit 8f2b099

Please sign in to comment.