Re: session: settings lost

2009-07-21 Thread fka...@googlemail.com



Tony Mechelynck wrote:
 Hm. Sure you haven't got options? Check it by

   :verbose set ssop?

Yes.

 Hooking
 the BufWinEnter autocommand is not necessary because 'filetype' is a
 buffer-local (not window-local) option.

Ok, good to know. I added it once because of another wrong assumption
(see below).


 I
 can't understand why wiping or not wiping one temporary buffer could
 make a difference though.

Me neither, however it has certainly to do with the solution (see
below).


 To set 'expandtab' for txt files only and not for other files, your
 ftplugin/txt.vim should contain

   setlocal expandtab

 (not set expandtab) in order not to clobber the global default for
 other files.

That helped. I changed everything in ftplugins/ to use setlocal
(instead of changing global settings always by using 'set' together
with BufWinEnter events, see above). Probably there where holes in
this strategy which caused the missbehaviour with the mentioned
session file commands.

Thank you so much, also for the other helpful pointers!

 Felix
--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: is syntax highlighting and auto indentation handled by seperate description files in vim?

2009-07-21 Thread Tony Mechelynck

On 21/07/09 01:33, Rahul wrote:

 Is syntax highlighting and auto indentation handled differently by
 vim? I know that for most languages my files are syntax highlighted as
 well as if I visual select and  press '=' then I can get a nice-
 looking indentation too.

 I just started editing a .json file and to start with it had neither
 highlighting nor indentation. I downloaded a suitable syntax file and
 now have syntax highlighting enabled but still cannot get it to indent
 in a smart way.

 Any suggestions?

 --
 Rahul

Yes, syntax highlighting and indenting are handled by different scripts. 
Syntax scripts are in the syntax/ subfolder of directories in 
'runtimepath', indent scripts are in the indent/ subfolder.

However, you should never change anything in $VIMRUNTIME or under it, 
because any upgrade may silently remove any changes you make there. Here 
are what the 'runtimepath' directory trees are meant for:

~/.vim/ (Unix)
~/vimfiles/ (Windows)
user-private full-fledged scripts

$VIM/vimfiles/  (all platforms)
system-wide scripts not distributed with Vim

$VIMRUNTIME/(all platforms)
ONLY what came together with Vim

$VIM/vimfiles/after/(all platforms)
system-wide small tweaks to any of the above

~/.vim/after/   (Unix)
~/vimfiles/after/   (Windows)
user-private small tweaks to any of the above

Most of these don't exist by default; they only need to exist when you 
need to put something in them. They all have the same structure.

