In my Sublime Text 3 (build 3065), ES6 string interpolation backticks seem to confuse the syntax highlighting in html files. For example
console.log(`"`)
would lead the syntax highlighting to assume we have an unmatched quote here, rather than figuring this is a single quotation mark quoted by backticks - which renders the remainder of the source file useless in terms of code highlighting.
Has this been solved in an updated build or add-on?
Meanwhile I can workaround it by closing the imaginary quotation in a comment.
console.log(`"`) // "
You will need to install a separate package for syntax highlighting in Sublime. There is currently a TextMate/Sublime 2 package for this (which should work for Sublime 3) here: https://github.com/Benvie/JavaScriptNext.tmLanguage
From the Installation and Use heading:
If you haven't already, install Package Control, then select
JavaScript Next from the Package Control: Install Package dropdown
list in the Command Palette.
To set this as your default JavaScript syntax, open a javascript file,
then select View -> Syntax -> Open all with current extension as... ->
JavascriptNext.
You may also need to change the ColorScheme. Pick one from Preferences
-> Color Scheme -> JavaScriptNext.
EDIT: Original Answerer posted a more widely used highlighter in comment below. It is here:
github.com/babel/babel-sublime
Related
When I'm typing a long line and press Enter in Atom Editor, I get the following:
I would like to know to set it so when I press Enter (or something equivalent) I get something with the following flavor:
Thanks a lot in advance!!
I suggest you install an indentation package for Atom.
Try the python-indent package.
It automatically applies the PEP8 style guide for indentation when you enter a newline.
It also works when splitting method calls with many args same as your example.
Just make sure to configure the pre-included language-python package first to use "soft" tabs.
(Settings > Packages > language-python)
Sublime is able to add parentheses, brackets (curly and square), apostrophes, and quotes to highlighted text by default. I've tried but can't seem to find a way to have it remove those as well. What I'd like to be able to do is highlight some text that is surrounded by parentheses and have it remove those. Is there a good way to do that using snippets?
I suspect it can be done with use of allFollowingCharacter and allPrecedingCharacter but it seems those might be from a previous version of Sublime when those were in XML instead of the current JSON...?
Any help would be appreciated!
With surround you can do this. Install it via Package Control. (Package Control Installation)
Open the command palette:
CTRLSHIFTP on Linux and Windows,
CMDSHIFTP on Mac.
Search for Surround: delete surround and type in ( and Enter and you are done!
I'm surprised this question isn't searched more regularly!
BracketHighlighter is an excellent utility that includes convenient deleting of parenthesis. To cut to the chase, install BracketHighlighter and set bh_remove_brackets to whatever shortcut you'd like to be able to delete parentheses. Search up bh_remove_brackets in the example sublime keymap to see an example!
In Windows, using the AutoHotkey utility, it's possible to write simple scripts to expand some text in an editor of choice (e.g. Visual Studio's editor).
For example, if in Visual Studio editor I type:
d1 [TAB]
(i.e. press the keys in sequence: d,1,Tab) the above "d1" text can be replaced with one or more lines of code snippets. The mapping between "d1" and the expanded lines of code is specified in a AutoHotkey script.
This is very convenient e.g. for demos; for example: at some point if I'd like to enter a whole function body, assuming that I associated it to e.g. "d3", I can simply press d3Tab on the keyboard, and I get the function body automatically pasted in the editor in current cursor location; and I can have different code snippets associated to different key combinations, e.g.
d1 --> DoSomething() function definition
d2 --> class Foo definition
d3 --> test code xyz...
Is it possible to achieve the same goal using Vim?
In other words, I'd like to have a set of code snippets previously prepared, and I'd like to paste each one of them in my currently edited source code file in Vim, in a way similar to what I described above.
Basic expansion can be done via the built-in abbreviations, for example:
:inoreabb d1 DoSomething()<CR>{<CR><CR>}<CR><Up><Up>
Read more at :help abbreviations.
snippets are like the built-in :abbreviate on steroids, usually with parameter insertions, mirroring, and multiple stops inside them. One of the first, very famous (and still widely used) Vim plugins is snipMate (inspired by the TextMate editor); unfortunately, it's not maintained any more; though there is a fork. A modern alternative (that requires Python though) is UltiSnips. There are more, see this list on the Vim Tips Wiki.
There are three things to evaluate: First, the features of the snippet engine itself, second, the quality and breadth of snippets provided by the author or others; third, how easy it is to add new snippets.
I have previously used snipMate that does something like what you're describing.
http://www.vim.org/scripts/script.php%3Fscript_id%3D2540
How do I force vim to highlight the following environment:
\begin{dmath*}
2 + 2
\end{dmath*}
the same way as
\begin{equation*}
2 + 2
\end{equation*}
?
i.e I want the dmath environments (in its plain and starred versions) to be highlighted the same ways as the equation (plain and starred) environment.
I pasted your question into Vim, :setf tex, and then used the SyntaxAttr.vim - Show syntax highlighting attributes of character under cursor plugin to find out that the corresponding syntax group name is texMathZoneES.
Then I opened $VIMRUNTIME/syntax/tex.vim and searched for it. I didn't find that directly, but something like this:
call TexNewMathZone("E","equation",1)
Then I looked up :help ft-tex-syntax (completed from the command-line via <C-D>), and found under :help tex-math a nice documentation. With that, I created the following solution:
call TexNewMathZone("M","dmath",1)
You can put that into ~/.vim/after/syntax/tex.vim, as suggested, to make it permanent. Easy, isn't it?!
I recently upgraded to gvim 7.3 and was pleased to find markdown highlighting. I also noticed that it treats "internal" _(underscore) as a marker. For example:
I want gvim to display emphasis here
but not_here
gvim actually displays the last line in my example as 'but not_here". It looks like SO's markdown interpretation is closer to what I want.
I do not say that gvim is "wrong" because I do not know what the correct markdown implementation is. However, is there a way to configure it so that the markers should be treated as normal text if they are surrounded by non-whitespace?
The runtime files (especially if you use the old Vim 7.3.000 / 046 installer found on vim.org) aren't updated frequently. Most plugin authors publish more recent releases elsewhere, and they are only occasionally picked up by Vim.
In Tim Pope's repository, you'll find a newer version (that you can install into your ~/.vim directory) that doesn't show the problem; instead, it even highlights the single underscore character as an error.
I have found a solution, which works in the things I have tested sofar.
Copy the %vim%/syntax/markdown.vim file into %/.vim/syntax/markdown.vim and change line 63 into:
syn region markdownItalic start="\s_\S\#=" end="\S\#<=_\|_\S\#=" keepend contains=markdownLineStart
Restart vim and it should match *this* and _this_ but not_this.
EDIT: Changed information, thanks to #ZyX
I had these issues when documenting code in markdown files.
The solution I used was to put the offending sections in a codeblock with four spaces or in a code span with surrounding back ticks (`).
Try to use Github flavor markdown: https://github.com/jtratner/vim-flavored-markdown