Yellow box at the end of each line

56 views
Skip to first unread message

Rudra Banerjee

unread,
Sep 19, 2012, 10:12:06 AM9/19/12
to v...@vim.org
Dear friends,
I am using vim-latex(http://vim-latex.sourceforge.net) and
fortran_codecomplete(http://www.vim.org/scripts/script.php?script_id=2487)

for my everyday use.
My vimrc is as follows:
$ cat .vimrc
set autoindent
set smartindent
set hlsearch
set incsearch
set ignorecase
set smartcase
set novisualbell
set paste
set ruler
set expandtab
set smarttab
set shiftwidth=3
set softtabstop=3
"set mouse=a "enable mouse
set nu "show line number
"set cul "highlight current line

if version >= 700
set spell spl=en_us
set nospell
nmap <F7> :set spell!
endif

" Fortran stuff
let fortran_do_enddo=1
let fortran_more_precise=1
let fortran_free_source=1

filetype on
filetype plugin on
filetype indent on

syntax enable

" Always jump to last edited line
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif

"let g:Imap_UsePlaceHolders = 0
set sw=2
set iskeyword+=:


The problem is, whenever I open a file with gvim, the last word of each
line is ^M. Though, it does not create any problem in compilation, its
odd and irritating to have a yellow box at each line.
is there anyway to do with this?

In my humble knowledge, this is caused by fortran codecomplete, but not
sure. The fileformat, checked using set ff? returns unix.

Charles Campbell

unread,
Sep 19, 2012, 11:09:56 AM9/19/12
to vim...@googlegroups.com
> au BufReadPost * if line("'\"")> 0&& line("'\"")<= line("$")
> \| exe "normal! g'\"" | endif
> endif
>
> "let g:Imap_UsePlaceHolders = 0
> set sw=2
> set iskeyword+=:
>
>
> The problem is, whenever I open a file with gvim, the last word of each
> line is ^M. Though, it does not create any problem in compilation, its
> odd and irritating to have a yellow box at each line.
> is there anyway to do with this?
>
> In my humble knowledge, this is caused by fortran codecomplete, but not
> sure. The fileformat, checked using set ff? returns unix.
>
>
Sounds like one of two cases:

* you're editing a file originally produced on a BillGates computer
on a Unix box
* you're editing a file on a BillGates computer that has one or more
lines missing that "yellow box".

I suspect that
:%s/\r$//
:w
:q
vim FileNameHere

will clean up the problem.

Regards,
Chip Campbell

Ben Fritz

unread,
Sep 19, 2012, 11:32:28 AM9/19/12
to vim...@googlegroups.com, v...@vim.org
It seems a file with DOS fileformat is not being detected properly by Vim.

What does this tell you?

:verbose set fileformats?

The string returned should contain "dos". The default for 'fileformats' contains "dos" on most systems, but a system .vimrc might be interfering. If so, setting it to "unix,dos" in your .vimrc might fix your problem.

If your 'fileformats' option already contains "dos", then likely the file you're editing does not actually contain a ^M on EVERY line, but just MOST lines (i.e. it is ALMOST DOS-format, but not quite). Try doing :e ++ff=dos after you've loaded the file.

See http://vim.wikia.com/wiki/Automatically_reload_files_with_mixed_line-endings_in_DOS_fileformat to make this happen automatically.

Tim Chase

unread,
Sep 19, 2012, 1:33:57 PM9/19/12
to v...@vim.org, Rudra Banerjee
On 09/19/12 09:12, Rudra Banerjee wrote:
> The problem is, whenever I open a file with gvim, the last word of each
> line is ^M. Though, it does not create any problem in compilation, its
> odd and irritating to have a yellow box at each line.
> is there anyway to do with this?

I suspect this is two separate things:

1) you have (as mentioned in a parallel thread) a file with DOS
newlines. Follow Tony's advice for getting rid of them.

2) you /also/ have them being highlighted yellow because it may have
been your last search. There are a couple ways to get rid of it
depending on what you want. If you never want to see your search
matches highlighted, you can issue ":set nohls" or put the line in
your vimrc (or rather, since you pasted your vimrc, remove the "set
hlsearch" line from it). If you just want to temporarily quiet Vim
from highlighting the match, but you want it to highlight future
searches, you can issue ":noh".

To learn more about each, you can read up at

:help 'hls'
:help :noh

-tim



rudra

unread,
Sep 20, 2012, 4:04:09 AM9/20/12
to vim...@googlegroups.com, v...@vim.org, Rudra Banerjee
Two question:
1) I am completely on linux, and have no connection with MS-dos or any other OS. So I dont know how that appeared.
2) The yellow boxes only comes when I press <F7> tab, as a map for code complete.
If I do a :%s/^M//g, those yellow box goes away, but if I hit <F7> again, it appears. Which, probably suggests that F7 has a extra map for searching pattern.
Is there any way to check all the maps I have with F7?

