Highlight nbsp character in Sublime Text 2? - text

Is there a way to highlight special whitespace characters like nbsp in Sublime Text 2? Several times I copied text from word users to my code and it crashed because I couldn't see these "illegal" whitespace characters...
Thanks!
Chris

Here is a plugin for Sublime Text that does the job:
https://github.com/possan/sublime_unicode_nbsp
You can comment out lines 125 and 126 if the highlighting of trailing whitespaces annoys you.

Edit your user settings as below (you may go into "Preferences->Settings Default." or "Preferences->Setting User." depends on whether you've already had some customized settings) :
{
"color_scheme": ...,
"font_size": ...,
"draw_white_space": "$your_selection"
}
The rule to set the setting is:
Set to "none" to turn off drawing white space
Set to a list to draw only the white space within the list
Set to "all" to draw all white space

Related

How to set display the indentation symbol when wrapping a new line in Vim,when input it will disappear

Does anyone knows how to set this? Vim will display the indentation symbol when wrapping a new line, When input it will disappear.
These options will make sure trailing spaces are displayed as dots (or whichever other character you set instead). As you say, the dots disappear once another character is entered, as the spaces are then not trailing any more. Look through other listchars options as well, if you want to see e.g. tabs or other cool stuff.
set listchars=trail:·
set list
(See :help 'listchars', :help 'list')

View only leading/multiple whitespace in Sublime Text 3

I would like to view whitespace characters in Sublime Text 3, except for single spaces between words.
For example, in VS Code this is enabled by the setting "editor.renderWhitespace": "boundary", and looks like this:
I'm aware of the built-in ST3 setting "draw_white_space": "all/none/selection", which does not accomplish what I'm looking for. I've tried the package Highlight Whitespaces which almost does what I want - but rather than highlighting the space, I'd like to just view the "dot" to show the "invisible" space character.

How to create dashed lines in terminal for indentation

I'm using vim in Mac terminal. I want to have dashed lines in front of each line to indicate the tabs and indentations. Is there a way to configure this in .vimrc? The editor shown in the picture is sharelatex.
Many thanks!
Set listchars to that symbol (you might want one of these: ¦⁞⋮┆┊┋┇︙⸽) and a space:
set listchars=tab:¦\
That is "tab", followed by a colon, your desired character, a backslash and a space.
In addition, to see the effect, you have to set the list option:
set list
listchars can be used to set more characters to show in special places, e.g. eol to show a character at the end of a line, or trail to see trailing spaces. To set multiple ones, seperate them by commas:
set listchars=tab:¦\ ,trail:·

Setting a sign to highlight only text instead of whole line in Vim

When defining a :sign you can use the linehl argument to assign a highlight group for the whole line the sign is placed in.
This highlights the whole line until the end, but how I do to highlight only the text of that line?
Edit: The idea is to use Syntastic to show the errors and warnings, but I can't redefine the SyntasticStyleError sign to do what I want. It highlights all the line instead of only the text of that line.
It is not possible as far as I know. Look at the :h sign-define:
:sign define {name} {argument}...
Define a new sign or set attributes for an existing sign.
The {name} can either be a number (all digits) or a name
starting with a non-digit. Leading digits are ignored, thus
"0012", "012" and "12" are considered the same name.
About 120 different signs can be defined.
Accepted arguments:
icon={bitmap}
Define the file name where the bitmap can be found. Should be
a full path. The bitmap should fit in the place of two
characters. This is not checked. If the bitmap is too big it
will cause redraw problems. Only GTK 2 can scale the bitmap
to fit the space available.
toolkit supports ~
GTK 1 pixmap (.xpm)
GTK 2 many
Motif pixmap (.xpm)
Win32 .bmp, .ico, .cur
pixmap (.xpm) |+xpm_w32|
linehl={group}
Highlighting group used for the whole line the sign is placed
in. Most useful is defining a background color.
text={text} *E239*
Define the text that is displayed when there is no icon or the
GUI is not being used. Only printable characters are allowed
and they must occupy one or two display cells.
texthl={group}
Highlighting group used for the text item.
It does not offer you a straight-forward way to distinguish between the text background colour and the background colour of the line - in fact, you can only set the linehl parameter.
Maybe there is a hacky way to do what you want. I've stumbled upon this link you might find useful: https://sunaku.github.io/vim-256color-bce.html
Another interesting idea is explained on vim.wikia.com (link) in the Highlighting that stays after cursor moves section. It suggests using the following command:
:nnoremap <silent> <Leader>l ml:execute 'match Search /\%'.line('.').'l/'<CR>
This way you might mix it with the information you get from :sign place and replace signs with your custom highlighting method I posted above. It requires some scripting though.

How to turn OFF (or at least override) syntax highlighting in nano via ~/.nanorc?

I am struggling finding a clear answer on disabling or overriding the color settings for the nano editor.
By default color syntax highlighting is enabled on my system. Clicking ALT+Y disables this, which is exactly what I want my default to be.
Any ideas?
To disable syntax highlighting write following lines into ~/.nanorc:
set quiet
syntax "disabled" "."
The first line prevent error reporting. The second line defines a new color syntax.
You can also define a single syntax containing your favorite color in your ~/.nanorc:
syntax "disabled" "."
color brightgreen,black "."
I hope this helps.
For future references, I would add that you can run nano without colors using the command line parameter -Y
nano -Ynone myfile.txt
The "none" syntax is reserved; specifying it on the command line is the same as not having a syntax at all.
You can set an alias in your .bash_profile file:
alias nano='nano -Ynone'
This worked for me better than above since I run a white background terminal. It just makes all the text black again.
set quiet
syntax "disabled" "."
color black "."
Add the following to your ~/.nanorc file to disable syntax highlighting for all file types.
syntax "" ""
color white ""
There's a limitation in nano that every syntax requires at least one color rule. And, on nano 4.0 at least, the color rule's regex can't be empty. But you can make a rule that just targets whitespace, or a rule that just targets an empty line.
I'd recommend defining an extremely minimal color scheme first that applies colors in a way that you can tolerate. For example, this rule sets the background to green in places where you have trailing whitespace.
syntax "nothing" "."
color ,green "[[:space:]]+$"
You can also create a rule that targets an empty line. This rule will have no visible effect, but the right hand side is technically not empty so nano will accept it.
syntax "nothing" "."
color green "^$"
Instead of using syntax "disabled" "." and forcibly keeping all hghlighting off, add this to bottom of your ~/.nanorc and use an alias when you want no highlighting:
## Syntax - Black and White only (for override)
syntax "blackandwhite" "."
color white,black "."
then:
nano --syntax=blackandwhite myfile-nohighlighting.php
(Too much to type? Then use an alias in your .bashrc/shellrc):
alias bw='nano --syntax=blackandwhite'
or you could simply (See #Adam answer):
alias bw='nano -Ynone'
And avoid creating a highlight profile.
then you can open using the alias and have no highlighting:
bw myfile.php
Using it this way, you also leave highlighting available in the .rc for when you may need it..
This answer is for nano version 5.9 on Termux version 0.117. Disclaimer: I don't understand exactly how .nanorc code works here (so, it possibly should be a bit different, but it seems to work).
To turn syntax highlighting off for all file types, do this in ~/.nanorc:
syntax "all" "\.*$"
color white,black "^.*$"
In the latter set of double quotes for each line, those are regular expressions. On the first line, the regex matches any file extension (I don't think "all" actually does anything; I just had to type a word in there; it doesn't work if it's blank or has multiple words). On the second line, the regex matches the entire text of the document, and sets the foreground (the font color) to white, and the highlight background to black.
I guess this does the same thing in a simpler way (I suppose it evaluates each character at a time):
syntax "all" "."
color white,black "."
If you just want to do the same thing for one kind of file, here is an example for .txt files:
syntax "txt" "\.txt$"
color white,black "^.*$"
Or
syntax "txt" "\.txt$"
color white,black "."
If you don't want to specify the background highlight color (which is not the entire background color of nano, btw), too, then instead of doing color white,black . . . do color white . . ..
Note: My personal reason for wanting to disable syntax highlighting was because comments beginning with # were a different color in plain text files and similar (and I didn't want that). These solutions make the comments white.

Resources