Indent scripts are mostly used to set either the 'indentexpr' option or 
the 'cindent' and 'cinoptions' options. They should ALWAYS SET THEM 
BUFFER-LOCALLY using the :setlocal command, not the :set command 
(which could clobber the settings for other unrelated files). See 
$VIMRUNTIME/indent/*.vim for examples.


Best regards,
Tony.
-- 
hundred-and-one symptoms of being an internet addict:
86. E-mail Deficiency Depression (EDD) forces you to e-mail yourself.

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Tag syntax highlighting

2009-07-21 Thread Tinou

 I'm trying to make my vim highlight all defined type from a C++
 project tag file.

 I found this function:


 function! s:highlight() let list = taglist('.*')
    for item in list
        let kind = item.kind
        if kind == 'f' || kind == 'c'
            let name = item.name
            exec 'syntax keyword Identifier '.name
        endif
    endfor
 endfunction


 It does exactly what I want but is horribly slow :-(

 I tried :echo taglist('.*') which is what takes most time (the project
 tree is quite big). But doing :echo taglist('TYPE.*') returns almost
 immediately. I didn't manage to make the function (which I only partly
 understand) work with it.

Hello again,

I've read the doc (as I should have done in the first place) and
discovered the argument passed to taglist() is a regexp of tags to be
found.

What I still don't understand in the function is the item.kind. Where is
this documented ?


-- 
Étienne

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Tag syntax highlighting

2009-07-21 Thread Matt Wozniski

On Tue, Jul 21, 2009 at 5:37 AM, Tinou wrote:

 I'm trying to make my vim highlight all defined type from a C++
 project tag file.

 I found this function:


 function! s:highlight() let list = taglist('.*')
    for item in list
        let kind = item.kind
        if kind == 'f' || kind == 'c'
            let name = item.name
            exec 'syntax keyword Identifier '.name
        endif
    endfor
 endfunction


 It does exactly what I want but is horribly slow :-(

 I tried :echo taglist('.*') which is what takes most time (the project
 tree is quite big). But doing :echo taglist('TYPE.*') returns almost
 immediately. I didn't manage to make the function (which I only partly
 understand) work with it.

 Hello again,

 I've read the doc (as I should have done in the first place) and
 discovered the argument passed to taglist() is a regexp of tags to be
 found.

 What I still don't understand in the function is the item.kind. Where is
 this documented ?

At :help taglist()


taglist({expr}) *taglist()*
Returns a list of tags matching the regular expression {expr}.
Each list item is a dictionary with at least the following
entries:

kindType of the tag.  The value for this
entry depends on the language specific
kind values.  Only available when
using a tags file generated by
Exuberant ctags or hdrtag.


If you mean what does it do in C/C++, you'd have to consult the
ctags docs, I'd imagine.

~Matt

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



[vim_use] Abbreviating a command

2009-07-21 Thread John Sampson

Hello -

Many thanks - but even after searching the manual etc. I do not
understand how this solution
is constructed or arrived at. Perhaps Vim is not for me.

Regards

_John Sampson_

John Beckett wrote:
 John Sampson wrote:
   
 I want to change lines of the form
 able|baker|charlie|dog|easy

 to
 baker|able|charlie|dog|easy
 

 A quick test with the following worked ok:

 :nnoremap F8 :s/\([^\|]*\)\|\([^\|]*\)\(.*\)/\2\|\1\3/CR:nohCR

 John

   



__ Information from ESET NOD32 Antivirus, version of virus signature 
database 4263 (20090721) __

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com



--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: [vim_use] Abbreviating a command

2009-07-21 Thread François Ingelrest

On Tue, Jul 21, 2009 at 13:11, John Sampsonjrs@ntlworld.com wrote:
 Many thanks - but even after searching the manual etc. I do not
 understand how this solution
 is constructed or arrived at. Perhaps Vim is not for me.

What don't you understand? The most complicated part of it is the
regular expression, which you already figured out in your first
e-mail. The rest is just a mapping, saying when I press F8, execute
what follows, and what follows is the substitute command. The 'noh'
part is used to avoid keeping the searched pattern highlighted.

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Tag syntax highlighting

2009-07-21 Thread Tinou

 If you mean what does it do in C/C++, you'd have to consult the
 ctags docs, I'd imagine.

Aha! Yes, I did find useful information doing:

ctags --list-kinds=c++

Thanks

-- 
Étienne

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: [vim_use] Abbreviating a command

2009-07-21 Thread John Sampson

Hello -

I didn't understand the 'noh' part, nor why ':map' wouldn't do but it
has to be ':nnoremap',
whatever that is. It is mentioned in the manual, but not really
explained, as far as I can see.

I would never have guessed that I had to use ':nnoremap'.

Regards

_John_

François Ingelrest wrote:
 On Tue, Jul 21, 2009 at 13:11, John Sampsonjrs@ntlworld.com wrote:
   
 Many thanks - but even after searching the manual etc. I do not
 understand how this solution
 is constructed or arrived at. Perhaps Vim is not for me.
 

 What don't you understand? The most complicated part of it is the
 regular expression, which you already figured out in your first
 e-mail. The rest is just a mapping, saying when I press F8, execute
 what follows, and what follows is the substitute command. The 'noh'
 part is used to avoid keeping the searched pattern highlighted.
   



__ Information from ESET NOD32 Antivirus, version of virus signature 
database 4264 (20090721) __

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com



--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Abbreviating a command

2009-07-21 Thread Ben Fritz



On Jul 21, 8:20 am, John Sampson jrs@ntlworld.com wrote:
 Hello -

 I didn't understand the 'noh' part, nor why ':map' wouldn't do but it
 has to be ':nnoremap',

Well, technically just :map should also work. The main trick is
probably making sure you include the ':' at the beginning and the
CR at the end. You didn't provide the map command you attempted to
use, so I'm just guessing one of those may have caused a problem. So,
stolen from John, this should also work:

:map F8 :s/\([^\|]*\)\|\([^\|]*\)\(.*\)/\2\|\1\3/CR

The main difference between :map and :noremap is that :noremap uses
the built-in functionality of each part of the right-hand-side,
whereas :map uses any other maps you may have defined.

You can refine this further by adding a mode descriptor. :nmap
and :nnoremap define mappings that only take effect in normal
mode, :vmap and :vnoremap in visual mode, etc. So using :nnoremap
instead of :map is a good idea (though not strictly necessary) because
it only takes effect in normal mode, and it doesn't do anything
unexpected if you ever define another mapping using some of right-hand-
side of this mapping.

 Perhaps Vim is not for me.

Vim has a very steep learning curve, and there's not much we can do to
change that. Once you've mastered it, however, it will make you far
more efficient, paying for your initial time investment many times
over.

It looks like you have general idea what you're doing, so I imagine
you've already ran the tutorial. If not...do so. You can also learn a
great deal just reading emails or archives on this list, by reading
through chapters of the :help, or by following the Random page link
on vim.wikia.com a few times a day. Stick with it. You'll be glad you
did.
--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Fatal exceptions

2009-07-21 Thread Thomas Allen

I've written a little project abstraction script for Vim, but one
problem is that it throws a series of errors if the specified project
does not exist. At the exit of s:ProjGetInfo, you'll see that I've
raised the error, but I need this exception to be fatal -- the script
should not resume. How can I do that (or is there a safer way to code
the line that assigns ProjGetInfo's return value to project)?

let g:ProjFileBrowser = 'NERDTree'
let g:ProjFile = '~/.vimproj'

fun! s:OpenProj(name)
let project = s:ProjGetInfo(a:name)
exec 'cd ' . project['path']
 Customization file is not required
if has_key(project, 'vim') == 1
exec 'so ' . project['vim']
end
exec g:ProjFileBrowser
endf

fun! s:ProjGetInfo(name)
try
let s:Config = readfile(expand(g:ProjFile))
catch /E484.*/
exec s:echoError('Could not read project file ' .
g:ProjFile . '')
endt

