From e9c20c38ed596401ff09dd74af9d56f2212dd832 Mon Sep 17 00:00:00 2001 From: Alex Roper Date: Wed, 12 Feb 2014 14:08:11 -0500 Subject: [PATCH 1/2] Fix issue arising when used with remapped keys. This fixes an issue arising from use of normal instead of normal! inside the text object function. normal! is used in all places except one, the final gv. The result is that if a user has remapped built in VIM commands (gv, in this case), indent objects will not work correctly. --- plugin/indent-object.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/indent-object.vim b/plugin/indent-object.vim index afb8edd..f4d86dd 100644 --- a/plugin/indent-object.vim +++ b/plugin/indent-object.vim @@ -215,7 +215,7 @@ function! TextObject(inner, incbelow, vis, range, count) let s:l1 = line("'>") let s:c0 = col("'<") let s:c1 = col("'>") - normal gv + normal! gv endfunction From a930e96d227b846413a3b6788fb7d34e06cc1181 Mon Sep 17 00:00:00 2001 From: Alex Roper Date: Wed, 12 Feb 2014 14:10:17 -0500 Subject: [PATCH 2/2] Allow users to define their own mappings. This adds an option, g:indent_object_no_mappings, which users may set to prevent vim-indent-object from defining any mappings. To allow users to then define custom mappings, we add mappings for each of the objects. The default setting is to retain previous behavior, and define mappings. --- plugin/indent-object.vim | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/plugin/indent-object.vim b/plugin/indent-object.vim index f4d86dd..31294f6 100644 --- a/plugin/indent-object.vim +++ b/plugin/indent-object.vim @@ -25,16 +25,28 @@ "-------------------------------------------------------------------------------- " Mappings excluding line below. -onoremap ai :cal HandleTextObjectMapping(0, 0, 0, [line("."), line("."), col("."), col(".")]) -onoremap ii :cal HandleTextObjectMapping(1, 0, 0, [line("."), line("."), col("."), col(".")]) -vnoremap ai :cal HandleTextObjectMapping(0, 0, 1, [line("'<"), line("'>"), col("'<"), col("'>")])gv -vnoremap ii :cal HandleTextObjectMapping(1, 0, 1, [line("'<"), line("'>"), col("'<"), col("'>")])gv +onoremap IndentObject-ai :cal HandleTextObjectMapping(0, 0, 0, [line("."), line("."), col("."), col(".")]) +onoremap IndentObject-ii :cal HandleTextObjectMapping(1, 0, 0, [line("."), line("."), col("."), col(".")]) +vnoremap IndentObject-ai :cal HandleTextObjectMapping(0, 0, 1, [line("'<"), line("'>"), col("'<"), col("'>")])gv +vnoremap IndentObject-ii :cal HandleTextObjectMapping(1, 0, 1, [line("'<"), line("'>"), col("'<"), col("'>")])gv " Mappings including line below. -onoremap aI :cal HandleTextObjectMapping(0, 1, 0, [line("."), line("."), col("."), col(".")]) -onoremap iI :cal HandleTextObjectMapping(1, 1, 0, [line("."), line("."), col("."), col(".")]) -vnoremap aI :cal HandleTextObjectMapping(0, 1, 1, [line("'<"), line("'>"), col("'<"), col("'>")])gv -vnoremap iI :cal HandleTextObjectMapping(1, 1, 1, [line("'<"), line("'>"), col("'<"), col("'>")])gv +onoremap IndentObject-aI :cal HandleTextObjectMapping(0, 1, 0, [line("."), line("."), col("."), col(".")]) +onoremap IndentObject-iI :cal HandleTextObjectMapping(1, 1, 0, [line("."), line("."), col("."), col(".")]) +vnoremap IndentObject-aI :cal HandleTextObjectMapping(0, 1, 1, [line("'<"), line("'>"), col("'<"), col("'>")])gv +vnoremap IndentObject-iI :cal HandleTextObjectMapping(1, 1, 1, [line("'<"), line("'>"), col("'<"), col("'>")])gv + +if !exists("g:indent_object_no_mappings") || !g:indent_object_no_mappings + omap ai IndentObject-ai + omap ii IndentObject-ii + vmap ai IndentObject-ai + vmap ai IndentObject-ii + + omap aI IndentObject-aI + omap iI IndentObject-iI + vmap aI IndentObject-aI + vmap aI IndentObject-iI +endif let s:l0 = -1 let s:l1 = -1