Tuesday, September 27, 2011

Re: Highlight current line number when using "set number"



On Wed, Sep 28, 2011 at 7:53 AM, Tony Mechelynck <antoine.mechelynck@gmail.com> wrote:
On 26/09/11 16:03, Francesc Salvat-Pujol wrote:
On Mon, Sep 26, 2011 at 2:07 PM, Ben Fritz <fritzophrenic@gmail.com
<mailto:fritzophrenic@gmail.com>> wrote:



   On Sep 25, 4:04 am, Francesc Salvat-Pujol <f.sal...@gmail.com
   <mailto:f.sal...@gmail.com>> wrote:
    > Hi,
    >
    > When using the option "set number", is there a way of
   highlighting the
    > current line number with a color other than LineNr? Using "set
   cuc cul"
    > is too much.
    >
    > I am aware that the question has been asked before, i.e.
    >
    >
   http://groups.google.com/group/vim_use/browse_thread/thread/90adce932...
    >
    > or with slightly different approach:
    >
    >
   http://groups.google.com/group/vim_use/browse_thread/thread/83fa20161...
    >
    > Unfortunately, none of these threads really offer a solution in the
    > sense described at the beginning of the mail.
    >
    > Any ideas?
    >

   That second thread offers a method which will get you closer, but even
   using the signs feature, I don't think Vim can highlight a specific
   line number in the line number column, and only the line number column
   (i.e. not the line text).

   Probably your best bet is to just set a cursorline highlight which is
   not too distracting and use that.


Uhum... Well, too bad.

Thanks for the replies though.

Cheers,

Cesc

In gvim (where the Normal background is white) (and in 256-color consoles with the CSApprox.vim plugin) I use the following in my "almost-default" colorscheme, http://users.skynet.be/antoine.mechelynck/vim/almost-default.vim

       hi clear CursorLine
       hi CursorLine guibg=#F4F4F4
       hi clear CursorColumn
       hi link CursorColumn CursorLine

which give me crosshairs in very light grey (95.7% grey), just enough to be visible, not enough to be distracting.


Best regards,
Tony.
--
"APL is a write-only language.  I can write programs in APL, but I
can't read any of them."
               -- Roy Keir

I'm actually using the terminal vim, but thx anyway. One day with some time and courage I might try to checkout the vim source and see if it's really that hard for a newbie to add a CurrentLineNr highlight group and print the current line number in the corresponding color.

Thx for the tips,

Cesc

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Highlight current line number when using "set number"

On 26/09/11 16:03, Francesc Salvat-Pujol wrote:
> On Mon, Sep 26, 2011 at 2:07 PM, Ben Fritz <fritzophrenic@gmail.com
> <mailto:fritzophrenic@gmail.com>> wrote:
>
>
>
> On Sep 25, 4:04 am, Francesc Salvat-Pujol <f.sal...@gmail.com
> <mailto:f.sal...@gmail.com>> wrote:
> > Hi,
> >
> > When using the option "set number", is there a way of
> highlighting the
> > current line number with a color other than LineNr? Using "set
> cuc cul"
> > is too much.
> >
> > I am aware that the question has been asked before, i.e.
> >
> >
> http://groups.google.com/group/vim_use/browse_thread/thread/90adce932...
> >
> > or with slightly different approach:
> >
> >
> http://groups.google.com/group/vim_use/browse_thread/thread/83fa20161...
> >
> > Unfortunately, none of these threads really offer a solution in the
> > sense described at the beginning of the mail.
> >
> > Any ideas?
> >
>
> That second thread offers a method which will get you closer, but even
> using the signs feature, I don't think Vim can highlight a specific
> line number in the line number column, and only the line number column
> (i.e. not the line text).
>
> Probably your best bet is to just set a cursorline highlight which is
> not too distracting and use that.
>
>
> Uhum... Well, too bad.
>
> Thanks for the replies though.
>
> Cheers,
>
> Cesc

In gvim (where the Normal background is white) (and in 256-color
consoles with the CSApprox.vim plugin) I use the following in my
"almost-default" colorscheme,
http://users.skynet.be/antoine.mechelynck/vim/almost-default.vim

hi clear CursorLine
hi CursorLine guibg=#F4F4F4
hi clear CursorColumn
hi link CursorColumn CursorLine

which give me crosshairs in very light grey (95.7% grey), just enough to
be visible, not enough to be distracting.


Best regards,
Tony.
--
"APL is a write-only language. I can write programs in APL, but I
can't read any of them."
-- Roy Keir

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Remembering syntax when moving in and out of buffers