let projects = {}
let title = ''

 Simple ini parser
for line in s:Config
let line = s:strip(line)
if strlen(line)  0
if match(line, '[') == 0
let title = strpart(line, 1, strlen(line) - 2)
let projects[title] = {}
else
let option = map(split(line, '='), 's:strip(v:val)')
let key = option[0]
let projects[title][key] = option[1]
end
end
endfo

if has_key(projects, a:name) == 1
return projects[a:name]
else
exec s:echoError('Project ' . a:name . ' not found in ' .
g:ProjFile)
end
endf

 Stole these two functions from NERDTree
fun! s:echo(msg)
redraw
echomsg 'Proj: ' . a:msg
endf

fun! s:echoError(msg)
echohl errormsg
call s:echo(a:msg)
echohl normal
endf
 But nothing else

fun! s:strip(text)
return substitute(a:text, '\s', '', 'g')
endf

 Commands
command! -n=1 Proj :call s:OpenProj(args)
--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Abbreviating a command

2009-07-21 Thread Efraim Yawitz
On Tue, Jul 21, 2009 at 4:40 PM, Ben Fritz fritzophre...@gmail.com wrote:


 It looks like you have general idea what you're doing, so I imagine
 you've already ran the tutorial. If not...do so. You can also learn a
 great deal just reading emails or archives on this list, by reading
 through chapters of the :help, or by following the Random page link
 on vim.wikia.com a few times a day. Stick with it. You'll be glad you
 did.


I'll second that and add (based on my own experience) that you can learn one
little bit at a time, and use whatever subset you know.  There is no need to
know every detail.

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Fatal exceptions

2009-07-21 Thread Ben Fritz



