What does the comment "COMBAK" mean? - vim

I was looking at the vimscript syntax file in the syntax directory, and under the keyword vimTodo were the words COMBAK, FIXME, TODO, and XXX. I can figure out what FIXME and TODO mean pretty easily, and I can guess what some might use XXX for, but I have no idea what COMBAK is for.
It must have a meaning of some sort, else there would be no reason to highlight it. I get that it's a code tag, but what does it mean? My best guess so far is an abbreviation for COMEBACK, though I doubt this.
Here is what I found so far:
Googling it got me nothing of use, and a google code search for COMBAK (with or without the quotes) got 0 results. I eventually Googled codetag "COMBAK" and found a single result, which uses it as a tag in a comment twice (a [ctrl+F] will find it): http://pastebin.com/H6mjbyBh.
The program is written in Vimscript, and contains both a vimscript syntax file and vimscript indent plugin file for lisp, along with some other massive functions.

Yes, it literally means "COME BACK".

Related

What is the syntax called that's used for syntax highlighting?

My apologies if this is such a trivial question for most, but it is not readily obvious to me and I can't find an answer. I am trying to understand how to code syntax highlighting for vi, but the syntax used [for the syntax highlighting] eludes me. For example, I know that
syn match myNumber '\d\+'
hi myNumber ctermfg=blue
will highlight positive integers blue. What confuses me is the '\d\+' part. Playing around it seems that \d means digit and \+ means several? But I have no idea what this syntax is called and thus can't find any documentation that could help me. I have only found links of people using it without explanation. I can probably decipher how
'[-+]\=\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+'
means 'positive and negative numbers with decimals and exponents', but if I am to make more complex highlighting I don't know where to begin. Does anybody know of any documentation that I could use to learn this?
That's called a "regular expression" or regex (or regexp) for short. See :help pattern and :help usr_27.txt. Also see vimregex.com.

Haskell Guards and SublimeText 3

I switched over to Sublime Text 3 but now that I was coding some Haskell in ST3 I noticed something quite odd, which is the syntax highlighting logic for guards.
As you can see, when I write it this way, it highlights the first guard in white colour and the different sign in a mix of white/magenta:
Only when I use this wrong syntax (with an equal sign after the argument) it displays correctly.
Does anyone know how to fix this?
You're probably using the default Haskell syntax highlighting. I would recommend disabling the Haskell package and installing SublimeHaskell. Its syntax highlighting is much better, and it recognizes things like otherwise as being a "built-in" (it's mainly Prelude functions that are considered built-in).
If you're using the built-in Haskell highlighting, you can check that it's buggy by using the CtrlAltShiftP shortcut. Highlight each guard pipe individually and then hit this shortcut. In the status bar it'll briefly show the syntax scope names associated with the region. For the first pipe, you'll get source.haskell meta.function.type-declaration.haskell, and for the second you'll get source.haskell keyword.operator.haskell. Using SublimeHaskell's syntax you'll get source.haskell keyword.operator.haskell for both pipes. I won't say that SublimeHaskell's is perfect (try indenting an entire file after module Name where), but it's definitely better. Since the syntaxes have the same name and because SublimeHaskell comes with snippets and whatnot that cover everything that the built-in does, I recommend disabling the Haskell plugin and only leaving SublimeHaskell's syntax selectable.
(NOT SURE!!!)
I now believe this is not a bug, instead I believe this is actually ST3's way of telling you you have non-exaustive patterns in that function.
Non-exaustive: http://i.imgur.com/74o4sgp.png
Exaustive: http://i.imgur.com/M9a4TTL.png

Is there a way to elegantly comment specific lines in vim search history, similar to " in command-line history?

I am using vim to edit structured text files.
Sometimes I use search-and-replace feature, and sometimes I am better off with search, followed with a macro, in which case I have several macros at hand, and the choice of one depends upon the particular search result.
In both cases, though I have to spend some effort to arrive at an acceptable regex to satisfy my editing needs. As the regexs are often very long and sophisticated, I end up with both command-line history and search history full of my trial-and-error by-products. The correct regex is not always the last one in a series of attempts, so if I want to reuse the hard-earned regex in a similar editing situation, I have to dig through the pile again.
In search-and-replace scenario I have quickly fixed this with comments that I now put in place at the end of a would-be reusable search-and-replace command string, for example:
:%s/very_long_and_sophisticated_regex/another_long_and_sophisticated_regex/gc "comments on what this search and replace command does and how it might be reused
This way I can easily ignore the piles of stuff in my command line history and quickly find relevant re-use candidates, they are shown in different color. The commands are reusable right away, comments are ignored.
Not so with the search history, though.
Having rtfmed and searched the web, I have not found anything similar. At the moment I put quasi-comments using XXX at the end of reusable search strings, for example:
/search_string_containing_very_long_and_sophisticated_regex XXX comments on what it finds and how it might be re-used
This way I can at least find the right string for re-use, but I have to first delete 'XXX' and the comments.
I wonder if there is a more elegant way of commenting the search strings in search history, similar to command-line history.
You used the word "elegant" in your title, and that I don't have on offer. If instead you can also accept a quirky workaround that relies on Vim internals, here's one.
To restate your problem, it is possible to add comments after Ex :commands,
:AComplicatedExCommand -42 -quux " this fizzes the brobble
:HardToRememberCommand test.txt " use this to brew the framble
but the same is not possible for complicated search /queries (or ?queries).
I've just discovered that you can trick Vim by terminating your search query with a literal null byte:
/[Complicated]*regexp/^# this regexp finds all scrobbles
/another\+Rege\x*p/^# use this to search foo bars
The ^# here is a literal NUL. You can enter it by pressing CtrlV and then 000.
Vim will ignore everything after the null byte, but it'll still show the whole line in the search history, including the "comment".
You can add a regexp branch that never matches, e.g. /\%$indicator\|search string
\%$ is a special Vim atom matching the end of the file. Since that will never match when followed by the indicator text, the first branch (up to \|) will never match and therefore can represent your indicator.
I've created the TaggedSearchPattern plugin to make adding the tag and recalling it even easier.

