Vim real tab characters start at column 8- I can't move all the way left - vim

I'm using real tab characters in my files, and when whitespace characters are set to invisible (which it is by default), then the farthest left I can go is column 8. But if I make whitespace visible (:set list!) then it still says that I'm at column 8, but it at least shows my cursor all the way to the left. What could be causing this?

This is not a matter of correct or incorrect. Vim just chooses to put the (single cell) cursor on the last cell of the Tab, and the jumping forward movement probably makes Tabs easier to detect, so most people like that behavior. Only with :set list, where a Tab is represented by a start and follow-up characters does this change.
If you really can't get used to it, the only workaround (short of modifying Vim's source code directly) is:
set list listchars=tab:\ \ " Note: trailing space after the last backslash!
Note that this has other side effects, e.g. when soft wrapping words.

It's not a bug or a problem, other than a visual annoyance. In the upper screenshot your cursor is at first character of the line. Try a character modifying command like rx on it, you'll see.

Related

Text with a dash in the cell but not in the formula bar (Excel)

In cell E1 it says You-Gov but in the formula bar it says YouGov.
If I copy/paste values it stays the same, the formatting is General. Using =CODE(MID($E$1,4,1)) I get a value of 173.
Any idea what is happening?
What you have got here is called the "Soft Hyphen". It's purpose is to let the system know where a word may be broken, if needed, for display purposes.
"The HTML standard states that a hyphen character should be displayed at the end of the line where the break occurs if a line is broken at a soft hyphen. On the other hand, nothing is displayed if the line is not broken at a soft hyphen."
And that is exactly what is happening in Excel. It may appear in-cell but the formula-bar will only show the Soft Hyphen when the word it's used in is actually broken in the editor itself. To test this out, try to squeeze Excel and it's formula bar to a very narrow pane. You'll notice the Soft Hyphen will appear on-and-off depending if it's needed to be shown. It's rather funny that MS even mentioned the Soft Hyphen in their docs but it won't show in the matrix, probably for the same reason.
To solve your issue:
Press Ctrl+F
Select 'Replace'
Search for: Hold Alt and type 0173 on the numpad.
Replace with: - A normal hyphen.
Here is a fun little demonstration from here full of "shy" hyphens. Resize the window to make them visible one by one:
Margaret­Are­You­Grieving­Over­Goldengrove­Unleaving­Leaves­Like­The­Things­Of­Man­You­With­Your­Fresh­Thoughts­Care­For­Can­You­Ah­As­The­Heart­Grows­Older­It­Will­Come­To­Such­Sights­Colder­By­And­By­Nor­Spare­A­Sigh­Though­Worlds­Of­Wanwood­Leafmeal­Lie­And­Yet­You­Will­Weep­And­Know­Why­Now­No­Matter­Child­The­Name­Sorrows­Springs­Are­The­Same­Nor­Mouth­Had­No­Nor­Mind­Expressed­What­Heart­Heard­Of­Ghost­Guessed­It­Is­The­Blight­Man­Was­Born­For­It­Is­Margaret­You­Mourn­For

mouse select copy from "vim" and "less" show different results

Case1: Open file1 in vi. Select a few lines(select copy is enabled). Paste in a different place.
Case 2: run the command less file1. From the console, select some lines. Paste in a different place.
In case2, I see that there are new lines introduced at where the line display shifts to new line. So, if the terminal width is 80 characters and my line is 100 characters, then 20 characters will be shown in the new line. If I copy from vim, all 100 characters are copied without any line-break. However, if I copy from "less" command, line-break is introduced after 80th character.
This messes up things like path.
Does "less" introduce line-break dynamically for lines longer than the display width?
less is not designed to handle mouse events. So when you select text while running it, the selection will be handled by the terminal behind, which doesn't give any sense to lines, paragraphs and so on; the text buffer is copied as it is displayed, that's all.
On the opposite, if you use vim with the right configuration, mouse events will be detected and treated by vim itself : the terminal will gracefully let vim handle them, for convenience. Then the line layout will be restored correctly when copying lines of text.

vim: highlight words in visual block mode