On Jul 21, 9:15 am, Thomas Allen thomasmal...@gmail.com wrote:
 I've written a little project abstraction script for Vim, but one
 problem is that it throws a series of errors if the specified project
 does not exist. At the exit of s:ProjGetInfo, you'll see that I've
 raised the error, but I need this exception to be fatal -- the script
 should not resume. How can I do that (or is there a safer way to code
 the line that assigns ProjGetInfo's return value to project)?

:help :echoerr
--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Fatal exceptions

2009-07-21 Thread Ben Fritz



On Jul 21, 9:15 am, Thomas Allen thomasmal...@gmail.com wrote:
 I've written a little project abstraction script for Vim

Out of curiosity (I'm not discouraging you from trying it yourself),
have you tried Project.vim? Or is this something entirely different?

http://www.vim.org/scripts/script.php?script_id=69
--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Fatal exceptions

2009-07-21 Thread Ben Fritz



On Jul 21, 11:27 am, Ben Fritz fritzophre...@gmail.com wrote:
 :help :echoerr

Scratch that, I guess it doesn't work the way I thought it did.

I tried this:

function! Ech() abort
  let g:var = 0
  echoerr Die die die!
  let g:var = 99
endfu

but after running the function, g:var is equal to 99. What gives?
Apparently an error message (:help :echoerr) doesn't count as an
error is detected?

Using :throw works, but the error message looks pretty bad:

function! Ech()
  let g:var = 0
  throw Die die die!
  let g:var = 99
endfu
--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Fatal exceptions

2009-07-21 Thread Ben Fritz



On Jul 21, 11:44 am, Ben Fritz fritzophre...@gmail.com wrote:
 I tried this:

 function! Ech() abort
   let g:var = 0
   echoerr Die die die!
   let g:var = 99
 endfu

 but after running the function, g:var is equal to 99. What gives?
 Apparently an error message (:help :echoerr) doesn't count as an
 error is detected?

 Using :throw works, but the error message looks pretty bad:

 function! Ech()
   let g:var = 0
   throw Die die die!
   let g:var = 99
 endfu

I'd still like an answer to the above, but I just
found :help :return...I think that's what the OP wants.
--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



'language messages' command not working

2009-07-21 Thread Alessandro Antonello

Hi, all.

I installed the latest Vim 7.2 with all patches from 1 to 234 and the command
'language messages' is not working anymore.

My LANG environment is pt_BR but I had configured Vim to show messages in
plain English with the following command in my vimrc file:

language messages en

Before the upgrade the command was working fine but now it is not.

Funny thing is that the standard menus of the interface are all in English.
Only messages at the command window and in the status line are changed to my
native language. This can have something to do with the 'libiconv.dll' that I
installed? Can I change this behavior without changing my LANG environment
variable?

Alessandro Antonello

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Fatal exceptions

2009-07-21 Thread Ben Fritz



On Jul 21, 11:47 am, Ben Fritz fritzophre...@gmail.com wrote:
 I just found :help :return...I think that's what the OP wants.

I need to stop trying to multitask before I make myself look like more
of an idiot.

Obviously you are already using :return to get a value from the
function.

What I meant is, simply return some flag value in the case of an
error. As-is, the function (implicitly) returns 0 in the last error
case (which I found in :help :return). Zero evaluates as false and a
non-empty string evaluates as true, so just check the value before you
use it.

You'll need an additional return 0 within your catch, but the rest
of the function should just work.
--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Fatal exceptions

2009-07-21 Thread Ben Fritz



On Jul 21, 12:01 pm, Ben Fritz fritzophre...@gmail.com wrote:

 I need to stop trying to multitask before I make myself look like more
 of an idiot.

 [snip]

 Zero evaluates as false and a
 non-empty string evaluates as true, so just check the value before you
 use it.

 You'll need an additional return 0 within your catch, but the rest
 of the function should just work.

Ugh, so much for the not looking like an idiot.

This would work, except:

a) In Vim, unlike Perl, apparently non-null strings DON'T evaluate to
true (is this documented anywhere? I can't find it if it is!)
b) you weren't returning a string anyway.

Returning 0 should still work, but check that type(project) == type
({}) for your sentinal, rather than checking for true/false of the
value itself.
--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Fatal exceptions

2009-07-21 Thread Thomas Allen

On Jul 21, 12:31 pm, Ben Fritz fritzophre...@gmail.com wrote:
 Out of curiosity (I'm not discouraging you from trying it yourself),
 have you tried Project.vim? Or is this something entirely different?

 http://www.vim.org/scripts/script.php?script_id=69

Yes, I've tried that, and it unfortunately wasn't close to what I
wanted. project.vim is great if you need to organize files strewn
about, but other than that it's not very useful. For me, projects are
rooted in a directory and I use symlinks to pull in other resources.
TextMate is abiding by a similar philosophy for its upcoming (if ever)
release. It also uses a crappy, confusing file browser when I prefer
NERDTree.

The goal of this plugin is ease of use and flexibility. I know it's
pretty basic right now, but once I figure out this error message
issue, I'll be putting it on vim.org.

Anyway, it does three things when I open a project which project.vim
can't (if it could, the hazy docs are hiding the capability):

1. Automatically cd to the path
2. Load some config
3. Open a normal browser (default NERDTree)

The next thing I'll add is a little project management browser that
integrates with the VCS plugin.

Thomas
--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



redirect from vim

2009-07-21 Thread Roald

How can I use a text I create in vim as input for a command? Like: 
sed 's/foo/bar/'  vim  out.txt ?

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: redirect from vim

2009-07-21 Thread Roald

I meant
vim | sed 's/foo/bar/'  out.txt

On Jul 21, 9:58 pm, Roald downa...@gmail.com wrote:
 How can I use a text I create in vim as input for a command? Like: 
 sed 's/foo/bar/'  vim  out.txt ?
--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: redirect from vim

2009-07-21 Thread Ben Fritz



On Jul 21, 3:31 pm, Roald downa...@gmail.com wrote:
 I meant
     vim | sed 's/foo/bar/'  out.txt


:%!sed 's/foo/bar/'
:w out.txt

:help :range!
--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Learning Vim (Was: Abbreviating a command)

2009-07-21 Thread Tony Mechelynck

On 21/07/09 15:40, Ben Fritz wrote:
[...]
 Vim has a very steep learning curve, and there's not much we can do to
 change that. Once you've mastered it, however, it will make you far
 more efficient, paying for your initial time investment many times
 over.

 It looks like you have general idea what you're doing, so I imagine
 you've already ran the tutorial. If not...do so. You can also learn a
 great deal just reading emails or archives on this list, by reading
 through chapters of the :help, or by following the Random page link
 on vim.wikia.com a few times a day. Stick with it. You'll be glad you
 did.

Rather than steep, I would say that Vim has a very high learning 
curve: I mean, Vim has a lot of functionality and customizability, which 
means there are a lot of things that can (and ideally should) be learnt 
about using it. And the more you learn, the more it becomes exciting and 
the more you want to go on learning about it.

This learning curve is, however, made somewhat less steep by the fact 
that Vim comes with very extra-super-hyper-first-class documentation. 
Indeed, John, as Ben said, the first step is to run the tutorial. But 
once you've done so, there are still other ropes to help you climb 
that slope. The main one is the help system. In fact, that help system 
is so complete (_everything_ is in it) that it often looks to the 
beginner like a mountain-high haystack with a little golden needle 
hidden somewhere in it. I know: when I was a beginner, finding the info 
I needed from the help often looked like a Herculean task. But Vim has 
tools, even for searching the help. Here are the main ones, or where to 
read about them: First, read

:help
:help :help
:help {subject}

where you type {subject} like that: brace, s, u, b, etc. until the 
closing brace.

Then if you're not sure of the tag name,

:help partname^D

(where ^D means hit Ctrl-D) will show you all the help subjects that 
include the partname, which can include the same kind of wildcards as 
a filename (? for one character and/or * for zero or more characters).


:set wildmenu
:help partnameTab

(or with Ctrl-E instead of Tab if you are running Vim in 'compatible' 
mode, which is not recommended) will display the possible completions in 
the form of a menu on the status line. Use Left or Right to select a 
different item, Enter to accept, Esc to cancel. This is explained under
:help 'wildmenu'
:help 'wildmode'


:helpgrep pattern

will search the _whole text_ of all help files for the vim-regexp 
/pattern/. The first match is displayed and all matches are collected 
into a quickfix list, so you can navigate the matches by means of
:cnext
:cprev
:cnfile
:cpfile
:cfirst
:clast
and/or open the quickfix list by
:copen
after which, hitting Enter on one line of the list brings you to the 
corresponding text in its helpfile. This quickfix stuff is described 
in detail under :help quickfix.txt. For easier navigation, I recommend 
mapping at least the first two of these commands to single keys, as follows:
:nmap   F2:cnextCR
:nmap   S-F2  :cprevCR



In addition to the help, there exists, as Ben said, a collection of 
tips and tricks which have been written over time by the various users 
of Vim. Those tips are collected in wikipedia form, starting at 
http://vim.wikia.com/ . They vary in quality, but as with every 
Wikimedia site, they become better over time by the ruthless editing 
of the site's subscribers, who are Vim users like you and me; Ben 
Fritzophrenic is indeed one of the most active of them.



Best regards,
Tony.
-- 
An American's a person who isn't afraid to criticize the President but
is always polite to traffic cops.

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Fatal exceptions

2009-07-21 Thread Matt Wozniski

On Tue, Jul 21, 2009 at 3:44 PM, Thomas Allen wrote:

 On Jul 21, 1:25 pm, Ben Fritz fritzophre...@gmail.com wrote:
 Ugh, so much for the not looking like an idiot.

 This would work, except:

 a) In Vim, unlike Perl, apparently non-null strings DON'T evaluate to
 true (is this documented anywhere? I can't find it if it is!)
 b) you weren't returning a string anyway.

 Returning 0 should still work, but check that type(project) == type
 ({}) for your sentinal, rather than checking for true/false of the
 value itself.

 Yea, I thought of just returning something else and then checking it,
 but I figured vimscript can raise fatal exceptions. Is there a command/
 function to kill the script flow itself? I could add that to the end
 of s:echoError...

That's exactly what raising an exception does.  When you get an
exception, why are you printing out a message about that exception,
and then ignoring that it ever happened?  Why not just :throw
something in s:ProjGetInfo() and :catch it in the caller?

~Matt

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Fatal exceptions

2009-07-21 Thread Tony Mechelynck

On 21/07/09 19:25, Ben Fritz wrote:



 On Jul 21, 12:01 pm, Ben Fritzfritzophre...@gmail.com  wrote:

 I need to stop trying to multitask before I make myself look like more
 of an idiot.

 [snip]

 Zero evaluates as false and a
 non-empty string evaluates as true, so just check the value before you
 use it.

 You'll need an additional return 0 within your catch, but the rest
 of the function should just work.

 Ugh, so much for the not looking like an idiot.

 This would work, except:

 a) In Vim, unlike Perl, apparently non-null strings DON'T evaluate to
 true (is this documented anywhere? I can't find it if it is!)
 b) you weren't returning a string anyway.

