I would like to replace the right square bracket "]" with ",1]". Usually I use M-% to do replacement, but for this case it does not work and gives: No matching parenthis found. I tried to replace left square brackets and it works. Does someone can give me a hint how I can replace right square brackets?
Thanks for help.
"No matching parenthesis found" is a useless warning here. Just ignore it. Consider this warning a bug, as it seems useful only WRT to regexps.
Related
Is there a way to highlight brackets when the cursor is anywhere within the enclosing brackets? Default settings highlight it only when I place the cursor near the brackets.
Yes, there is now a way by default, in VSCode 1.40 (October 2019):
Improvements to bracket matching
Previously, VS Code would only highlight matching brackets when the cursor was next to a bracket character.
Now VS Code will always highlight enclosing brackets if they exist.
We have also adjusted our Go to Bracket and Select to Bracket actions to use enclosing brackets.
It is improved and supported natively with VSCode 1.60 (Aug. 2021):
Bracket pair colorization can be enabled by setting "editor.bracketPairColorization.enabled": true.
All colors are themeable and up to six colors can be configured.
VS Code only supports bracket matching when the cursor is near the opening or closing bracket. Maybe an extension would help highlight the enclosing brackets wherever you are in the code but I haven't been able to find one.
If you just want to quickly find matching brackets, braces, parens, etc. you could try Bracket Pair Colorizer or Rainbow Brackets.
Also maybe you will like VSCode extension "Blockman", it highlights nested code blocks. (I am the author of Blockman)
With release 1.60 (September 2021), VS Code now has bracket pair colorization built in, indicating all matching brackets by color.
This feature can be enabled by adding this line to settings.json:
"editor.bracketPairColorization.enabled": true
I am using Version: 1.63.2(MacOS). Default bracket highlight feature was not working for me. In case, someone face similar issue, set it true.
"editor.matchBrackets": true,
I'm tying to put in a command that goes
{11,21}STO>dim([A])
And I keep getting a syntax error at the first square bracket. The syntax seems correct to me, so I don't know what the issue is.
Your syntax appears to be right. The only tip I can give you is a list of button presses to make sure for example you are not doing Bracket A Bracket but selecting the matrix from the matrix menu.
The button presses to do the task you appear to want are:
2nd->left brace(left parenthesis button)->1->1->,->2->1->2nd->right brace(right parenthesis button)->sto(->)->2nd->matrx(x^-1 button)->right arrow->3->2nd->matrx(x^-1 button)->1->right parenthesis
I hope this can be of help, let me know if it works or not.
I want to add square bracket in org mode links' description, for example:
[[http://www.example.com][ Array[i] ]]
Is there a way to escape the brackets [ and ] ? Someone mentioned URL-encoding, but it's not compatible. Besides, looking for the URL-encoding of a character is time consuming.
I suspect that Org doesn't support this.
Org's link structure documentation makes no mention of escaping square brackets in link descriptions.
If you use org-insert-link (bound to C-c C-l by default) and try to use square brackets in your link text, Org converts them to braces:
[[http://www.example.com/][Array{i}]]
You should be able to use a Unicode character that looks like a square bracket inside your link text, but I haven't found a reasonable character to use. The closest I found were SQUARE IMAGE OF (⊏) and SQUARE ORIGINAL OF (⊐), which do indeed work:
[[http://www.example.com/][Array⊏i⊐]]
I found that using org-mode Macros to insert the ASCII codes for the square brackets works. I have posted the solution on Emacs Stackexchange.
Is there a way to autoclose brackets and quotes in IPython.
Just like in RStudio when you type an opening bracket like [ it automatically types the closing bracket ] and moves the cursor inside the brackets. Same thing with quotes.
Possible, probably not too hard, but not trivial. Might need to update the underlying library (in progress), and to dig in CodeMirror doc to see if there is already such an option. If you are interested in diving in the code/submit Patch I would suggest asking for directions on the ML / on github.
Compiling (or executing) a perl program with unmatched array braces ("[ ]") or scope brackets ("{ }") causes the "missing right curly or square bracket" syntax error. Perl often reports the source as your last code line ("at EOF"), which could be far removed from the actual missing piece.
Example perl error message:
Missing right curly or square bracket at ./foo.pl line 100, at end of line
syntax error at ./foo.pl line 100, at EOF
Execution of ./foo.pl aborted due to compilation errors.
How do vi or Vi IMproved (VIM) users troubleshoot this error message? I've added an answer with some VIM enhancements. Please add your own ideas, practices, or vi plugins.
NOTE: Original question posted with VIM version that didn't highlight perl braces and brackets. Many newer versions do this; see vim.org for more info.
How to troubleshoot this error right now:
In VIM, pick an opening {, [, or ( symbol. The % command jumps between matching { }, [ ], and ( ) pairs. Mismatches will jump to an unexpected location.
Install perltidy, run it, and look for oddly indented code blocks.
How to prevent future errors:
StackOverflow question 719476 shows how to modify VIM brace/bracket syntax coloring for braces/brackets. (Some versions don't do this by default.)
Karl Guertin's AutoClose plugin auto-matches [, (, {, ", ' symbols when typed.
perltidy script reformats perl for readability, which can expose mismatched symbols.
User a paid nerd said: "Use perltidy within VIM editor with nmap."
nmap \g mt:%!perltidy<CR>'t
Use consistent {} matching indentation (general tip, not specific to this perl error).
sub foo {
...
}
or
sub bar
{
...
}
You can use the % command to match braces/brackets/parentheses in vim. So use that to search for unmatched characters.
I constantly use perltidy to reformat my code. When I reformat code that's missing a terminator, further code indents strangely and I can quickly trace upward to locate the problem.
Bonus: I use this mapping to instantly reformat the file and not lose the cursor position:
nmap \g mt:%!perltidy<CR>'t
Use padre. Click Perl->Find Unmatched Brace. It moves your cursor right to the problem.
I came to this page with the same problem. Using perltidy and vim were of no help, the indenting looked fine after perltidy. I had an extra open brace before a 'sub' keyword for some reason. Padre solved the problem in one-click.
http://padre.perlide.org/
use syntax highlighting, vim almost always get this right, and has a very sophisticated perl syntax highlighting scheme.
:syntax on
It sounds like you may be talking about a teaching situation, in which case teaching good indentation will solve most of these issues.
However, sometimes I'm on a server with no niceties like vim and perltidy, and I use a quick'n'dirty technique to find the syntax error - just add a right-curly at different points in your code until the line number changes, and there's your trouble spot.
If you don't see any missing braces :
Replacing \r with \n can help to fix this issue if the file created in windows and trying to use in Linux.
I got this error in a script that appeared to have perfectly matched curly and square braces... except that I had used bash-style syntax which actually commented out the second half of one line (with the second half of a curly brace pair).
The error went away when I changed this line:
$data_len="${#insert_data}";
to this:
$data_len=length($insert_data);
Use regular expression to narrow down where offending code. Example using shell, pcregrep
cat index.pl |pcregrep '[\{]{1}[\w\W^}^{]{90,}'
varying 90 as needed for limiting block length before expecting an ending brace.
As a simple re-statement and combination of #Ether and #Matthew Glidden:
Intent shown like this ( vi command like this )
Go to top of file ( 1G )
Search for brackets ( /[[({] then press "Enter" )
That's "slash" "open square brace" "open square brace" "open round brace" "open curly brace" "close square brace"
As a regex, we're searching for a custom character class which is all opening braces.
Find end matching bracket ( % )
Find starting bracket again ( % )
Find next opening bracket ( n )
Repeat from 3 until you've checked all brackets in file.
Works as far back as vi on HP-UX 11.11 (like ~2001).