How to correct spelling in entire file?

Spelling mistakes can be fixed by pointing the cursor on the misspelled word and pressing z= (a list appears and you can select correct word). But this will fix the mistake only once (on current word). This is not that much of us will want, most will be happy to do replacement in entire file. How can I do so?
Unsuccessful Attempt:
I got an idea of substitute that mistake with correct one (i.e. :%s/badspell/goodspell/g). But the bad part of this is, it is painful. First I need to (atleast) correct a word, then store bad spelling and corrected spelling in my buffer (brain), then write the command for substitution (chances are I will do mistake in writing bad spelling and good one.). Though its time taking too.
There's a similar question on StackOverflow which says I can solve my problem with doing :spellrepall after the correction. The only problem is I don't want to all this typing. I want to automate this everytime there is a spelling correction.
And don't suggest me about plugins.
you can set the spell on in .vimrc
set spell
or if u execute this on vim directly do in vim command mode.
:set spell
Once the spell is on, you need to know following command:
]s — move to the next mispelled word
[s — move to the previous mispelled word
zg — add a word to the dictionary
zug — undo the addition of a word to the dictionary
z= — view spelling suggestions for a mispelled word
If most of the time you're selecting the first fix from the query you can use a remap for 1z= as such:
nnoremap 1z= 1z=:spellrepall<cr>
Although I would recommend binding :spellrepall to a seperate key as many people already suggested. I highly doubt you have run out of keybindings with all those <leader> and <localleader> combos. (something like <leader>z would be a perfect candidate for this)
I don't think this can go any easier without you loosening your expectations.

Lookup a specific kind of tag in Vim

So here's my problem. I've gotten exuberant ctags working with Vim, and it works great, most of the time. One thing that still irks me though is whenever I try to search for a function that is named the same as some variable name. I sometimes get the right tag on the first try, sometimes not. Then after I pull up the list of alternate tags with :tselect, it comes up with a list of tags for both function definitions or variable definitions/assignments. (I'm in PHP so definitions and assignments are syntactically indistinguishable).
However, I notice that there's a column labeled 'kind' that has a value of 'f' or 'v', for function and variable, respectively. I can't seem to find a whole lot of information about this field, it seems like it may not be exactly standardized or widely used. My question is: can you filter tag results in Vim by "kind"?
Ideally, the default would be to search the whole tags file, but by specifying some extra flag, you could search a specific ('f' or 'v') kind only.
This is such a small problem for me as it doesn't come up THAT often, but sometimes it's the small problems that really annoy you.
You can certainly generate ctag files with any combination of php-kinds that you want (see the ouput of the command ctags --list-kinds.)
If you feel it's worth the effort you can make a vim function tagkind and bind it to a command. The tagkind function can overwrite the current tags vim variable to point at only the tag file with the kinds that you are interested in and call :tag. Optionally, it can store the previous version of the tags variable and restore it after this one call.
Unfortunately, I don't know of anyway other than this. Perhaps someone else would know.
I generate python ctags with --python-kinds=-i to exclude tags for import statements (which are useless). Maybe you could generate with --php-kinds=-v and drop a class of tags completely.
You can read :help tag-priority. Apparently the "highest-priority" tag is chosen based on some hard-coded logic.
fzf with fzf.vim has a :Tags (for the whole project) and :BTags for the current file option that generates ctags on the fly.
An issue raised on the plugin 'Skip tag kinds in :BTags and :Tags' gives the following code that you can use to only generated tags for a particular kind. I've modified the below so that it should only search for the PHP f kind.
command! BTagsEnhanced
\ call fzf#vim#buffer_tags(<q-args>, [
\ printf('ctags -f - --sort=no --php-kinds=f --excmd=number --language-force=%s %s', &filetype, expand('%:S'))], {})
Note as per my comment on the question, there is a potential Vim tagfinder.vim plugin via a blog post on Vim and Ctags: Finding Tag Definitions. But I haven't tried it.

Resources