A string which begins with a decimal number, or with 0 then an octal 
number, or with 0x or 0X then a hex number, evaluates as that number. 
Any other string evaluates as zero.

When evaluating as a Boolean, it is first converted to a Number. Then 
zero counts as FALSE and anything else counts as TRUE.

This is documented about one page below :help variables.


 Returning 0 should still work, but check that type(project) == type
 ({}) for your sentinal, rather than checking for true/false of the
 value itself.

This checks for a Dictionary. To test for a string, use type('').

(Using a Dictionary as if it were a Number doesn't work, it throws an 
exception. Using a String as a Number does work, as above.)


Best regards,
Tony.
-- 
Oh, I don't blame Congress.  If I had $600 billion at my disposal, I'd
be irresponsible, too.
-- Lichty  Wagner

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Fatal exceptions

2009-07-21 Thread Ben Fritz



On Jul 21, 5:54 pm, Matt Wozniski m...@drexel.edu wrote:
 That's exactly what raising an exception does.  When you get an
 exception, why are you printing out a message about that exception,
 and then ignoring that it ever happened?  Why not just :throw
 something in s:ProjGetInfo() and :catch it in the caller?


When I was writing programs for school in Java (seems like forever
ago), I remember that not being careful with what you placed inside
try...catch blocks, you ended up eating memory REALLY fast. I think
that had something to do with Java trying to discard/restore pretty
much everything within the try or something like that if it failed.

