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

improvements for visual wrapping #35

Closed andrew-hill closed 13 years ago

andrew-hill commented 14 years ago

some ideas/random thoughts for improving/extending visual wrapping

1. using markers for inserting delimiters

not sure if it would make any difference, but just wondering if the visual mode wrapping would potentially not break redo (as the help doc says it does?) if it used <` and>` to navigate to the start and end of the visual selection to insert delimiters?

execute 'keepjumps normal! `>a' . rd
execute 'keepjumps normal! `<i' . ld

basing that assumption on another vim plugin (LatexBox) which I don't think breaks redo and provides some similar wrapping features.

2. normal-mode wrapping

Any chance of adding (optional?) normal-mode mappings which apply the wrapping to the current word so you don't have to enter visual mode to wrap a single word?

not a huge deal of course for me to add some mappings like this:

nnoremap <buffer> <Leader>( viw:call delimitMate#Visual("(")<cr>

would just be easier to have an option...

3. repeated/multiple wrappings

Would be good if the wrapping could be repeated (e.g. if you want to nest a selection in two delimiters, same or different). Not sure if this is widely useful, but there are definite cases for me wanting to insert 3 " characters in python documentation or two ``,'pairs in LaTeX, and reselecting the text 2-3 times would make it not worth using the visual wrapping. Other possible cases (though I have not had the need myself) would be wrapping in different delimiters, e.g. turninghellointo[ 'hello' ]`

Raimondi commented 14 years ago
  1. Using this breaks redo, and using two commands breaks undo.
  2. There is a popular plug-in that offers this features in normal and visual (iirc) modes, it's surround.vim. Give it a try, it's pretty nice.
  3. A count before the command could work, but it might take a while.

Many thanks for the suggestions, if something else pops-up, please, let me know.

Cheers! Israel

andrew-hill commented 14 years ago

Not sure I totally follow what you mean on 1. When you say "redo" is that the opposite of "undo" (the :redo command) or is that the repeat '.' command? The back-tick method in LatexBox doesn't break undo or redo (in the first sense) for me. It does break "repeat" but that doesn't appear to work with delimitMate anyway (at least in the way I'd expect).

and thanks for the suggestion of surround.vim, will check it out

Raimondi commented 14 years ago

My bad, I meant the repeat command "." instead of the redo command "".

Raimondi commented 13 years ago

I have ditched the visual wrapping feature, so this is never going to happen.