Below is a screenshot of me entering visual block mode and pressing "w" to select by word:
How can I select every word in the rows I have selected? Meaning I want the full word in the rows highlighted instead of it getting cut off as shown in the screenshot.
edit: What I want to be able to do is delete a column of words of varying length. In the example screenshot I want to delete the words between the tags, But it could be any column of words.
There are a bunch of plugins for multiple selection, look them up on vim.org.
But I must remind you that visually selecting text is more often than not an unnecessary step. Why don't you explain what you actually want to achieve instead of your failed attempts? Maybe there's a better way...
[edit]
:'<,'>norm dit
seems to be the simplest way to achieve your goal without selecting every word:
and :,+7norm dit would be even better because you don't select anything.
The highlight modes can only select blocks (by cursor, by line, or by rectangular block). You can use a plugin such as vim-multiple-cursors to do what you are trying to do.
The only place where Vim allows a non-rectangular, "jagged edge" visual selection is at the end of the lines, i.e. by extending the blockwise selection with $. Therefore, you'd need to (temporarily) get rid of the trailing </th> (or include it in the selection, but operate in such a way that they are kept intact).
You shouldn't need a selection to work with the text. For example, to delete the text inside the tags, you can use a substitution:
:%s#<th>\zs.*\ze</th>##
You can't. You can only select rectangular blocks in block select mode. Maybe a plugin solves this?

Vim select the ends of multiple lines (block mode, but where the ending column varies)

Is there any way in vim that I can select the end of all these lines? (I'm only showing the end of the lines in these screenshots).
In block mode I can get them all if the bottom line is longer than the rest, but if the bottom line is shorter, the longer lines are truncated.
EDIT | I guess I can just pad out the bottom line with spaces before I select, then delete the spaces later.
Put your cursor on the top-left character you want to be part of the block.
Enter block selection mode with ctrl+v
Select to the end of the line with $ (this is the step you're missing; if you move to the end of the first line using $ then the selection will extend to the end of subsequent lines as well)
Move down 3 lines with 3j
There's more information in the Vim documentation's section on visual mode which you can read online, or just type :help v_$ in Vim.
Click somewhere (anywhere) in the first line you wish to append text to.
Press Control + V.
Press Down to create an arbitrary vertical block selection that spans the desired lines.
Press $ to expand the visual block selection to the ends of every line selected.
Press Shift + A to append text to every selected line.
Type the text you want to append.
Press Escape and the text will be appended across the selected lines.
Alternately, you can set the virtualedit (:h 'virtualedit') setting so that, any time you're in visual block mode, you can move the cursor around even past the ends of lines. E.g. :set virtualedit=block.
If you're looking to select the very last character of every line, like if you want to add something after the quotes at the end of each line, you can do the following:
Put your cursor over the very last character (in this example, the last quote on the first line)
Enter block mode: control + V
Move down to select as many lines as you want to change.
Insert at the end of the line: shift + A
Type what you want to add and then exit Visual mode
You text should now be inserted at the end of each selected line!
Hope this is helpful to others like me searching for an answer similar, but not exactly the same, as the above.
I don't know if is a new thing. But if you press $ two times (instead one) the block goes to the end of all lines without creating extra spaces).
Tested on nvim 0.7.2.

Moving a block of code by a tabspace

I am currently visually selecting the code and typing ">" which moves the code by 2 tabs. But I only want to move it by one tab.
Is there any alternate command in VIM to move the code by a tabspace.
Ideally I would like to put a marker and then move the whole code block by a tabspace.
Thanks
This will set your shifting width to four spaces (default tab size):
:set sw=4
You can also change the size of the tab stop itself (X is any value you like):
:set ts=X
And if you like to use spaces instead of tab characters, use this:
:set expandtab
If you use the same settings in many files, you can put these in your .vimrc.
> moves the code by one shiftwidth. So you need to set that option correctly.
There are easier ways to do what you want, as others have pointed out, but the
following is of more general use:
You can select a column by pressing ctrl+v and then using the up and down keys (or j and k).
Next press I to go to insert mode. Now you can type anthing you like. In your case, type a single tab.
Finish by pressing esc, and see how your edit is applied to all lines.

Resources