It looks like Vim's implementation is just a sort of instant return-
through-all-callers, it doesn't try to undo anything. Are there any
side effects of a try...catch in Vim, performance related or
otherwise, that one should be aware of?

Additionally, what on earth does :echoerr do in relation to all this?
From my trial-and-error above, it DOESN'T seem to exit a function,
even if defined with the abort keyword. Neither of these work as I
expect (i.e. abcd and defg both get the value 123 instead of 0):

function AbErr() abort
  let g:abcd=0
  echoerr 'fooblarg'
  let g:abcd=123
endfu

fun NoAbErr()
  let g:defg=0
  echoerr 'blargfoo'
  let g:defg=123
endfu

Does echoerr need to be in a try...catch to be useful in a situation
like this?
--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



:Explore and single click in gvim

2009-07-21 Thread googler

I have been using the Explore command in gvim these days and finding
it very useful in moving around directories. However, there is one
feature that's causing me problem sometimes. When gvim is listing the
contents of a directory and I click on any file or directory, it opens
that file or directory. This can be a useful feature for some people
but for me it's causing problem sometimes, when I accidentally click
somewhere in the gvim window or click to make it the active window.
Today I was even trying to highlight the contents (for copying) and it
worked like a single click and opened the file. Is there a way I can
stop the file or directory from opening on a single click? Maybe a
double click would be better. Hitting enter should also work, as it
does now. Thanks.

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: redirect from vim

2009-07-21 Thread Tony Mechelynck

On 21/07/09 22:31, Roald wrote:

 I meant
  vim | sed 's/foo/bar/'  out.txt

Let's push it one step further. Rather than

 someprogram | vim | sed 's/foo/bar'  out.txt

I'd use

 someprogram  out.txt
 vim -es -c '%s/foo/bar/g' -cq out.txt

(using Vim in batch mode). Well, I /think/ stat's what that sed command 
does but I know Vim better than sed so I'm not sure. I guess I use Vim 
where most people use sed, because I know how to use it, and like its 
docs better.

See
:help -e
:help -s-ex
:help -c
:help :s
:help :saveas
:help :q
:help -file

For giving additional commands to Vim, see also
:help -S


Best regards,
Tony.
-- 
Life is a whim of several billion cells to be you for a while.

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: is syntax highlighting and auto indentation handled by seperate description files in vim?

2009-07-21 Thread Tony Mechelynck

