How to make Emmet on Notepad++ treat extension .xslt as language XSLT? - xslt

When file extension is .xsl everything is good, but with .xslt it falls back to default: html, so I cannot expand XSLT code.
I believe it does not look at file extension, because for whatever file, if you choose CSS as syntax highlight, you can expand CSS, eg: 'va' expands to 'vertical-align: top;'; if you choose any other syntax highlight, 'va' expands to ''.
The problem is I am already using XML syntax highlight for both .xsl and .xslt . I tried to edit the config file C:\Program Files (x86)\Notepad++\plugins\EmmetNPP\emmet\snippets.json but there was just no difference.

You can edit langs.xml. It has all the default associations between languages and extensions. Located in C:\Users\yourUserName\AppData\Roaming\Notepad++\langs.xml.

Related

vimscript syntax highlighting: highlight longlines greater than &textwidth set value

I want to highlight lines that are longer than the set textwidth so that it is dynamic for different filetypes. I have the following:
autocmd BufEnter * highlight OverLength ctermbg=darkgrey guibg=#592929
autocmd FileType * execute 'match OverLength /%\{'.&textwidth.',}v.*/'
This code doesn't seem to activate the highlighting, however, the following does work:
autocmd BufEnter * highlight OverLength ctermbg=darkgrey guibg=#592929
autocmd BufEnter * match OverLength /\%>90v.\+*/
I have tried excluding the execute statement and adding the backslashes accordingly but I still cannot seem to get this to work. Also, I think using the execute statement makes this code cleaner. I would appreciate it if someone could explain to me what I am doing incorrectly.
I have referenced the following examples in pursuit of the answer:
highlight long lines
expand a variable in regular expression
If there is a more portable and cleaner way to go about this then please let me know. I am trying to learn as much as possible.
ANSWER:
What I ended up doing is utilizing vim's vim/after/ftplugin folder hierarchy and adding:
set textwidth=100
let &colorcolumn=join(range(&textwidth+1,999),",")
to each filetype.vim file e.g. markdown.vim, java.vim, vim.vim
And for help.vim and man.vim files I didn't want colorcolumn highlighting so I changed the textwidth in those files to 999. By doing this vim was able to distinguish between different file types when they were open in the same session.
What I ended up doing is utilizing vim's vim/after/ftplugin folder hierarchy and adding:
set textwidth=100
let &colorcolumn=join(range(&textwidth+1,999),",")
to each filetype.vim file e.g. markdown.vim, java.vim, vim.vim
And for help.vim and man.vim files I didn't want colorcolumn highlighting so I changed the textwidth in those files to 999. By doing this vim was able to distinguish between different file types when they were open in the same session.
– user2904000

Sublime C++ namespace keyword color scheming

I am having an annoying behavior in Sublime.
When I start typing out the line...
using namespace SomeNamespace;
The keywords 'using' and 'namespace' are properly colored the keyword coloring. Then when I add the semicolon to the end of the line, the namespace keyword goes white (default text color). I know this is not that significant, but it really annoys me.
Has anyone noticed this behavior before? The code compiles without errors or warnings, so I know sublime is not detecting some so of code problem.
Does anyone have any suggestions on how to fix this problem?
The problem is in this particular regex in the C++ syntax definition:
\b(namespace)\s+([A-Za-z_][_A-Za-z0-9:]*\b)?+(?!\s*?(;|=|,))
At the very end, in the negative lookahead - (?!...) - we see that semicolons are excluded from the match, meaning that if a semicolon is present at the very end of the line, there's no match.
To fix it, you'll need to install the very useful PackageResourceViewer plugin from Package Control. Then, open the Command Palette, type prv to bring up the PackageResourceViewer options, select the Extract Package one, then scroll down and select C++. There will now be a C++ directory in the directory opened by choosing Preferences -> Browse Packages.... Go into that directory and you'll see a bunch of files. Depending on what version of Sublime Text 3 you're using, you'll want to open either C++.tmLanguage or C++.sublime-syntax in Sublime. The .tmLanguage format is XML, so you can pick that for syntax highlighting if you wish, while the .sublime-syntax file is in YAML.
Once the appropriate file is open (you'll either have one or the other, not both), search for the regex above, or just search for namespace, you should find it pretty easily. Delete the ;| from near the end, making the whole thing:
\b(namespace)\s+([A-Za-z_][_A-Za-z0-9:]*\b)?+(?!\s*?(=|,))
Save the file, and that's it! Your C++ source files should update their behavior immediately - if not, just close and reopen them, and in the worst case you can just close them, restart Sublime, then reopen them.

Applescript to extract the Digital Object Identifier (DOI) from a PDF file

I looked for an applescript to extract the DOI from a PDF file, but could not find it. There is enough information available on the actual format of the DOI (i.e. the regular expression), but how could I use this to get the identifier from the PDF file?
(It would be no problem if some external program were used, such as Hazel.)
If you're ok with using an app, I'd recommend Skim. Good AppleScript support. I'd probably structure it like this (especially if the document might be large):
set DOIFound to false
tell application "Skim"
set pp to pages of document 1
repeat with p in pp
set t to text of p
--look for DOI and set DOIFound to true
if DOIFound then exit repeat--if it's not found then use url?
end repeat
end tell
I'm assuming a DOI would always exist on one page (not spread out to between two). Looks like they are invariably (?) on the first page of an article, which would make this quick of course, even with a large doc.
[edit]
Another way would be to get the Xpdf OSX binaries from http://www.foolabs.com/xpdf/download.html and use pdftotext in the command line (just tested this; it works well) and parse the text using AppleScript. If you want to stay in AppleScript, you can do something like:
do shell script "path/to/pdftotext 'path/to/pdf/file.pdf'"
which would output a file in the same directory with a txt file extension -- you parse that for DOI.
Have you tried it with pdfgrep? It works really well in commmandline
pdfgrep -n --max-count 1 --include "*.pdf" "DOI"
i have no idea to build an apple script though, but i would be interested in one also. so that if i drop a pdf into that folder it just automatically extracts the DOI and renames the file with the DOI in the filename.

Arbitrary file syntax in WebStorm 7

Is it possible to set syntax for currently opened file to any arbitrary type? The way you can do it in Sublime? Or the syntax highlighting always determined based on the file extension?
Not currently possible. Please see IDEA-103297. The highlighting is based on extensions indeed - or, more exactly, on the patterns specified for each file type in Settings/File types.

Export a specific line in Notepad++

I have a large XHTML file that contains a lot of code, see the below example:
<a:CreationDate>0</a:CreationDate>
<a:Creator/>
<a:ModificationDate>0</a:ModificationDate>
<a:Modifier/>
<a:name>stack</a:name>
<a:CreationDate>0</a:CreationDate>
<a:Creator/>
<a:ModificationDate>0</a:ModificationDate>
<a:Modifier/>
<a:name>user</a:name>
How can I export or select a specific line? In the example I want to have such result:
<a:name>stack</a:name>
<a:name>user</a:name>
and the rest of the code should be ignored.
okay I found my desire result:
^((?!<a:name>.*</a:name>).)*$
As it seems it is a kind of xml document if you want to search a line for example
<a:CreationDate>0</a:CreationDate>
or
<a:name>user</a:name>
you can search by the closing tags like </a:name> or </a:CreationDate>
or you can use a scripting language like php or javascript to select the line.