On Sep 25, 8:42 pm, "Benjamin R. Haskell" <vim@benizi.com> wrote:
> On Sun, 25 Sep 2011, Spiros Bousbouras wrote:
> > On Sep 21, 7:38 pm, "Benjamin R. Haskell" wrote:
> >> On Wed, 21 Sep 2011, Spiros Bousbouras wrote:
> >>> On Sep 18, 11:14 pm, "Benjamin R. Haskell" wrote:
>
> 2. If you disable filetype- and syntax-highlighting behaviors, you
> shouldn't also be surprised when trying to do filetype- and
> syntax-highlighting things turns out to not work as expected.

The only thing I found surprising was that I was moving away from the
buffer , returning to it and the syntax wasn't remembered whereas
buffer specific variables were. Even if filetype detection was on and
I had put myfile.vim of my opening post under the appropriate
directory , the syntax highlighting commands would still get
reexecuted when returning to the buffer and that I find surprising.
I hadn't thought of the distinction between unloading the buffer and
simply moving away from the buffer. After all , if you really want to
unload a buffer you do :bunload

> >>> Right. This brings us back to what I was saying in the OP namely
> >>> that it is a strange design choice. Note in particular that buffer
> >>> local variables are remembered yet syntax is not. As I understand it
> >>> , syntax is buffer specific. So why would syntax from other files
> >>> have to be cleared and why would proper syntax have to be reloaded ?
> >>> I can't think of a scenario where I'm editing a buffer , set up a
> >>> syntax , move away , return to the buffer and now a different syntax
> >>> has to be valid.

There is one : you are editing a buffer *and* the syntax highlighting
file for the buffer. So you start with the buffer , then move to the
highlighting file , make some changes and then return to the buffer.
Obviously you want the new syntax to take effect.

> >> It's not that you're just moving from one buffer to another. It's
> >> that you are unloading the file entirely (because you don't/didn't
> >> have 'hidden' set). When you load a file, its syntax starts fresh,
> >> and needs to be set up. No way around that.
> >
> > Yes , I understand how it works , I was just saying that I find it
> > strange. I thought you agreed with me earlier that it is strange.
>
> I found it strange that *moving* from one buffer and back changed your
> settings. I didn't realize when I agreed that it was strange that (1)
> you weren't just moving between windows (buffers != windows, but I made
> that bad assumption), and (2) that you didn't use 'hidden' (so it's not
> just moving between buffers -- you're loading a file every time you
> switch to a buffer).
>
> I find nothing strange about the way loading syntax-highlighting
> actually works, at least in the 'hidden' case. I do find it strange
> that buffer-specific variables are kept in that case.

You mean when 'hidden' is off , yes ? If buffer specific variables
weren't kept it would at least be consistent and the example of my
opening post would work as I expected even with filetype detection
off.

> > What prompted me to set autowriteall was exactly because I often tend
> > to move between different files and I found it irritating having to
> > add a ! to the commands for moving. Anyway I am more worried about
> > whether there is some sequence of key presses which will take me out
> > of vim without saving changes.
>
> Not without '!', as far as I'm aware.

Ok , then it's safe.

> > If I'm not sure that I want to keep the
> > changes I'm making to some file I just create a copy of it before
> > modifying it.
>
> That sounds like something that will just create a large amount of work
> removing one-off files later.

If it happened often yes but it's a very rare occurrence. Until this
thread I even had 'hidden' off which meant that when I moved away
from a buffer not only it saved it but I couldn't even undo changes
when I returned (with vim 7.1) .On one occasion in the last several
years it caused me to lose a minor piece of information when I
deleted the line which had it and then moved away from the buffer but
otherwise this set up has worked fine. But having 'hidden' on seems
to be better.