On 22/07/09 00:06, RPN wrote:



 On Jul 21, 4:36 am, Tony Mechelynckantoine.mechely...@gmail.com
 wrote:
 Indent scripts are mostly used to set either the 'indentexpr' option or
 the 'cindent' and 'cinoptions' options. They should ALWAYS SET THEM
 BUFFER-LOCALLY using the :setlocal command, not the :set command
 (which could clobber the settings for other unrelated files). See
 $VIMRUNTIME/indent/*.vim for examples.

 Thanks Tony! I already have a lot of my own custamizations and syntax
 files under ~/.vim.

 I am used to looking at the standard vim repositories for syntax
 highlighting files. Is there a similar one for indent scripts?

yes, as I said near the top of my former post, it is called indent/ 
instead of syntax/ (but at the same level in the same directory trees), 
and as I said near the bottom, see examples in $VIMRUNTIME/indent/*.vim 
for how to write them.

The middle part of my former post, which, alas, probably triggered your 
zap-reflex so that you didn't read there my answer to the question you 
are asking again today, was meant to impress unto you the necessity of 
never changing any $VIMRUNTIME script in-place -- I've known too many 
people who shot themselves in the foot by trying.


 I was looking for an indent script for the json format. A syntax
 file already exists but I cannot find an indent script. Anyone know of
 such?

 --
 Rahul

Well, not me, but maybe you can write your own?


Best regards,
Tony.
-- 
A professor is one who talks in someone else's sleep.

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: vim on ARM

2009-07-21 Thread bill lam

On Tue, 14 Jul 2009, Tim Chase wrote:
 You can get a good idea at
 
:help +feature-list
 
 as there's a key that tells you whether items are (T)iny, 
 (S)mall, (N)ormal, (B)ig, or (H)uge.  If you want to cut fat, 
 attack the Big/Huge items first.  Most of my list came from issuing

When I compile vim, ./configure provides only a few options mainly for
enable interpreters, most features can only be chosen or disabled by
setting normal, big etc.  Is there any way to cherry pick individual
features?

-- 
regards,

GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: is syntax highlighting and auto indentation handled by seperate description files in vim?

2009-07-21 Thread RPN


On Jul 21, 9:20 pm, Tony Mechelynck antoine.mechely...@gmail.com
wrote:

 yes, as I said near the top of my former post, it is called indent/
 instead of syntax/ (but at the same level in the same directory trees),
 and as I said near the bottom, see examples in $VIMRUNTIME/indent/*.vim
 for how to write them.

 Well, not me, but maybe you can write your own?


Thanks again Tony! Ah, maybe I didn't write clearly the last time,
sorry! I had read the top, middle and bottom part of your post. :) I
understand the concept of an indent file and the difference from a syn
file but before writing a new one myself I wanted to check if similar
to the online repos of syntax files contributed by users any such
existed for indent files as well? My indent directory does not
contain the indent file for json and before I reinvent the wheel I
wanted to check if there was one already available. Maybe someone else
already had this problem. Sorry if it felt like I was barging ahead
not reading your reply! Best Regards,
--
Rahul
--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Fatal exceptions

2009-07-21 Thread Tony Mechelynck

On 22/07/09 03:36, Ben Fritz wrote:



 On Jul 21, 5:54 pm, Matt Wozniskim...@drexel.edu  wrote:
 That's exactly what raising an exception does.  When you get an
 exception, why are you printing out a message about that exception,
 and then ignoring that it ever happened?  Why not just :throw
 something in s:ProjGetInfo() and :catch it in the caller?


 When I was writing programs for school in Java (seems like forever
 ago), I remember that not being careful with what you placed inside
 try...catch blocks, you ended up eating memory REALLY fast. I think
 that had something to do with Java trying to discard/restore pretty
 much everything within the try or something like that if it failed.

 It looks like Vim's implementation is just a sort of instant return-
 through-all-callers, it doesn't try to undo anything. Are there any
 side effects of a try...catch in Vim, performance related or
 otherwise, that one should be aware of?

In Vim, IIUC undoing what a try block did is the user's responsibility, 
by means of the :finally clause, which is run even if the try...endtry 
is in a function and there is a :return anywhere between :try and 
finally. The general structure of a (full) Vim try block is as follows:

:try
 first, save whatever it is that we must later restore
 do something, possibly raising exception(s)
:catch /E123/
 what should we do if exception E123 is triggered
:catch /E456/
 if exception E456 is triggered
:catch
 if anything we haven't yet caught is triggered
:finally
 restore everything to a known state
 e.g. from what we saved at the top of the :try
:endtry

The :finally is optional, and there may be any number of :catch 
clauses. The catch-all clause, if present, should of course be the last 
of them.

rant
The one thing missing from Vim's documentation is the text of ost 
exceptions. E.g. :help E224 tells me that E224 and E225 are about 
buffer-local mappings, but what can I know exactly what they are for, 
and what is the difference between them as long as they don't happen to 
me? I guess the only solution is to run :cscope find e E224 on the Vim 
source, it tells me:

(1 of 1) unknown ^I^I^IEMSG2(_(E224: global abbreviation already 
exists for %s),

then hitting the spacebar shows E225 a few lines lower, with mapping 
instead of abbreviation. But can't I sensibly write try blocks without 
a Vim with +cscope, the Vim source at hand, and a cscope.out built on it?
/rant
Oh well... I suppose Bram has better things to do, and that if I really 
wanted, I could (now that I've found it) document it myself and submit a 
help patch or even a new helpfile. Only there are undreds of them, so 
I'd better automate it somehow... maybe save somewhere the QF lists 
generated by cscope (for EMSG, EMSG2, EMSG3, EMSGN, EMSGU, or maybe just 
one list, using EMSG as an egrep pattern) and then reprocess that...


 Additionally, what on earth does :echoerr do in relation to all this?
 From my trial-and-error above, it DOESN'T seem to exit a function,
 even if defined with the abort keyword. Neither of these work as I
 expect (i.e. abcd and defg both get the value 123 instead of 0):

 function AbErr() abort
let g:abcd=0
echoerr 'fooblarg'
let g:abcd=123
 endfu

 fun NoAbErr()
let g:defg=0
echoerr 'blargfoo'
let g:defg=123
 endfu

 Does echoerr need to be in a try...catch to be useful in a situation
 like this?

I confess I haven't yet used try blocks much. They are a relative 
novelty (6.2, according to version6.txt), and if I wanted to keep my 
scripts and vimrc version-6-1-compatible, I could use :echoerr but not 
:try:throw:catch:finally:endtry. (That was not the only reason: another 
was that I didn't really understand all those new ex-commands, they came 
from beyond my experience).

As for abort in a function definition, I cannot see where it was 
introduced, but it was earlier than 6.0.252, see version6.txt lines 
5365 sqq., so even if user-thrown exceptions didn't exist, of course 
user errors and vim errors (i.e. Vim exceptions) did.

That patch 6.0.252 gives me an idea though: if you put :if 1 and 
endif, or failing that let true = 1 | if true and :endif, around 
your :echoerr, does it make a difference? If it does, then that bugfix 
has come unstuck.


Best regards,
Tony.
-- 
Arithmetic is being able to count up to twenty without taking off your
shoes.
-- Mickey Mouse

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: is syntax highlighting and auto indentation handled by seperate description files in vim?

2009-07-21 Thread Tony Mechelynck

On 22/07/09 05:04, RPN wrote:


 On Jul 21, 9:20 pm, Tony Mechelynckantoine.mechely...@gmail.com
 wrote:

 yes, as I said near the top of my former post, it is called indent/
 instead of syntax/ (but at the same level in the same directory trees),
 and as I said near the bottom, see examples in $VIMRUNTIME/indent/*.vim
 for how to write them.

 Well, not me, but maybe you can write your own?


 Thanks again Tony! Ah, maybe I didn't write clearly the last time,
 sorry! I had read the top, middle and bottom part of your post. :) I
 understand the concept of an indent file and the difference from a syn
 file but before writing a new one myself I wanted to check if similar
 to the online repos of syntax files contributed by users any such
 existed for indent files as well? My indent directory does not
 contain the indent file for json and before I reinvent the wheel I
 wanted to check if there was one already available. Maybe someone else
 already had this problem. Sorry if it felt like I was barging ahead
 not reading your reply! Best Regards,
 --
 Rahul

Ah, sorry, I didn't understand that point. Repositories of contributed 
Vim scripts are for all kinds of scripts AFAIK, for instance the 
scripts section of www.vim.org -- otherwise, when it goes about less 
generalistic sources, each author has his own preferences -- e.g. 
Dr.Chip has quite a lot of scripts but I don't know if there are indent 
scripts among the lot (I confess that I personally don't like the 
computer messing up whatever nonsystematic indenting I happen to use).

It's where to drop them when you want to us them which is different.


Best regards,
Tony.
-- 
You've been leading a dog's life.  Stay off the furniture.

--~--~-~--~~~---~--~~
You received this message from the vim_use maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---