Prettier tab symbols in vim - vim

I’m trying to make vim look more similar to what I’m used to in Coda 2.
In my .vimrc I have this line:
set listchars=tab:➝.,extends:#,nbsp:.
That makes my whitespace look like this:
However, I’d rather those dots weren’t visible, so it’d look more like this:
I've tried using a space character, but I end up with this warning:
E474: Invalid argument: listchars=tab:➝
What character can I use that won’t be visible on the screen, and also won’t throw a warning?

You can escape the space character like this:
set listchars=tab:➝\ ,extends:#,nbsp:.

In listchars tab: takes to characters. Directly from the help file:
tab:xy Two characters to be used to show a tab. The first
char is used once. The second char is repeated to
fill the space that the tab normally occupies.
"tab:>-" will show a tab that takes four spaces as
">---". When omitted, a tab is show as ^I.
So you can just use a space instead of the dot that you are using for the second character, it does have to be escaped though: set listchars=tab:➝\ ,extends:#,nbsp:. to get the result you want.

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')

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:·

How to search for invisible control characters

I know there are some threads about this on stackoverflow but when i write ":set list" in the editor, it seems to display hidden characters but it doesnt display the hidden characters in the code we are having problems with.
Some times now we have had some invisible symbols in our code making if loops break, i dont know how the symbols get there except from that some wierd keyboard combination much have been accidentally typed in. The code itself looks correct but the invisible symbol breaks it.
I have searched online about this but all i can find seems to be the ":set list" command in vim in addition to have to change the color of the hidden characters, but while this seems to display some hidden characters it doesnt display the problematic ones. We are getting two symbols which looks like a cross and one looks like a pistol. We have also tried to add the "draw_white_space" setting in sublime text but this only seems to display, well, whitspace like it says but the result was shown on google for showing hiden characters so i gave it a try.
The only way we have been able to see where the symbols are is with the DiffMerge tool, we have not been able to see these symbols in any other editor but we have actually been able to copy the sign to its own file and grep through all the files with the -f grep option which works, but it would be easier to display the characters in vim but using a keybinding.
Does someone have any suggestions? This is causing us to use a lot more time debugging the code when the problems is an invisible symbol.
Try the following search command:
/[^ -~<09>]
(you get the <09> by pressing the tab key). Or if you want to get rid of those nasty tabs, just:
/[^ -~]
That will find and highlight any non-ASCII or control-ASCII character.
If you still have hidden characters out there, you can try this command before the search:
:set enc=latin1
That will prevent any weird Unicode character to show up in your code.

Remove White space in vim, keep indentation

I am looking to remove all white space in vim, but keep the default indentation as is. Currently all out files use spaces instead of tabs so:
content
content inside[Sneeky white space of epicness]
content
Should be:
content
content inside
content
Note: [Sneeky white space of epicness] represents a block of white space.
Use substitute
%s/ *$//g
$ means end of line.
* means match zero or more instances of the previous element (as suggested by Jite)
Be aware that you could have tab... To represent any white space, use \s
%s/\s*$//g
EDIT:
As suggested by kojiro you could use + instead of *. With a *, vim does the replace on EVERY line. With a +, the replace is done only where it needs to be done in that case.
+ means match at least one instance of the previous element.
With vim you have to escape the +.
See :help pattern-overview for more details.
My final answer :
%s/\s\+$//g
There are several plugins that can detect and (on demand, or even automatically) delete trailing whitespace. My DeleteTrailingWhitespace plugin is one of them, and handles way more cornercases that the simple :%s command usually given. (The plugin page has links to alternative plugins.)

how to get the digraph key or unicode from a special character

I am configuring tmux & powerline. I would like to change the default separators in tmux status line. I managed to figure out where to do it, however I could not get the special character that I want.
I want to type, in Vim, a left/right pointing triangle that spans the whole line-height, but the only thing I could find is a small triangle (unicode : 25B6,25BA,25C0,25C4...)
There is a big right pointing triangle already in a powerline configuration file, which I could copy and paste, but I want to know its unicode and want a left one. Is there a way to get the unicode from the symbol in Vim or anywhere else?
You can get the codepoint value of a character in Vim by positioning the cursor on the character in question and typing either ga or :ascii.
You can either use ga in command mode or :ascii on the command line (even though it says ascii, it shows information for general encodings)
You may add a permanent preview of current character in your status line (see :h statusline), eg.:
:let &statusline = &statusline . "\ [%03b\ 0x%B]"

Resources