> > What does using option filetype buy you when you do use the normal
> > filetype detection mechanism ? One advantage I can see is that it
> > makes it easier to use plugins by other people. But if you're using a
> > file type of your own does using the filetype option offer you
> > anything ?
>
> Only consistency. Putting commands in one file
> (~/vim-scripts/myfile.vim) or another (~/vim-scripts/syntax/myfile.vim)
> shouldn't be *that* much of a hassle. And if you do it the way other
> filetypes do it (use the standard filenames), it happens the same way
> (they get loaded when they're needed).
>
> But, if you *really* don't use other filetypes, and disable the filetype
> detection mechanism anyway, there's no point to that consistency, since
> it's unused. So, the answer is "nothing". There's nothing better about
> doing it the right way when you disable all but your custom filetype(s).

Ok.

> > I also don't like how the functionality for one type of file is split
> > among several directories which will in general also contain
> > functionality for other kinds of files. So instead of having for
> > example one directory with all the plugins for say C source code , you
> > have a syntax directory where you have syntax stuff for C code , Lisp
> > code , etc. and then another directory for indentation stuff for C
> > code , Lisp code etc. and so forth for all other kinds of
> > functionality vim supports.
>
> It's organized by Vim function (ftdetect, ftplugin, syntax, indent)
> rather than by language. That split probably makes the most sense for
> filetype-detection, since a lot of it is used to determine what filetype
> you're in, so differentiating one dialect from another, or two filetypes
> that share common extensions [pl = Prolog / Perl] touches more than one
> "language".
>
> That the other three (syntax / indent / ftplugin) are also split in the
> same way probably has to do with being able to independently
> enable/disable the functionality. (You can turn filetype plugins on
> without filetype syntax with or without filetype indenting.)
>
>
> > This is different than the way code is organised in every other
> > programming language I know of.
>
> Virtually every programming language has conventions for where to load
> its library files. VimL (the language Vim uses) is no different.
>
> Though, you may be right that it would make more sense to see:
>
> c/ftplugin.vim
> c/syntax.vim
> c/indent.vim
> java/ftplugin.vim
> java/syntax.vim
> java/indent.vim
> lisp/ftplugin.vim
> lisp/syntax.vim
> lisp/indent.vim

Yes , that's the kind of thing I had in mind.

> > Say I want to have a listing of all the files associated with some
> > filetype. With the way things get done outside of vim you would use a
> > single ls command or a single find command. But with the way vim
> > organises things how do you do it ?
>
> One way would be to load a file of that type and run :scriptnames. But
> even that's not enough, because there's also an autoload mechanism. And
> as you yourself were doing previously, you can simply put a :source
> command into an autocmd. So, there's no nice, consistent way to get a
> full list. But why do you need that list anyway? If you're not using
> the normal mechanisms, that list won't matter.

I don't absolutely need it but it would be nice to have. Say I'm
curious to see what the total size of all lisp plugins is. Then if
things were organised the way I'm suggesting I could do (from the
shell command line)
wc lisp/*
The way things are organised I have to use something a bit more
complicated.
Or say I want to copy all the lisp plugins or send them over an email
or something. Then I could do
tar cf ~/vim-lisp.tar lisp
As things are I have to either learn a new tool , vimball , or again
use a more complicated tar command. In either case what I have to do
is not a lot more complicated but still it's a minor annoyance. I
also wonder whether the way I'm suggesting would work better with
version control software.

> If you do come around and decide to use the normal mechanism, the
> following seems like a good first pass:
>
> fun! FindFilesForType(ft)
> return split(globpath(&rtp,'{ftdetect,syntax,indent,ftplugin}/{,after/}'.a:ft.'{,{/,_}*}.vim'), "\n")
> endfun
>
> It will miss autoload files. (often used for 'omnicomplete' and by
> ftplugins)

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Remembering syntax when moving in and out of buffers

On Sep 25, 6:09 pm, Tony Mechelynck <antoine.mechelynck@gmail.com>
wrote:
> On 25/09/11 18:48, Tony Mechelynck wrote:
>
> > On 25/09/11 17:35, Spiros Bousbouras wrote:

> >> I also don't like how the functionality for one type of file is split
> >> among several directories which will in general also contain
> >> functionality for other kinds of files. So instead of having for
> >> example one directory with all the plugins for say C source code ,
> >> you have a syntax directory where you have syntax stuff for C code ,
> >> Lisp code , etc. and then another directory for indentation stuff for
> >> C code , Lisp code etc. and so forth for all other kinds of
> >> functionality vim supports. This is different than the way code is
> >> organised in every other programming language I know of. Say I want
> >> to have a listing of all the files associated with some filetype.
> >> With the way things get done outside of vim you would use a single ls
> >> command or a single find command. But with the way vim organises
> >> things how do you do it ?
> >>
> >
> > Easy.
> > For all files currently loaded in Vim:
> >
> > :filetype on " unnecessary if already set
> > :echomsg 'Files of type foobar currently loaded:'
> > :bufdo if &ft == 'foobar' echomsg bufnr('%') . ':' expand('%:p') | endif
> >
> > For all files in a given directory:
> >
> > :filetype on " unnecessary if already set
> > :cd /some/place
> > :args *
> > :echomsg 'Files of type foobar in /some/place'
> > :argdo if &ft == 'foobar' echomsg expand('%:t') | endif
> >
> > See
> > :help :bufdo
> > :help :argdo
> > :help expr-option
> > :help :echomsg
> > :help expand()
> > :help filename-modifiers
> > etc.
>
> Oh, and if you meant all the Vim scripts which handle a given filetype
> (let's say foobar) it's also rather easy:

Yes , that's what I meant and I also meant from the shell command
line rather than from within vim .

> just list any file named
> ftplugin/foobar.vim ftplugin/foobar_*.vim or ftplugin/foobar/*.vim below
> any directory listed in 'runtimepath'. Since the default syntax is
> usually the same as the filetype, you may want to add syntax/foobar.vim
> and syntax/foobar/*.vim to these.
>
> see :help 'runtimepath'

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Remembering syntax when moving in and out of buffers

On Sep 25, 5:48 pm, Tony Mechelynck <antoine.mechelynck@gmail.com>
wrote:
> On 25/09/11 17:35, Spiros Bousbouras wrote:
> > On Sep 21, 7:38 pm, "Benjamin R. Haskell"<vim@benizi.com> wrote:
> >> On Wed, 21 Sep 2011, Spiros Bousbouras wrote:
> >>> On Sep 18, 11:14 pm, "Benjamin R. Haskell" wrote:
>
> > I wasn't trying to disable the normal filetype detection mechanisms
> > per se , I was trying to get rid of functionality I found irritating
> > and which seemed to be the result of filetype detection. It's been
> > around 4 years so I don't remember for sure but I think that one
> > thing that annoyed me was that I was writing Scheme code , added a
> > ; in the beginning of some line (which counts as a comment in Scheme)
> > and then vim started adding a ; at the beginning of all subsequent
> > lines.
>
> That's customizable. I think that
>
> :set fo-=c fo-=r fo-=o fo-=q
>
> will disable all comment formatting and all comment leaderinsertion;
> though youmay want something less drastic, see :help fo-table

I never doubted it would be customizable. But disabling
filetype detection altogether is even simpler.

> > I think it also did parenthesis matching which I found
> > distracting and possibly also syntax highlighting which yet again I
> > found distracting.
>
> That is also customizable.
>
> Method I: to disable it entirely: add the line
>
> let loaded_matchparen = 1
>
> in your vimrc.
>
> Method II: to disable it by default, but with possibility to re-enable:
> add the line
>
> au VimEnter * NoMatchParen
>
> to your vimrc. You can then use
>
> :DoMatchParen
>
> and
>
> :NoMatchParen
>
> to enable and disable parenthesis matching respectively, see :help
> matchparen

Thanks but whenever I'm in doubt that my parentheses , braces or
whatever match I do % .But having it on all the time is just
distracting. My general mentality when using applications is "don't
show me something unless I asked for it" unless I'm about to make a
really big screw up. So you can see that before I disabled filetype
detection and vim was showing me all that stuff I hadn't asked for it
was driving me up the wall.

> Compiling your own Vim will by default put the executable in
> /usr/local/bin, equate (if unset) $VIM with /usr/local/share/vim,
> $VIMRUNTIME with /usr/share/vim/vim73, and look for the system vimrc at
> $VIM/vimrc. When compiled by a distro, I'm not 100% sure about Debian,
> but typical settings (as used by openSUSE) are /usr/bin, /usr/share/vim,
> /usr/share/vim/vim73 and /etc/vimrc. Both will look for your own vimrc
> at ~/.vimrc. So if you have both, your own Vim takes precedence (it is
> first in the $PATH) and the distro stuff isn't used.

In my case there is a /usr/share/vim/vimrc which is a symbolic link
to /etc/vim/vimrc .I do have a ~/.vimrc but /etc/vim/vimrc still
gets executed. /etc/vim/vimrc has a line
runtime! debian.vim
which I have commented out.

> >>>> I wasn't using -u NONE, sorry. I was explaining what goes wrong
> >>>> without it. In the -u NONE case that you present, it gets cleared
> >>>> because syntax starts fresh prior to loading each new buffer, so that
> >>>> filetype detection can detect the file and load the proper syntax
> >>>> without having to worry about clearing out the syntax of whatever
> >>>> other file or files are open.
>
> >>> Right. This brings us back to what I was saying in the OP namely that
> >>> it is a strange design choice. Note in particular that buffer local
> >>> variables are remembered yet syntax is not. As I understand it ,
> >>> syntax is buffer specific. So why would syntax from other files have
> >>> to be cleared and why would proper syntax have to be reloaded ? I
> >>> can't think of a scenario where I'm editing a buffer , set up a syntax
> >>> , move away , return to the buffer and now a different syntax has to
> >>> be valid.
>
> If you don't set hidden, and use ":filetype plugin on" and ":syntax on",
> the syntax highlights will be loaded once per buffer at buffer load. I'm
> not sure what happens with 'hidden'.

I tried these precise settings (with 'hidden' off) and repeated the
test of my opening post. Leaving the buffer and returning still turns
off syntax highlighting.

> If you use :syntax on followed by :filetype off, you won't by default
> get any highlighting since filetypes won't be detected. You can then set
> syntax for one file by means of
>
> :setlocal syntax=foobar
>
> and by using :setlocal you will avoid changing the syntax settings of
> other present or future buffers.
>
> If you want no highlighting in general but automatic syntax highlighting
> for sompe particular files, you can have
>
> syntax on
> filetype off
>
> (in that order) in your vimrc, then a syntax-setting modeline near the
> beginning or the end of the files which interest you. Here are a few
> examples of such modelines:

No , no , no , having option modeline on is dangerous.

> // vim:ft=cpp:
>
> /* vim: set ft=c :*/
>
> <!-- vim: set ft=html :-->
>
> # vim:ft=sh:
>
> vim:tw=78:ts=8:ft=help:norl:

[...]

> >> All of the filetype-related "behind the scenes" stuff is well-documented under
>
> >> :help filetypes
>
> >> Other sources of info:
> >> :help :setfiletype
> >> :help 'filetype'
>
> > Yes , I read some of it before and after starting the thread but it's
> > quite big and I don't have the time to read the whole of it in
> > detail.
>
> If you don't have the time to get to know your tools, it's not my fault
> if you can't use them.

What do you mean it's not your fault , of course it is your
fault :-D

> You should take the time to read the help about
> anything in Vim that you don't yet know inside and out (and even
> occasionally about some things that you think you do know inside and
> out), in the long run it will make you more proficient,

Not necessarily. Not all vim functionality is useful to all people.
Some of it may increase my productivity but some won't. It's possible
that reading in detail all the filetype related documentation would
increase my productivity but based on what I have read and what
people here say , it seems unlikely. If I had time to read everything
I want then I would read it but since I don't , I have to go by the
odds and the odds in this case are that it won't help me.

> and the hour
> (maybe) that you "lose" today will be repaid over and over by "winning",
> maybe, ten minutes every day: in this example the "debt" will be repaid
> in a week.

A week ? Not likely since it would take me a lot more than a week to
learn inside out all vim functionality.

> It's the old proverb: Give a man a fish, he'll eat for one
> day. Teach him how to fish, he'll eat his whole life long.
>
> > I also don't like how the functionality for one type of file is split
> > among several directories which will in general also contain
> > functionality for other kinds of files. So instead of having for
> > example one directory with all the plugins for say C source code ,
> > you have a syntax directory where you have syntax stuff for C code ,
> > Lisp code , etc. and then another directory for indentation stuff for
> > C code , Lisp code etc. and so forth for all other kinds of
> > functionality vim supports. This is different than the way code is
> > organised in every other programming language I know of. Say I want
> > to have a listing of all the files associated with some filetype.
> > With the way things get done outside of vim you would use a single ls
> > command or a single find command. But with the way vim organises
> > things how do you do it ?

