How to avoid the auto completion triple quote ''' or triple double quote """ in xCode when pressing the character followed by space bar.
In my development style, the multiline String is used less than a simple String so I prefer hard typing the triple characters.
keyboard: U.S. International - PC
xcode version: 9.0 beta (9M136h)
illustration:
Answer
For some who'd be having the same issue, you might want to check your system's keyboard input source and make sure that you're using a source not allowing special latin's characters. In my case I was using U.S. International - PC instead of U.S.
On OS X you can edit your input sources by navigating to
System Preferences > Keyboard > Input Sources
Explanation
I was using U.S. International - PC which basically gives access to special characters (such as é, è, à, ö, etc.) by pressing a quote ', a backtick `, double quote " followed by the base character (for example ' + a produces à). With such a configuration, you can escape all these special characters by using the escape bar.
xCode 9 is generating the triple quote ''' or triple double quote """ if you try to escape ' (resp. ").
Related
I'm using the readline library in C to create a bash-like prompt within bash. When I tried to make the prompt colorful, with color sequences like these, the coloring works great, but the cursor spacing is messed up. The input is wrapped around too early and the wrap-around is to the same line so it starts overwriting the prompt. I thought I should escape the color-sequences with \[ and \] like
readline("\[\e[1;31m$\e[0m\] ")
But that prints the square brackets, and if I escape the backslashes it prints those too. How do I escape the color codes so the cursor still works?
The way to tell readline that a character sequence in a prompt string doesn't actually move the cursor when output to the screen is to surround it with the markers RL_PROMPT_START_IGNORE (currently, this is the character literal '\001' in readline's C header file) and RL_PROMPT_END_IGNORE (currently '\002').
And as #Joachim and #Alter said, use '\033' instead of '\e' for portability.
I found this question when looking to refine the GNU readline prompt in a bash script. Like readline in C code, \[ and \] aren't special but \001 and \002 will work when given literally via the special treatment bash affords quoted words of the form $'string'. I've been here before (and left unsatisfied due to not knowing to combine it with $'…'), so I figured I'd leave my explanation here now that I have a solution.
Using the data provided here, I was able to conclude this result:
C1=$'\001\033[1;34m\002' # blue - from \e[1;34m
C0=$'\001\033[0;0m\002' # reset - from \e[0;0m
while read -p "${C1}myshell>$C0 " -e command; do
echo "you said: $command"
done
This gives a blue prompt that says myshell> and has a trailing space, without colors for the actual command. Neither hitting Up nor entering a command that wraps to the next line will be confused by the non-printing characters.
As explained in the accepted answer, \001 (Start of Heading) and \002 (Start of Text) are the RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE markers, which tell bash and readline not to count anything between them for the purpose of painting the terminal. (Also found here: \033 is more reliable than \e and since I'm now using octal codes anyway, I might as well use one more.)
There seems to be quite the dearth of documentation on this; the best I could find was in perl's documentation for Term::ReadLine::Gnu, which says:
PROMPT may include some escape sequences. Use RL_PROMPT_START_IGNORE to begin a sequence of non-printing characters, and RL_PROMPT_END_IGNORE to end the sequence.
Im using JREPL.BAT to find and replace specific instances and my regex I have works for find and replace in VSC code and also in the couple regex editors I've used.
CALL ./framework/config/JREPL.BAT "(Error)+\(([^()]*|\(([^()]*|\([^()]*\))*\))*\)" "Error(\"\")" /f ./dist/index.html /o
so what I'm expecting is it to find any case of
Error("")
or
Error( skjdksjdskd() + "" + )
etc
Find and replace works perfectly but jrepl takes
Error( skjdksjdskd() + "" + )
and changes it to
Error()( skjdksjdskd() + "" + )
does anyone know with more JREPL experience know why its ignoring the quotes and also not replacing the () area?
JREPL is hybrid JScript/batch that uses CSCRIPT - the Windows script host.
CSCRIPT has an inherent limitation that prevents double quote literals from being passed as parameters - there is no CSCRIPT escape sequence that includes a " literal.
To include a " literal in your query string, you can use \x22 instead. All of the standard JScript escape sequences can be used in the query string. By default, escape sequences are not recognized in the replace string.
But you want a quote literal in your replace string. This requires the /XSEQ option so you can use the JREPL extended escape sequence of \q. A significant advantage of this option is you can also use the extended escape sequences in the replace string. You could also use \x22 for both the search and replace strings if you prefer, but I find \q much easier to remember.
You have one other potential problem - the CALL command doubles all quoted carets, so [^()] (any character other than ( or )) becomes [^^()] (any character other than ^, ( or )). This is definitely not what you want. That is the reason I added the \c = ^ extended escape sequence.
So I believe the following will give your expected result:
CALL .\framework\config\JREPL.BAT "(Error)+\(([\c()]*|\(([\c()]*|\([\c()]*\))*\))*\)" "Error(\q\q)" /xseq /f .\dist\index.html /o -
FYI - The effect of the ^ beginning of string anchor is not harmed by caret doubling - you don't need the \c escape sequence for the beginning of string anchor because "^MatchStringBeginning" and "^^MatchStringBeginning" yield identical regex results.
You can get more information about the extended escape sequences by issuing jrepl /?/xseq, or jrepl /??/xseq for paged help.
>jrepl /?/xseq
/XSEQ - Enables extended escape sequences for both Search strings and
Replacement strings, with support for the following sequences:
\\ - Backslash
\b - Backspace
\c - Caret (^)
\f - Formfeed
\n - Newline
\q - Quote (")
\r - Carriage Return
\t - Horizontal Tab
\v - Vertical Tab
\xnn - Extended ASCII byte code expressed as 2 hex digits nn.
The code is mapped to the correct Unicode code point,
depending on the chosen character set. If used within
a Find string, then the input character set is used. If
within a Replacement string, then the output character
set is used. If the selected character set is invalid or
not a single byte character set, then \xnn is treated as
a Unicode code point. Note that extended ASCII character
class ranges like [\xnn-\xnn] should not be used because
the intended range likely does not map to a contiguous
set of Unicode code points - use [\x{nn-mm}] instead.
\x{nn-mm} - A range of extended ASCII byte codes for use within
a regular expression character class expression. The
The min value nn and max value mm are expressed as hex
digits. The range is automatically expanded into the
full set of mapped Unicode code points. The character
set mapping rules are the same as for \xnn.
\x{nn,CharSet} - Same as \xnn, except explicitly uses CharSet
character set mapping.
\x{nn-mm,CharSet} - Same as \x{nn-mm}, except explicitly uses
CharSet character set mapping.
\unnnn - Unicode code point expressed as 4 hex digits nnnn.
\u{N} - Any Unicode code point where N is 1 to 6 hex digits
JREPL automatically creates an XBYTES.DAT file containing all 256
possible byte codes. The XBYTES.DAT file is preferentially created
in "%ALLUSERSPROFILE%\JREPL\" if at all possible. Otherwise the
file is created in "%TEMP%\JREPL\" instead. JREPL uses the file
to establish the correct \xnn byte code mapping for each character
set. Once created, successive runs reuse the same XBYTES.DAT file.
If the file gets corrupted, then use the /XBYTES option to force
creation of a new XBYTES.DAT file. If JREPL cannot create the file
for any reason, then JREPL silently defaults to using pre v7.4
behavior where /XSEQ \xnn is interpreted as Windows-1252. Creation
of XBYTES.DAT requires either CERTUTIL.EXE or ADO. It is possible
that both may be missing from an XP machine.
Without the /XSEQ option, only standard JSCRIPT escape sequences
\\, \b, \f, \n, \r, \t, \v, \xnn, \unnnn are available for the
search strings. And the \xnn sequence represents a unicode
code point, not extended ASCII.
Extended escape sequences are supported even when the /L option
is used. Both Search and Replace support all of the extended
escape sequences if both the /XSEQ and /L options are combined.
Extended escape sequences are not applied to JScript code when
using any of the /Jxxx options. Use the decode() function if
extended escape sequences are needed within the code.
Final Answer for this is to escape the quotes and backslashes as \" AND \\ when using CALL in Webpack-shell-plugin.
'call "./framework/config/JREPL.BAT" \"(Error)\\(([\\c()]*|\\(([\\c()]*|\\([\\c()]*\\))*\\))*\\)\" \"Error(\\q\\q)\" /xseq /f ./dist/index.html /o ./dist/indexFinal.html'
My class requires US-ASCII - Codepage 20127 or Unicode (UTF-8 without signature) - Codepage 65001 characters to be used on all assignments. However, my computer is run in a non-English Windows 10 for work purposes.
I need to, printf("Use \\n to cause a newline; use \\t to cause a tab.");
so that \n to cause a newline; use \t to cause a tab, will be displayed.
But since my computer settings are incompatible with ASCII code, it doesn't print \ like it can here. It only prints the character on the button (which looks like W) between backspace button and enter button on both Visual Studio (C) and output window (the black window that pops up after debugging).
What do I need to do to fix this?
I have tried,
Tools->Options...->Environment->Documents and unchecked the "Save documents as Unicode when data cannot be saved in codepage" checkbox.
I tried the save with encoding option where I tried both US-ASCII - Codepage 20127 and Unicode (UTF-8 without signature) - Codepage 65001. My computer still prints the W, not \.
My coding:
#include <stdio.h>
int main(void) {
printf("Use \\n to cause a newline; use \\t to cause a tab.\n");
return 0;
}
This ouputs Wn to cause a newline; use Wt to cause a tab., where W is the character on the button between backspace button and enter button.
It's a font problem. On my US Windows system if I type chcp 949 it forces the font to "MS Gothic", which displays a different character for backslash:
Before:
After:
If you cut-and-paste that text into a program like Notepad using a different font like Consolas, the slash will reappear. The character on the screen is the correct ASCII character...the font is just displaying it with an alternate symbol.
I had trouble getting the console to switch fonts. Most selections I had in Windows 10 switched back to MS Gothic, but the SimSun fonts would display Korean and the backslash correctly. I have a Chinese IME installed instead of Korean, so your console font selections may vary.
I am testing some Escape Sequence Character in C using Command Line Tool in xCode on El Capitan. This is the string I tested:
printf("\a111\b222\n");
The expected result was:
bell noise followed by 112221
to my surprise, there was no bell sound at the start, \b did not move cursor one character back, and write from there on. Is this a Mac and xCdoe problem? If so, what do I need to enable all the escape characters.
How those escape sequences are interpreted is up to the terminal/shell where you execute the program. Not all terminals support all sequences.
I have a question with regards to using the 'repl' batch command, specifically it's replace parameter.
After taking the time to read the documentation... :-)... and some testing, it seems that regular expressions can't be used in the replace parameter.
"type file.txt | repl "Jacob is alive. He lives.\n" "Betty lives.\nGo Betty." M >file.txt.new"
This will do a literal replace using the characters '.' & '\n' rather than inserting a new line. Is it true regular expressions cannot be used in the [replace] parameter of repl.bat? If not, do you know of a way to achieve this behavior? Thanks ahead of time!
Extracted from the repl.bat /? information
M - Multi-line mode. The entire contents of stdin is read and
processed in one pass instead of line by line, thus enabling
search for \n. This also enables preservation of the original
line terminators. If the M option is not present, then every
printed line is termiated with carriage return and line feed.
The M option is incompatible with the A option unless the S
option is also present.
X - Enables extended substitution pattern syntax with support
for the following escape sequences within the Replace string:
\\ - Backslash
\b - Backspace
\f - Formfeed
\n - Newline
\q - Quote
\r - Carriage Return
\t - Horizontal Tab
\v - Vertical Tab
\xnn - Extended ASCII byte code expressed as 2 hex digits
\unnnn - Unicode character expressed as 4 hex digits
So, your repl command options should be MX instead of only M