Skip to content
Browse files

Make ',' and ';' work as documented (fixes #5)

  • Loading branch information...
1 parent 23ddb00 commit a40bdb4a2bd6e516d9b7f358b75cd0012d81265c @chrisbra committed Jun 6, 2015
Showing with 19 additions and 18 deletions.
  1. +1 −0 .gitignore
  2. +2 −1 README
  3. +11 −16 autoload/ftimproved.vim
  4. +5 −1 doc/ft_improved.txt
View
1 .gitignore
@@ -6,3 +6,4 @@ vim_passfile
*.vba
# ignore *.orig files
*.orig
+*.vmb
View
3 README
@@ -33,7 +33,8 @@ Functionality
This plugin tries to improve the existing behaviour of the |f|, |F|, |t| and
|T| command by letting them move the cursor not only inside the current line,
but move to whatever line, where the character is found. Also the |,| and |;|
-command should just work as expected.
+command should consistently by default, but can be enabled to work as usual
+(see |improvedft-consistent_comma|).
It does consider counts given and should work simply as a user would be
expecting.
View
27 autoload/ftimproved.vim
@@ -82,13 +82,13 @@ fun! <sid>ColonPattern(cmd, pat, off, f, fwd) "{{{1
fun! <sid>ColonPattern(cmd, pat, off, f, fwd) "{{{1
if !exists("s:colon")
let s:colon = {}
- endif
endif
+ let cmd = a:cmd
let pat = a:pat
let opp = <sid>Opposite(a:cmd[-1:])
- let opp_off = <sid>Opposite(a:off[0])
+ let opp_off = <sid>Opposite(a:off[0])
if a:cmd ==# 'f' || a:cmd ==# 't'
- let cmd = '/'
+ let cmd = '/'
elseif a:cmd == 'F' || a:cmd ==# 'T'
let cmd = '?'
endif
@@ -203,11 +203,7 @@ fun! ftimproved#ColonCommand(f, mode) "{{{1
" a:f f/F command, a:mode: map mode
if !exists("s:searchforward")
let s:searchforward = 1
- endif
- if s:searchforward
- let fcmd = (a:f ? ';' : ',')
- else
- let fcmd = (!a:f ? ';' : ',')
+ endif
let fcmd = (a:f ? ';' : ',')
if !exists("s:colon")
let s:colon={}
@@ -218,13 +214,13 @@ fun! ftimproved#ColonCommand(f, mode) "{{{1
let res = ''
let res = (empty(s:colon[fcmd]) ? fcmd : s:colon[fcmd])
- if get(g:, 'ft_improved_consistent_comma', 0)
- let fcmd = (a:f ? ',' : ';')
- if (a:f && res[0] !=? '/')
- let res = (empty(s:colon[fcmd]) ? fcmd : s:colon[fcmd])
- elseif (!a:f && res[0] !=? '?')
+ if get(g:, 'ft_improved_consistent_comma', 0)
+ if a:f
+ let res = '/'.res[1:-2]. '/'
+ else
let res = '?'.res[1:-2]. '?'
endif
+ endif
let oldsearchpat = @/
if a:mode =~ 'o' &&
@@ -238,7 +234,7 @@ fun! ftimproved#ColonCommand(f, mode) "{{{1
" ?-search, means, we need to escape '?' in the pattern
let spat = pat[2]
if pat[1] =~ '[?/]'
- let pat[2] = escape(pat[2], pat[1])
+ let pat[2] = escape(pat[2], pat[1])
if !s:colon['cmd'] && pat[1] == '?'
" T command
let res = pat[1]. '\('. pat[2]. '\m\)\@<=.' . pat[1]
@@ -279,6 +275,7 @@ fun! ftimproved#FTCommand(f, fwd, mode) "{{{1
" f: its an f-command
" fwd: forward motion
" mode: mapping mode
+ try
let s:searchforward = a:fwd
let char = nr2char(getchar())
if char == s:escape
@@ -351,15 +348,13 @@ fun! ftimproved#FTCommand(f, fwd, mode) "{{{1
if !get(g:, "ft_improved_multichars", 0)
" Check if normal f/t commands would work:
if search(matchstr(pat.'\C', '^\%(\\c\)\?\zs.*'), 'nW') == line('.')
- \ && a:fwd
\ && a:fwd
let cmd = (a:f ? 'f' : 't')
call <sid>ColonPattern(<sid>SearchForChar(cmd),
\ pat, '', a:f, a:fwd)
return <sid>DebugOutput(cmd.orig_char)
elseif search(matchstr(pat.'\C', '^\%(\\c\)\?\zs.*'), 'bnW') == line('.')
- \ && !a:fwd
\ && !a:fwd
let cmd = (a:f ? 'F' : 'T')
call <sid>ColonPattern(<sid>SearchForChar(cmd),
View
6 doc/ft_improved.txt
@@ -33,7 +33,8 @@ Functionality
This plugin tries to improve the existing behaviour of the |f|, |F|, |t| and
|T| command by letting them move the cursor not only inside the current line,
but move to whatever line, where the character is found. Also the |,| and |;|
-command should just work as expected.
+command should consistently by default, but can be enabled to work as usual
+(see |improvedft-consistent_comma|).
It does consider counts given and should work simply as a user would be
expecting.
@@ -176,6 +177,9 @@ third line of this document.
==============================================================================
4. History *improvedft-history*
+0.10: (unreleased) "{{{
+- Make |,| and |;| work as documented (reported by JonnyRa in
+ https://github.com/chrisbra/improvedft/issues/5, thanks!)
0.9: Jan 15, 2015 "{{{
- do not mess up highlighting for |;| and |,| commands
- make count work correctly with multi-highlight match, so that only the

0 comments on commit a40bdb4

Please sign in to comment.
Something went wrong with that request. Please try again.