Silly me , I forgot that vim also has ls and find commands. I meant
get a listing from the shell command line and the Unix ls and find
commands.

> Easy.
> For all files currently loaded in Vim:
>
> :filetype on " unnecessary if already set
> :echomsg 'Files of type foobar currently loaded:'
> :bufdo if &ft == 'foobar' echomsg bufnr('%') . ':' expand('%:p') | endif
^
Needs a | here

> For all files in a given directory:
>
> :filetype on " unnecessary if already set
> :cd /some/place
> :args *
> :echomsg 'Files of type foobar in /some/place'
> :argdo if &ft == 'foobar' echomsg expand('%:t') | endif
>
> See
> :help :bufdo
> :help :argdo
> :help expr-option
> :help :echomsg
> :help expand()
> :help filename-modifiers
> etc.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Substitutions Triggered by autocmd Are Noisy

Tony Mechelynck a écrit :

> Try setting 'cmdheight' to 2 or even 3 in your vimrc

Since I'm not willing to permanently change cmdheight and since my first
attempt at temporarily modifying it failed, I looked at my .muttrc and I
changed the following line:

set editor = "vim +/^$ ++1"

to

set editor = "vim"

And now, things work as expected.

Thanks everyone,
--
Bastien

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Vim spellcheck

Hi Thomas!

On Di, 27 Sep 2011, Thomas wrote:

> On 27 September 2011 15:23, Matteo Landi <landimatte@gmail.com> wrote:
> Now with "set spell spelllang=de_de" in my .vimrc the spellchecking is
> always correct, but actually I just want to use this feature in a few
> text-files.

http://vimhelp.appspot.com/vim_faq.txt.html#faq-26.1

regards,
Christian

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php