My vim editor highlights the pattern [{}] when I'm writing c++ code.
It highlights the braces in the same way it would highlight search matches, however the command :nohl doesn't yield anything.
Any ideas on how to turn this off?
Related
I have written a program that searches for 'opens' without matching 'closes' in a target file. It produces an output like this:
open
close
open
open
close
In this example here the second 'open' is not immediately followed by a matching 'close', so I consider that an error. My text-editor (editpad) has a regular-expression search/replace feature, which I would like to use to get rid of all correct pairs, so I can notice easily the incorrect situations. I tried replacing the following
open\r\nclose
I thought that this would match the two words and the line-break between them (I'm using Windows). This did not work.
Does anyone have an idea why it didn't?
If you select the Regex mode, your regex will work, but I also suggest making \r optional by appending ? after it to support LF endings, too:
open\r?\nclose
See the screenshot with settings and proof it works in EditPad:
I'm trying to do a find and replace on a file to get rid of line breaks using Adobe Brackets. However, when I enter \n in the search field, even with Regular Expression turned on, it says No results. Is there a way to find newlines within Brackets?
You could try this:
(\r\n|\r|\n)
Based on geany documentation
Geany knows four types of auto-indentation:
None: Disables auto-indentation completely.
Basic: Adds the same amount of whitespace on a new line as on the last line.
Current chars:
Does the same as Basic but also indents a new line after an opening brace '{', and de-indents when typing a closing brace '}'. For Python, a new line will be indented after typing ':' at the end of the previous line.
Match braces:
Similar to Current chars but the closing brace will be aligned to match the indentation of the line with the opening brace.
I am developing new editor for new DSL. I don't have any kind of braces, so indentation must be based on strings. How can I apply auto-indentation to my custom syntax. Is there any short and easy way?
Scintilla can be the thing that you are looking for. Strategy which used while implementing folding inside LexDSL.cxx can be a solution for it. Level based implementation of code folding can also determine the deepness of the tab. Each level means new tab and using that strategy could make customization of indentation in geany be possible.
I am trying to append some text (e.g. "Fish") to the end of every line in a file using Visual Studio or SQL Server Management Studio using the following settings in the find/replace dialog:
Find what: $
Replace with: Fish
Use Regular expressions: Checked
This mostly does the job, but for a handful of lines it not only appends "Fish" to the end of the line it also puts it at the beginning of the line. I can't discern any pattern to this behaviour it seems to be almost random, with the larger the file the more lines tending to go wrong.
A similar find/replace with ^ (to put text at the beginning of the line) works with no problem.
Anybody know why this is happening? And also, are there any better suggestions for achieving what I want to?
This works in Visual Studio 2012 and 2015:
Find: \r
Replace: Fish\r
Make sure you tick 'Use Regular Expressions' checkbox:
I'm not sure why you're seeing that, but you might try something like:
Find: ^.*$
Replace: \0Fish
I bother you to have some tips for this problem: I'm working in Latex with a very dirty code, generated by writer2latex (quite good programme, anyway) and, using Emacs, I'm trying to query-replace multiple lines of code, for instance:
{\centering [Warning: Image ignored] % Unhandled or unsupported graphics:
%\includegraphics[width=11.104cm,height=8.23cm]{img34}
have to become:
\begin{figure}[tpb]
\begin{center}
\includegraphics[width=\textwidth]{img34}
Using M-x re-builder, I found out that I could underline the whole region I need to query-replace with the string: \{.*centering.*c-qc-j.*cm] but, if I M-x replace-regexp using this, I only get: Invalid regexp: "Invalid content of \\{\\}"
Any suggestion about how to perform the query? I have a HUGE amount of lines like these to replace... :-)
You're getting this error message because in Emacs' regular expressions the curly braces\{ and \} have special meaning. These braces are used to specify that the part of the regexp immediately before the braces should be matched a certain number of times.
From the GNU Emacs documentation on regexps:
\{n\}
is a postfix operator specifying n repetitions [...]
\{n,m\}
is a postfix operator specifying between n and m repetitions [...]
If you want your regexp to actually match a curly brace, do not escape it with a leading slash:
{.*centering.*C-q C-j.*cm]
In order to use a backslash in the replacement string you have to escape it with another backslash. (When doing this in code, it quickly becomes quite ugly because inside a double-quoted string backslashes themselves have to be escaped already. However, since you are doing your replacements interactively, the double escaping is not necessary and thus two backslashs are enough.)
M-C-% {.*centering.*C-q C-j.*cm] RET \\begin{figure}[tpb]C-q C-j\\begin{center}C-q C-j\\includegraphics[width=\\textwidth] RET
Make sure the re-syntax is "read", C-c tab. Remove the initial backslash. Now the regexp should work if you yank it into replace-regexp