Raimondi / delimitMate

Vim plugin, provides insert mode auto-completion for quotes, parens, brackets, etc.
http://www.vim.org/scripts/script.php?script_id=2754
1.98k stars 117 forks source link

Adding closing chars twice with MacVim #63

Closed MSch closed 12 years ago

MSch commented 13 years ago
  1. Switch to insert mode
  2. Type "qwewqe{asdasd
  3. Press <Command-Right> to move to end of line
  4. Press Esc
  5. See that an additional }" gets added
travisjeffery commented 13 years ago

I keep running into the problem as well.

BRMatt commented 13 years ago

Ditto, I tend to run into this problem a lot when using the arrow keys to move around the document. Here's my version of gvim:

matt@matt-lappy:~/www/(develop)$ gvim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Mar 24 2011 07:07:00)
Included patches: 1-35
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by buildd@
Huge version with GTK2 GUI.  Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent 
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff 
+digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi 
+file_in_path +find_in_path +float +folding -footer +fork() +gettext 
-hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall 
+linebreak +lispindent +listcmds +localmap +lua/dyn +menu +mksession 
+modify_fname +mouse +mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm 
+mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme 
+netbeans_intg -osfiletype +path_extra +perl/dyn +persistent_undo +postscript 
+printer +profile +python/dyn +python3/dyn +quickfix +reltime +rightleft +ruby 
+scrollbind +signs +smartindent -sniff +startuptime +statusline -sun_workshop 
+syntax +tag_binary +tag_old_static -tag_any_white +tcl +terminfo +termresponse
 +textobjects +title +toolbar +user_commands +vertsplit +virtualedit +visual 
+visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup 
+X11 -xfontset +xim +xsmp_interact +xterm_clipboard -xterm_save 
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/libdrm -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pixman-1     -Wall -g -O2 -D_FORTIFY_SOURCE=1    -I/usr/include/tcl8.4  -D_REENTRANT=1  -D_THREAD_SAFE=1  -D_LARGEFILE64_SOURCE=1  -I/usr/lib/ruby/1.8/i686-linux -DRUBY_VERSION=18 
Linking: gcc -L/usr/lib/i386-linux-gnu    -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic  -Wl,-E  -Wl,--as-needed -o vim   -pthread -L/usr/lib/i386-linux-gnu -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0   -lXt -lncurses -lselinux   -lacl -lgpm -Wl,-E  -fstack-protector -L/usr/local/lib  -L/usr/lib/perl/5.10/CORE -L/usr/lib -ltcl8.4 -lieee -lruby1.8 -lrt -lm   

Output of :DelimitMateTest:

delimitMate Report
==================

* Options: ( ) default, (g) global, (b) buffer

( ) delimitMate_apostrophes = ''
( ) delimitMate_autoclose = 1
( ) delimitMate_balance_matchpairs = 0
( ) delimitMate_excluded_ft = ''
( ) delimitMate_excluded_regions = 'Comment'
(g) delimitMate_expand_cr = 1
(g) delimitMate_expand_space = 1
( ) delimitMate_matchpairs = '(:),{:},[:]'
( ) delimitMate_nesting_quotes = []
( ) delimitMate_quotes = '" '' `'
( ) delimitMate_smart_matchpairs = '^\%(\w\|\!\|£\|\$\|_\|["'']\s*\S\)'
( ) delimitMate_smart_quotes = 1
--------------------

* Mappings:

<S-Tab>: is not set:
i  <S-Tab>     * <C-R>=BackwardsSnippet()<CR>
    Last set from ~/.vim/bundle/snipmate/after/plugin/snipMate.vim
<CR>: is not set:
i  <CR>          <CR><Plug>DiscretionaryEnd
    Last set from ~/.vim/bundle/endwise/plugin/endwise.vim
--------------------

* Showcase:

Open: (|)
Delete: |
Exit: ()|
Space: ( | )
Delete space: (|)
Car return: (
|)
Delete car return: (|)

Open: {|}
Delete: |
Exit: {}|
Space: { | }
Delete space: {|}
Car return: {
|}
Delete car return: {|}

Open: [|]
Delete: |
Exit: []|
Space: [ | ]
Delete space: [|]
Car return: [
|]
Delete car return: [|]

Open: "|"
Delete: |
Exit: ""|
Space: " | "
Delete space: "|"
Car return: "
|"
Delete car return: "|"

Open: '|'
Delete: |
Exit: ''|
Space: ' | '
Delete space: '|'
Car return: '
|'
Delete car return: '|'

Open: `|`
Delete: |
Exit: ``|
Space: ` | `
Delete space: `|`
Car return: `
|`
Delete car return: `|`

