I'm learning data structure. I tried coding to assist my learning. Sometimes I need to highlight some keywords in pseudo code ("SeqList","SqList","ElemType") as the color of the preset keywords ("int").
I do know I can add keywords in vim, for example, : syn keyword type seqlist, could dye the word "seqlist" as "int". But I wonder if mainstream editors (vscode, clion, Xcode, sublime) can achieve this?
I used VIM for some days to highlight the keywords defined by myself, using syntax keyword and syntax match
Related
Emacs newbie here. I have recently switched to (Doom) Emacs and decided to add syntax highlighting to V files. There's already a mode that does that (vlang-mode), but I didn't like it, so I decided to make my own one. The problem is, that, as you probably know, Emacs' regex doesn't support lookaround, which I find essential for stuff like (proper) function higlighting, among others.
So, I have found info about Font Lock mode and (in general words) how to use it. Also, I found a solution to regex problem in using visual-regexp-steroids. The only problem is, I can't figure out how to apply highlighting to regions that it finds.
Links to learning resources would be appreciated.
I am developing my own Domain Specific Language (DSL) and the filename extension is .xyz.
Emacs doesn't know how to highlight syntax in .xyz files so I uausally turn on typescript-mode or json-mode. But the available syntax highlight mode is not good enough for me, so I am considering writing my own syntax highligher for Emacs editor. Any tips on this task? Any toolkit recommendation?
Alternatively, I would be happy with any available mode that highlights common keywords such as class, string, list, variables before =sign and after # sign, braces {}, brackets [], question mark ? and exclamation mark !. Any existing languages have similar syntax?
I am not color-blind and not picky on colors. Any syntax highligher that highlights above syntax can solve my problem.
If you are satisfied with simple syntax highlighting for keywords and comments only, there is a helper for this called define-generic-mode, which is documented in the elisp manual.
Some examples of using it can be found in generic-x.el distributed with Emacs.
But highlighting of variable names is not covered by this. For that, you need to be able to parse the DSL using semantic/bovine, as whether a particular string is interpreted as a variable name depends on context, and not just simple regexp matching.
I want my emacs to globally replace
:>>:
with
»
during typing. Any other typing combination is ok, too. I just chose :...: because that made it easier for emacs to descern the "name" of the replacement. I have a couple of sequences I want to be replaced in this way, i.e.
:>>: with »
:<<: with «
:e/: with e-accent-acute
:e\: with e-accent-grave
and so on.
Maybe there is a mechanism in emacs I can use. But googling did not get anything useful, I probably did not use the right search terms.
One big issue seems to be that the » in question is a unicode char and the .emacs-file has problems with that?
Emacs supports many Input Methods (doc here).
For example, with the latin-1-prefix input method, you can type `e to get the grave accented e; ~< will give you the opening guillemet.
Call set-input-method and select latin-1-prefix for this.
The function describe-input-method will show you complete help for your current input method.
Another interesting input method is TeX, which substitutes TeX symbols on the fly, such as \Delta, ^1, ~n, etc.
Answer to related question here. Nice tutorials here or here.
Use Abbrev Mode. Set :>>: to map to » etc.. The mode will automatically substitute. To do this, edit the abbrev file to include your mapping, or simply create the mapping in Emacs and save it with M-x write-abbrev-file.
p.s. I think Emacs is Unicode safe ATM. I've been using various Unicode characters for a long time.
My NetBeans dictionary is kind of... illiterate? It's flagging words like "website" and the "doesn" part of doesn't. I right-clicked expecting to see your standard Add to dictionary... option but found none. I browsed the menus and also found nothing.
How do I educate my NetBeans spellchecker?
It looks like the spell checker is a relatively recent addition. There are basic instructions on how to change the dictionary here.
Adding an unknown word to the dictionary requires alt + enter while the cursor is on the 'misspelled' word. This might take care of the most glaring omissions.
If it highlights just 'doesn', then it probably isn't aware of English-style contractions (i.e., it doesn't know that words can span across an apostrophe). Until that is fixed, I would recommend just adding 'doesn' as a separate word using the above method.
There's a lot of Text editors which support autocomplete during programming, but I want one which can autocomplete while typing normal text as I see a lot of repetition of words I type. Any emacs fans who have implemented this ?
Try the builtin dabbrev-expand; it's bound to M-/.
Also see Predictive Mode if you fancy the more flashy stuff.
pabbrev-mode (predictive abbreviation) works by examining previously written text. Unlike dynamic abbreviation, the text is analyzed during idle time (which enables quick lookup of potential abbreviations). Pabbrev looks at word frequency to suggest the most common expression.
From the documentation, this is what it might look like as you typed the keys pred.
p[oint]
pr[ogn]
pre[-command-hook]
pred[ictive]
I love hippie-expand!
The Zeus editor has a non-programming auto complete feature (i.e. Alt + Space) that takes the current user input, searches the current file for words starting with that input and displays them in a drop down list.
vim has such a feature http://vim.wikia.com/wiki/VimTip4
i think ultra edit has a simmilar feature
You could set up auto-complete mode with a dictionary as your source. I have been very tempted to do this myself.
predictive-mode auto-completes from a dictionary of words. It learns which words you use most often, and can also automatically learn new words as you type if desired.
It's very fast, fast enough that turning on auto-completion doesn't cause any noticeable lag when typing, even with a large dictionary.
(Disclaimer: I'm the author of predictive-mode)