vim-textobj-quote icon indicating copy to clipboard operation
vim-textobj-quote copied to clipboard

Need instructions for "Configurable to support international variations in quotation marks"

Open boydkelly opened this issue 4 years ago • 5 comments

In French also there is a non breakable space between the quote mark and text. I just tried as a test to put u00a0 twice between the french quotes as below but it did' work. autocmd FileType *.adoc call textobj#quote#init({ 'double':'« »', 'single':'«»', 'educate': 1 }) Can textobj help me out here? Or any other suggestions?

boydkelly avatar May 02 '20 08:05 boydkelly

I use vim-surround which handles (with and without) whites-pace inside parenthesis/brace/bracket/caret text objects (( example ) and (example)), so there must be a way to do this. I don't think this plugin is setup to do it now but somehow somebody should implement this for French!

alerque avatar May 02 '20 20:05 alerque

Hi Caleb. Thanks for the comment. Just an FYI, I got something working; I found this mapping on an old 2011 forum post. http://vim.1045645.n5.nabble.com/Function-to-write-correctly-French-quotation-marks-td4259054.html

function! LanguageSettings()
      if &spelllang =~ 'fr'
         set keymap=french 
         :imap <expr> " getline('.')[col('.')-2]=~'\S' ?  ' »' : '« '
         :imap <expr> ' getline('.')[col('.')-2]=~'\S' ?  ' »' : '« '
      elseif &spelllang =~ 'en'
         :silent! iunmap  "
         :silent! iunmap  '
      endif
endfunction 

To complete this in my French keymap, I have the mappings for the question mark and exclamation mark including the nonbreakable space which also works fine:

loadkeymap
?   ?
!   !

My only issue now is I can't seem to get everything in one place. The keymap file doesn't seem to support an expression as with imap. And if I try to load the ?! mappings with imap (that include a tab and u-00a0 it totally hangs my terminal. Anyways it is possible now for me to painlessly type in French with my favorite editor! Cheers!

boydkelly avatar May 04 '20 12:05 boydkelly

I think that this is out of scope for this plugin.

I'd like to close the issue with a pointer to vim-sandwich, which could maybe handle something like what the OP wanted.

/ping @alerque

telemachus avatar Feb 09 '22 22:02 telemachus

I'm not quite sure why this would be out of scope? Or perhaps I misunderstand what the OP wanted. Is the problem just that French quote styles include two characters on each end instead of one? Other than the series of glyphs used what is fundamentally different about what they want to accomplish?

alerque avatar Feb 10 '22 06:02 alerque

Sorry, I wasn't clear. By "out of scope," I meant that I didn't think that we would implement this directly in the plugin itself.

On the README, we offer advice about non-English quote characters, but I didn't think that we would ever directly implement them in the plugin. (We could, but so far nobody seems to have taken on that work.)

That said, I was mostly trying to clean up the issues that seemed stale to me. If you want to leave this open to gather other suggestions or as a note for a future enhancement, that makes sense too.

telemachus avatar Feb 10 '22 11:02 telemachus