--- Options ---
  autoread            cursorline          foldmethod=indent   history=1000        incsearch         nomodeline            number              scroll=23           showmatch         noswapfile            wildmenu
  background=dark   nofoldenable          helplang=en         hlsearch            laststatus=2        modified            numberwidth=3       shiftwidth=4        showtabline=2       tabstop=4           window=48
  binary              foldlevel=9         hidden              ignorecase          list                mouse=a             ruler               showcmd             smartcase           textwidth=80
  backspace=indent,eol,start
  backupdir=~/.backup,.
  cinoptions=:0,(s,u0,U1,g0,t0
  completeopt=menuone,preview
  directory=~/.backup,~/tmp,.
  fileencodings=ucs-bom,utf-8,default,latin1
  formatoptions=qrn1
  guifont=DejaVu Sans Mono 8
  guioptions=aegimrLt
  isfname=@,48-57,/,.,-,_,+,,,#,$,%,~,=,:
  listchars=tab:▷⋅,trail:·
  omnifunc=syntaxcomplete#Complete
  printoptions=paper:a4
  runtimepath=~/.vim,~/.vim/bundle/ack.vim,~/.vim/bundle/align,~/.vim/bundle/autocomplpop,~/.vim/bundle/coffee-script-syntastic,~/.vim/bundle/command-t,~/.vim/bundle/conque_0.5,~/.vim/bundle/cucumber,~/.vim/bundle/delimitMate,~/.vim/bundle/earendel,~/.vim/bundle/endwise,~/.vim/bundle/fugitive,~/.vim/bundle/greplace,~/.vim/bundle/haml,~/.vim/bundle/json,~/.vim/bundle/kwdbi,~/.vim/bundle/local-snippets,~/.vim/bundle/markdown,~/.vim/bundle/minibufexpl,~/.vim/bundle/misc-lang-settings,~/.vim/bundle/mustache,~/.vim/bundle/nerdcommenter,~/.vim/bundle/nerdtree,~/.vim/bundle/pastie,~/.vim/bundle/puppet,~/.vim/bundle/rails,~/.vim/bundle/rcov,~/.vim/bundle/repeat,~/.vim/bundle/sessionman,~/.vim/bundle/showmarks,~/.vim/bundle/snipmate,~/.vim/bundle/space,~/.vim/bundle/surround,~/.vim/bundle/syntastic,~/.vim/bundle/taglist,~/.vim/bundle/tmux,~/.vim/bundle/unimpaired,~/.vim/bundle/vim-coffee-script,~/.vim/bundle/vim-indentobject,~/.vim/bundle/vim-textobj-rubyblock,~/.vim/bundle/vim-textobj-user,~/.vim/bundle/vividchalk,~/.vim/bundle/yankding,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim73,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/bundle/snipmate/after,~/.vim/after
  statusline=%<%1*%f%* %h%m%r%#warningmsg#%{SyntasticStatuslineFlag()}%*%=%-14.(%l,%c%V%) %P
  suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
  termencoding=utf-8
  wildignore=.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif
filetype detection:ON  plugin:ON  indent:ON
--------------------

If needed my dotvim files are on github

bittersweet commented 13 years ago

I don't mean to sound too pedantic but you really shouldn't be going anywhere near arrow keys or in this case even OS specific bindings. I did for a time and shaking the habit has proven quite useful with editing on remote servers etc. Although I haven't managed to shake command-w to close windows with MacVim.

skalnik commented 13 years ago

I've been seeing this too.

@bittersweet You're totally right, this is something that users should be avoiding in vim. That being said, I still feel like this shouldn't happen as a punishment for using your arrow keys or OS specific key bindings :)

MSch commented 13 years ago

So does anyone of you have any idea on how to start fixing this behavior?

randy909 commented 13 years ago

This seems to be the same issue as this: https://github.com/Raimondi/delimitMate/issues/43

and this: https://github.com/Raimondi/delimitMate/issues/69

The basic issue seems to be getting extra closing characters after hitting escape. Maybe removing the mapping for the ESC key from the plugin would help...

Would you ever want it to insert anything after you hit escape? If not it would seem like a fairly easy fix.

MSch commented 12 years ago

I've fixed the issue in my fork: MSch@aff97432695ca179188db282e63903d6539b7718

This fixes it for Control-Left/Right, I didn't want to add Alt-Left/Right here since it's MacVim specific AFAIK.

So instead I added this to my gvimrc: https://github.com/MSch/dotvim/blob/7d80ca5/gvimrc#L13-17

skalnik commented 12 years ago

Nice! I didn't realize it was such a simple addition @MSch. Send @Raimondi a pull request!

Raimondi commented 12 years ago

I won't merge that fix because the issue is related to MacVim only. This should go into the (g)vimrc.

@MSch : Thanks for sharing the fix!