guns / vim-sexp

Precision Editing for S-expressions
MIT License
612 stars 33 forks source link

Broken parenthesis closing #17

Closed remko closed 9 years ago

remko commented 9 years ago

I have a very annoying problem with the closing parenthesis magic from vim-sexp. I have the following .clj file:

(defn foo []
  (println "Hello"))

I do the following after opening the file:

No matter what I do, i can't seem to close the opening brace anymore, it always jumps to the last line.

I use MacVim 7.4, no other plugins installed (except pathogen).

guns commented 9 years ago

Hi, thanks for reporting.

This is intended behavior. There isn't much reason to delete a single bracket, but if you do it on accident you can either:

  1. Undo with u
  2. Force insertion with <C-V>)

Using the element and compound-form text objects liberally helps to avoid this situation.

HTH

guns commented 9 years ago

I'm closing this issue, but feel free to re-open if you'd like to discuss it further!

remko commented 9 years ago

Thanks.

Unfortunately, this behavior makes the plugin basically unusable for me, so I had to uninstall it. Personally, I expect my editor to follow standard behavior, i.e. i'm allowed to delete single characters like i always do, and inserting a character in edit mode effectively inserts a character.

I understand that if you rigorously follow the rules to use the sexp-specific commands to insert/delete structures, this is not a problem. However, sometimes it's easy to just do what you usually do, and this is very painful with this plugin.

guns commented 9 years ago

Personally, I expect my editor to follow standard behavior, i.e. i'm allowed to delete single characters like i always do, and inserting a character in edit mode effectively inserts a character.

You can delete any single character as you like (unlike some other S-expression plugins), and you can insert any single character with the <C-V> prefix.

Forced bracket insertion with <C-V>) isn't difficult IMHO, but I respect your preferences, which is why you can disable the insert mode mappings with:

let g:sexp_enable_insert_mode_mappings = 0

If you like vim-sexp's text objects, but don't like the normal mode commands or the insert mode commands, you can bind the text object <Plug> mappings manually:

https://github.com/guns/vim-sexp/blob/master/doc/vim-sexp.txt#L477-L579

(the xmap and omap mappings would bind the text objects to your buffer)

Finally, if you don't like the text-objects, the normal mode commands, or the insert mode commands, then I think you should stop trusting whoever recommended vim-sexp to you. :)

remko commented 9 years ago

Thanks, I will definitely try the insert mode mapping disabling. This should at least be less drastic than disabling the plugin entirely.