Case-insensitive tag in Vim

For the most part, I find case-sensitive tag searches appropriate. Most of the languages โ€‹โ€‹we use are case sensitive, which is why this is desirable.

However, I have a DSL in my workplace that uses case sensitive identifiers. I generate tags for this DSL, and I can even sort it using flash memory (and set the corresponding flag in the tag file), but Vim still looks case sensitive for identifiers.

What would I like if Vim could understand the tag file is "case sensitive", because "this language is case insensitive." Is there such a setting?

I suggested that I could enable ignorecase for this type of file (I would disable the tag file anyway and change a few more settings), but then Vim barks at me when the case does not match. I just wanted to tell Vim: "Hey, this is not case sensitive, so everything is fine, you donโ€™t need to yell at me about that." As a rule, it seems to me desirable that Vim can simply interpret the intention with a way to sort the tag file, but perhaps this is not a widespread desire ...

+6
source share
3 answers

Ultimately, I just decided to ignorecase . I have this in my vimrc:

 autocmd BufEnter * setlocal noignorecase autocmd BufEnter *.{dsl-a,dsl-b*} setlocal ignorecase 

Annoying, but resolved; I was hoping Vim would notice the header in the tag file:

 !_TAG_FILE_SORTED 2 /0=unsorted, 1=sorted, 2=foldcase/ 

Alas, it seems that this is not so.


The other day, I ran into a problem that contains additional documentation for the masses; some of the tags I was looking for were not found, but when I looked in the tag file, they were there. Then I noticed that over the element that was skipped there were lines that had the same leading characters, but then underlined; I realized that the underscore was sorted down to letters and wondered if this could be a problem (the underscore is one of six characters that appear between the capturing Z and lowercase A, but the only ones that are valid in a C-compatible identifier).

To giggle, I manually applied the insult section so that underscores appear after the letters. I even processed a minimal test case and wrote a large error report for @vim errors, and then decided to look in the tag documentation to โ€œprovide the appropriate linkโ€. There he was buried closer to the end :help tagbsearch , that is, it is of little use to those of us who chronically hold on.

Please note that this case must be uppercase in order for this to work.

One line changes my Python script my tag file:

 if casefold: tags.sort(key=str.upper) # tag file requires case folding to be folded to upper case else: tags.sort() 
+1
source

I'm relatively new to vim, but I added this to my .vimrc , and it seems to work for me so far.

 "Tag jumping function! TagInsensitiveJump() execute ":tj /\\c" . expand("<cword>") endfunction nnoremap <C-]> :call TagInsensitiveJump()<CR> 
+2
source

This is not a good answer, but hopefully it will be one!

Will you provide more details? For example, a small working example?

My attempt here is one thing, but I'm not sure if this illustrates what you are talking about. I will also save it to gist if you want to collaborate, and maybe then we can find the answer together.

tags:

 blah a.txt 1 

a.txt:

 bLah 

The essence of the same .

Steps to play:

  • run vim
  • do :set ignorecase
  • do :tag blah
  • get message: "tag 1 of 1 or more Using a tag with a different case!"

It also looks like someone asked this question recently on the Vim user mailing list , but I don't see any answers.

+1
source

Source: https://habr.com/ru/post/896147/


All Articles