14
votes
Accepted
How to deactive colorcolumn quickly in different situation?
You can clear all the lines by just setting cc to an empty value like so:
:set cc=
You also can create a command or mapping to toggle between the two, &cc refers to the cc setting, we need to ...
11
votes
Accepted
Function to toggle set colorcolumn
The only big flaw I see in your code is the fact that you don't use the non recursive version of nmap (See here for more details).
Also just for the sake to not use a function and make it a one liner ...
5
votes
How do I get consistent behavior with matchadd color column?
The solution I'm using nowadays is:
matchadd('ColorColumn', '\%81v\s*\zs\S', 100)
That version highlights the first non-space character after column 80, which I find more useful.
4
votes
How do I stop the colorcolumn from breaking into multiple pieces when there are wrapped lines?
The colorcolumn setting accepts multiple values, for example set colorcolumn=30,60 will highlight column 30 and 60.
We can use this to display a single unbroken line for wrapped lines; for example for ...
4
votes
How do I get consistent behavior with matchadd color column?
After digging around a bit on the internet, I found this page which achieves a similar effect but is more specific in the match.
The fix is to add a . after the v.
call matchadd('ColorColumn', '\%...
4
votes
Accepted
Insert character until column number
Well, doing this in vimscript is not that hard. For example, the following command will do what you describe to the line your cursor is on:
:exec 'norm '.(&cc - strlen(getline('.'))).'A='
The ...
4
votes
Accepted
Set colorcolumn to textwidth only when textwidth is set
You're on the right track, you just need to add the same function to the BufEnter autocmd:
set textwidth=0
function! s:SetColorColumn()
if &textwidth == 0
setlocal colorcolumn=80
...
3
votes
How can I set up a ruler at a specific column?
I mostly do coding in vim (version 7.4) and I have added the below two lines in my .vimrc to maintain a "colorcolumn" for 100 character length.
:set colorcolumn=100 ...
3
votes
Accepted
How do I get a specific colorcolumn value?
One strange thing about vimscript is that it automatically converts string to numbers when some
operations are applied.
For example, if you try this:
if '123foo'
echo 'hi'
endif
You will get 'hi'...
3
votes
Accepted
How to check the color code of my line numbering?
The highlight group used for line numbers is named LineNr, so you can use the following command to inspect its current setting:
:hi LineNr
Additionally, if you want to use the same settings for both, ...
1
vote
Accepted
Setting `colorcolumn` to the value of `textwidth` has no effect?
What you are expected to do: set cc=+0
Why your stuff doesn't work: because ordinary :set is executed once, while :autocmd FileType is executed upon each FileType event.
Note: your autocmd has all ...
1
vote
Is it possible to use colorcolumn on specific lines only
I can't help but feel that you are trying to limit the colorcolumn to the 81st (or so) column only when there actually is a line that goes beyond that column. I'm sorry, if I got your question wrong, ...
1
vote
Highlighting screen positions, or `:set colorcolumn` only for the 2 bottom and top lines visible on the screen
Hightlight first and last 2 lines after column 80:
:autocmd VimEnter,WinEnter * :match Error /\v%>80v%<3l.*|%>80v.*%$|%>80v.*(\n.*%$)@=/
You need to open a new window or reopen vim for ...
1
vote
How do I get a specific colorcolumn value?
How can I a) discover that I have more than
one value, and b) access that 2nd value?
a). By checking if the option contains a comma. I'd do so with a regular expression comparison. See :help =~:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
colorcolumn × 15highlight × 3
vimrc × 2
vimscript × 1
folding × 1
color × 1
alignment × 1
text-generation × 1
highlighting × 1
textwidth × 1