Tony Mechelynck

unread,
Sep 20, 2012, 8:11:08 AM9/20/12
to vim...@googlegroups.com, rudra
:verbose map <F7>
:verbose map! <F7>

Without the exclamation mark you'll get the maps for Normal, Visual and
Operator-Pending modes; with it, for Insert and Command-line modes; and
the :verbose prefix tells you where they were defined.

See
:help :verbose
:help verbose-cmd
:help :map-verbose
:help map-listing
:help :map_l
:help mapmode-nvo
:help mapmode-ic


Best regards,
Tony.
--
The District of Columbia has a law forbidding you to exert pressure on
a balloon and thereby cause a whistling sound on the streets.

Ben Fritz

unread,
Sep 20, 2012, 1:00:47 PM9/20/12
to vim...@googlegroups.com, v...@vim.org, Rudra Banerjee
On Thursday, September 20, 2012 3:04:09 AM UTC-5, rudra wrote:
> Two question:
>
> 1) I am completely on linux, and have no connection with MS-dos or any other OS. So I dont know how that appeared.
>
> 2) The yellow boxes only comes when I press <F7> tab, as a map for code complete.
>
> If I do a :%s/^M//g, those yellow box goes away, but if I hit <F7> again, it appears. Which, probably suggests that F7 has a extra map for searching pattern.
>

The fortran_complete plugin you're using includes this line:

vim.command('s/$/\x0D\x0D/') # insert two lines

This probably explains the highlight showing up, since the command given will set the last search pattern to match whatever is at the end of a line.

As for the ^M characters getting inserted, I don't know what would cause that. I wonder if maybe the same vim.command in python is having problems with the hex values in the replacement string. I THINK that command is basically causing Vim to do s/$/^M^M/ which SHOULD work, but it's better written as s/$/\r\r/ which would not have any literal byte values in it. I don't know python, but I imagine this would accomplish the latter:

vim.command('s/$/\\r\\r/') # insert two lines

Then you can turn off highlight after the new command:

vim.command('nohls') # suppress search highlight

Maybe you can make that modification, restart Vim, and see what happens. If it fixes your problem, you should contact the plugin maintainer with your changes. Otherwise...I have no idea what might be going on.

Rudra Banerjee

unread,
Sep 20, 2012, 2:08:43 PM9/20/12
to Ben Fritz, vim...@googlegroups.com, v...@vim.org
Thanks,
Its working!
I will contact codecomplete developer

Ben Fritz

unread,
Sep 20, 2012, 3:36:46 PM9/20/12
to vim...@googlegroups.com, v...@vim.org, Rudra Banerjee
On Thursday, September 20, 2012 12:00:47 PM UTC-5, Ben Fritz wrote:
> As for the ^M characters getting inserted, I don't know what would cause that. I wonder if maybe the same vim.command in python is having problems with the hex values in the replacement string. I THINK that command is basically causing Vim to do s/$/^M^M/ which SHOULD work, but it's better written as s/$/\r\r/ which would not have any literal byte values in it. I don't know python, but I imagine this would accomplish the latter:
>
> vim.command('s/$/\\r\\r/') # insert two lines
>
> Then you can turn off highlight after the new command:
>
> vim.command('nohls') # suppress search highlight
>

I did try sourcing this file in Windows gvim 7.3.661:

python << EOF
import vim
vim.command('s/$/\x0D\x0D/')
EOF


I did NOT get any ^M characters inserted into my text, but I DID get search highlight turned on. So possibly the only change needed is the 'nohls' command, or even better a save/restore of the last search.
Reply all
Reply to author
Forward
0 new messages