Re: VimWiki - released finally

2007-06-05 Thread Luc Hermitte
* On Tue, Jun 05, 2007 at 02:54:21PM -0600, Mike Hansen [EMAIL PROTECTED] 
wrote:
  From: Tom Purl [mailto:[EMAIL PROTECTED] 
 [...] 
  So what I don't understand is, why can't I change these categories?
  I've been editing Mediawiki pages for 4 years, and I've never seen
  anything like this.
 
 This isn't a figment of Tom's mind.
 
 I just poked around the wiki. I'm not seeing a way to change the
 category of an existing article. When you create a new article, you
 can assign categories, but I'm not seeing a way to change the category
 on an existing article even if you edit the entire article by clicking
 on the edit link at the top of the article.
 
 If there is a way to change the category of an existing article, I'm
 missing it.

I did it twice.
- http://vim.wikia.com/wiki/Running_the_win32-version_of_Vim_from_cygwin

I've added the [Category:Cygwin], and removed Review.

[Category:Review] is a consequence on the template [1] {{Review}} [2] 
The [category:VimTips] is likely a consequence of the template {{Tip}}
[3] used at the start of every vimtip.

BTW, it can be interresting to add a {{Vimscript}} template. In the
long term, it could check the existence of a wiki-page dedicated to the
script and point to that page if found, or to vim site otherwise.
(NB: I don't even know if this is possible, nor ergonomic)

In the short term, it is good way to provide links to the vimscripts of
vim.org.


[1] http://vim.wikia.com/index.php?title=Special%3AAllpagesfrom=namespace=10
[2] http://vim.wikia.com/wiki/Template:Review
[3] http://vim.wikia.com/wiki/Template:Tip
-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: disabling abbreviations inside comments

2007-04-12 Thread Luc Hermitte
Hello,

* On Thu, Apr 12, 2007 at 12:31:24PM -0700, Mrinal Nath [EMAIL PROTECTED] 
wrote:
 I have some iabbreviations defined. The problem is that the iabbrs get
 expanded even while I am writing comments (in VHDL).
 
 Is there a way to detect that I am currently typing a comment (line
 that has -- anywhere before the cursor), and temporarily disable
 abbreviation expansion? When I finish typing the comment, I would like
 all the abbreviations to be expanded as usual.

My VimL-library suite lh-map-tools defines a few functions that helps
implementing such abbreviations.
- http://hermitte.free.fr/vim/ressources/lh-map-tools.tar.gz

(Note: it also comes with a bracketing-system, and all the documentation
you'll need - :h MapNoContext(), :h BuildMapSeq(). For more advanced
mappings have a look at my CC++ ftplugins suite.)

HTH,

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: bracket completion

2007-04-02 Thread Luc Hermitte
Hello,

* On Mon, Apr 02, 2007 at 10:38:14AM -0500, shawn bright [EMAIL PROTECTED] 
wrote:
  Check out Luc Hermitte's development of Stephen Riehm's
  bracketing macros.
 
  http://hermitte.free.fr/vim/settings.php#settings

 On 4/2/07, shawn bright [EMAIL PROTECTED] wrote:
 this looks like exactly what i am after.  i am kind of a newbie here,
 and cant quite get it to work right.
 i believe that i need a python.vim file in /ftplugin directory.

Only if you want to customize the bracketing system for python.

 but i dont know how to word it to make this plugin work,
 could anyone kinda help me here, i can't make out what i should do
 from the docs on the website that you linked to

 whoa !, nevermind, found an example file on his website, tried it and 
 works,.
 sorry, my own rftm mistake


The doc is a little bit outdated. The plugin used to word standalone.
But now there are a lot of inter-dependendies between by plugins -- I'm
still in the process of refactoring everything. As a consequence,
prefer the tarball archives.

lh-map-tools.tar.gz should be enough -- but don't forget to define a
ftplugin suited to your needs. If you want a more complete suite,
check the CC++ ftplugins suite (which encapsulates/contains map-tools),
which is the most complete of all [1]. There are a few other suites,
which are not really maintained anymore. [2]

If you have any questions feel free to ask. I've tried to write a
documentation (the one in the tarball) as complete as I could, but I may
have missed a few details.

HTH,

[1] it contains many mappings to insert control-statements (if, for,
...) in every mode.
[2] http://hermitte.free.fr/vim/ressources - *.tar.gz

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: bracket completion

2007-04-02 Thread Luc Hermitte
* On Tue, Apr 03, 2007 at 02:14:59AM +0300, Panos Laganakos [EMAIL PROTECTED] 
wrote:
 One thing that would also be great, was if you were able to tab your
 way out of it, ie move to the outside of the bracket, once you're
 done. Now you need to either press right, to move ahead (which is not
 quite vim-ish), or hit escape and Shift_A, to resume editing.
 
 Only possible way I can think of, is to use a snippet system, like
 snippetsEmu[1] or something. Any other suggestions?

Well. You can use my bracketing system, or the fork of mu-template I'm
maintaining (which relies on the bracketing system) -- see my signature.
The marker/placeholder can be easily enable or disabled, cutomized for
every language, ...

-- 
Luc Hermitte
http://hermitte.free.fr/vim/ressources/


Re: How can a script know if we're running without X ?

2007-03-13 Thread Luc Hermitte
Hello,

* On Tue, Mar 13, 2007 at 11:29:28PM +0100, A.J.Mechelynck [EMAIL PROTECTED] 
wrote:
 How can a Vim script know if we're running without an X connection?
 
 Of course, some cases are obvious, such as
 
   if has('unix')  !has('x11')
 
 meaning we're on Unix with no X11 support compiled-in.
 
 But what about an X-enabled Vim running in console mode, either with
 the -X command-line switch, or in a terminal with no access to an X
 server?
 [...]
 It doesn't take care, however, of the case when an X-enabled Vim was 
 started as vim -X in an xterm. Is there a way to check for that in 
 vimscript?

What about checking whether .gvimrc is sourced or not?
Testing also for has('x11') could be a way to be sure vim is compiled
for x11, and running with an X connection.

Reading the documentation from |.gvimrc|, it seems there are a few other
way to test for the fact you are running with graphics support.

Unless you want to also support vim running in console, and with X-term
support [1], this should do it. Otherwise, what about testing the
options vim was launched with (thanks to a system('ps
-relevant-options')) ?

HTH,


[1] I don't know whether it is relevant or not.
-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: inoremap tips/examples (Was Re:add c/c++ snippets)

2007-03-10 Thread Luc Hermitte
Hi,

* On Wed, Mar 07, 2007 at 07:48:24PM +, Eric Leenman [EMAIL PROTECTED] 
wrote:
 Triggered by the video presentation of Bram by making a iabbreviation
 or inoremaps of things you type often in combination with the reply of
 Gavin, would you like to share some of your inoremap mappings?
 Some like Gavin send?
 Plain and simple and very effective.

Few of mine are that simple -- I try to make them smart. However they
are quite effective. 
They can be found in the various ftplugins and some of the plugins I'm
maintening

Explore the tarballs in
http://hermitte.free.fr/vim/ressources/

HTH,

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: How to make inoremap 's filetype depend

2007-03-10 Thread Luc Hermitte
Hello,

* On Sat, Mar 10, 2007 at 07:59:21AM +, Eric Leenman [EMAIL PROTECTED] 
wrote:
 How do you making inoremap filetype depend?
 What I want is
 
 if (filetype == vim) then
   inoremap @a   A
 else if (filetype == c)
   inoremap @a   aa
 else if (filetype == vhdl)

I use ftplugins, and buffer local mappings
-
   {rtp}/ftplugin/vim/at_a.vim
  inoremap buffer @a A

   {rtp}/ftplugin/c/at_a.vim

HTH,

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: Automatically positioning cursor when opening a file

2007-03-10 Thread Luc Hermitte
Hello James,

* On Fri, Mar 09, 2007 at 10:22:22AM +0100, James Kanze [EMAIL PROTECTED] 
wrote:
 I'm having trouble automatically positionning the cursor when
 opening an existing file.
 
 Basically, all of my files have a standard header (copyright
 blurb, etc.), and I'd like to have the cursor positionned after
 it at the start of editing.  When opening a new file, I have the
 following in my .vimrc:
 
 [...]
 
 I'd like something similar when I open the file, but
 
autocmd BufReadPost *.cc,*.hh,*.sh,*.mk,GNUmakefile :1
autocmd BufReadPost *.cc,*.hh,*.sh,*.mk,GNUmakefile /^$/
 
 leaves the cursor at the top.

I have no idea why BufReadPost is not triggered. Could it be that your
autocommands are in the global scope, and that they are reset by other
autocommands which are triggered just before yours ?
You can try the following code to fix this possible situation
augroup JK_template
   au!
   au BufReadPost your auto-command
aug END

 Changing the event to BufWinEnter or BufEnter works well when I open
 the file, but causes the cursor position to be lost if I leave the
 window, then later come back to it.

If that case, you can set a buffer-local variable that tells you to not
reset the cursor position.
-
   function s:GotoLastEmptyLine() 
  if ! exist('b:JK_file_already_opened')
  normal! G
  let l = search('^\s$$','b')
  if l==0
  do whatever you want
  endif
  let b:JK_file_already_opened =1
  endif
   endfunction

   au BufEnter *.cc call s:GotoLastEmptyLine()


 From the documentation, I'd expect BufReadPost to work, but it
 doesn't.
 
 Also, while I'm at it: is there any reason why 1G doesn't work, but :1
 does, to start from a known point.

Auto-commands are expecting a command, not a normal mode sequence. Try
``:normal! 1G'' instead of ``1G''

HTH,

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: Two minor requests for the TODO list

2006-12-06 Thread Luc Hermitte
Hello, 

* On Wed, Dec 06, 2006 at 04:11:24PM -0800, Eggum, DavidX S [EMAIL PROTECTED] 
wrote:
 I've found two tasks that are done in vim scripts routinely and it
 would be nice to streamline them:
 
 Here's the first one: If some variable isn't set yet, then set it to
 a default value. The code always looks something like this:
 
 if !exists(g:MyScriptSetting)
    let g:MyScriptSetting = default_value
 endif
 
 How about adding this:
 [...]
 get({string} [, {default}])
    value from variable {string}.  When this variable does not
    exist, return {default}.  Return zero when {default} is
omitted.

Well, I've started to refactor my plugins to isolate a similar similar
function in an autoload plugin. My function also takes another argument:
a list of scopes in which the variable can be defined.

 Function: lh#option#Get({name}, {default} [, {scope}])
 @return b:{name} if it exists, of g:{name} if it exists, or {default}
 otherwise
 The order of the variables checked can be specified through the optional
 argument {scope}

Then, in my script, I systematically call this function, and never
directly use a variable. Indeed, I have no way of knowing if the
variable is b:goo, g:foo, w:foo or even s:foo.

The support of non global options is very important to me as I mainly
maintain ftplugins, and work on the files from various projects that
don't share the same configuration (like different targets used in the
makefiles).

A typical use is:
let l:foo = lh#option#Get('foo', s:foo_default, 'wbg')
Which will return the value of the first variable found among w:foo,
b:foo and g:foo. Or s:foo_default otherwise. 

So far, {default} is not optional as I have both integer and string
variables, and I can't easily tell the exact type of the variable.

Having such function as builtin would be nice. I can easily cope without
it. But still, it would be nice.

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: separator in user-defined command name

2006-12-05 Thread Luc Hermitte

* On Mon, Dec 04, 2006 at 12:09:34PM -0800, Gary Johnson [EMAIL PROTECTED] 
wrote:
 On 2006-12-04, [EMAIL PROTECTED] wrote:
   I tried '-' and '_' in user-defined command name, both are not accepted
   (like X_Y, X-Y). Is there maybe some  [other] separator that is
   allowed in user-defined command name ?
  
  I'm afraid only uppercase letters can be used
 
 Actually, uppercase letters, lowercase letters and digits can be 
 used, but the name must start with an uppercase letter.

Of course. I meant can be used as word separator
- :MyCommand and not :MYCOMMAND


-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: chasing symlink

2006-10-20 Thread Luc Hermitte
Hello,

* On Fri, Oct 20, 2006 at 11:39:10PM +0200, Yakov Lerner [EMAIL PROTECTED] 
wrote:
 Let's say I edit file x (vim x) which is a symlink, x-y.
 (Linux). How can I make a script that opens y
 instead of x in the buffer (chases the symlinks and opens it)

Are you looking for realpath?

In case the script you are looking for is a shell script (not a viml one)
AFAIK, realpath does not work on non existant files -- that could be
problematic if you wish to follow directories.
Moreover you will have to distinguish between files passed to vim from
vim arguments like -c /foo.

In the end you will implement something very similar to the script
cyg-wrapper I'm maintening (check my signature). The easiest thing to do
is probably to adapt cyg-wrapper to not use cygpath and other programs
related to windows (like start)
/

Otherwise, may be you can play with things like FilePreRead and :file ?

HTH,

-- 
Luc Hermitte
http://hermitte.free.fr/cygwin
http://hermitte.free.fr/vim/


Re: Turning abbreviations on and off

2006-09-27 Thread Luc Hermitte
Hello,

* On Mon, Sep 25, 2006 at 02:41:51PM +0200, Marius Roets [EMAIL PROTECTED] 
wrote:
 I have a in my plsql.vim filetype plugin a lot of abbreviations to the
 effect of :
 iabbrev buffer then THEN
 iabbrev buffer else ELSE
 ...
 etc.

A while back, I implemented a plugin specialised in toggling almost
everything like the definitions from a VimL function.

It seems I haven't released the lastest version on sourceforge. However
you can obtain it from here:
http://hermitte.free.fr/vim/ressources/Triggers.tar.gz
The documentation can be found there:
http://hermitte.free.fr/vim/general.php#expl_triggers

 The idea is that some companies' coding standards expect me to use
 capitalized keywords. Personally I hate capitalized keywords (it
 reminds me of BASIC programming). So I was wondering if there was a
 way where I could turn a set of abbreviations on and off, on the fly,
 without reloading the buffer.

Won't you be more interrested in definitions local to projects ?
I.e. all files under a directory will have some specialized mappings,
abbreviations,  And files under another directory will have other
specialized abbreviation ...
This issue has been discussed here a couple or week, may be less.

HTH,

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: abbreviations + indent + movement commands

2006-09-27 Thread Luc Hermitte
Hello,

* On Mon, Sep 25, 2006 at 08:29:02PM +0200, Kim Schulz [EMAIL PROTECTED] 
wrote:
  I finally converged to the use of search(), on a placeholder
  regex-pattern. This way neither @/ nor the search history are messed
  up by irrelevant patterns.
 
 I have been playing around with the search() but I couldn't quite get
 the hang of it. 

As Benji said, search() returns a value that is not an insert mode
action, but a line number.

 Could you maybe give me an example on how to use it in relation to an
 abbrev. What I tried was:

My use of search() is completely encapsulated. It is called from within a
function that returns the normal mode action that can reselects the
placeholder once out of the function. It is used then in the family of
mappings !jump!, !jumpB!, ...

Then, my smart-abbreviations (they are context-sensitive) insert a text
through
   c-r=InsertSeq(,
   \ 'for (!cursorhere! ; !mark! ; !mark!)\n{\n!mark!\n}')

InsertSeq() is really tricky. Among the may things it does, it replaces
!stuff! by the keys binded to the insert mode-mapping !stuff! -- 99%
of the time the ones I code (and use in InsertSeq()) rely on a function
call. 
!cursorhere! takes a snapshot of cursor position, and InsertSeq() move
the cursor to the snapshotted position -- when it detects !cursorhere!.

Actually I could have used the placeholder inserted by mark, but I
wanted to be able to place the cursor anywhere, not necessarily on the
first placeholder.

IIRC, that's what has been done in Srinath  al. IMAP.vim plugin: the
cursor is moved to the first placeholder.

HTH,
-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: placeholders

2006-09-23 Thread Luc Hermitte
Hello,

* On Fri, Sep 22, 2006 at 07:52:28AM +0200, Kim Schulz [EMAIL PROTECTED] 
wrote:
 On Thu, 21 Sep 2006 23:36:19 +0200
 Luc Hermitte [EMAIL PROTECTED] wrote:

   any ideas? 
  
  
  Why don't you use already existing solutions ?
 
 what would I learn from that ? :-) 

A lot or nothing. It depends.
Nothing if you just use. A lot if you look at the code and try to
understand the solutions used.

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: abbreviations + indent + movement commands

2006-09-23 Thread Luc Hermitte

Hi again,

* On Sat, Sep 23, 2006 at 03:38:58PM +0200, Kim Schulz [EMAIL PROTECTED] 
wrote:
 I am playing a bit around with abbreviations, in order to use them for
 simple pattern templates when I code. like:
 iabbrev for( for (%%%;%%%;%%%){CRCR}
 
 How can I get it to obey my indentation rules? 

In my ftplugins set ``lh-cpp'', I interpret c-f (the correct
keybinding should actually match the indent options) from within
abbreviations inserted through i_CTRL-R_=. In the next release, I plan
to support a !reindent! trigger to define my abbreviations. 

In mu-template, I have a template option s:reindent, that triggers a call
to
exe first.','.last.'normal! =='  IIRC
first and last initial values are based on '[ and '] (which are
automatically set), and adjusted according to lines removed from the
template file.

 Second problem:
 
 After the for( is changed to the for (){...} I would like to move
 the cursor to the first spot just inside the () without having to do
 this manually. is there a way to go to that place ?

Use placeholders, and reserve a mapping/trigger that jumps to the
placeholder.  In lh-map-tool, I use !cursorhere! (and !gotocursor!,
which is an implementation detail) to acheive this.

 I guess it is in the mark for place of last change, but I just cant
 get iabbrev to execute my movement command (other than using left
 right up down). Is there any way to do this?

I finally converged to the use of search(), on a placeholder
regex-pattern. This way neither @/ nor the search history are messed up
by irrelevant patterns.

If everytime (i.e., for every keywords - for, if, while, ...) you
count the number of lines or columns you have to move the cursor, it
becomes quickly boring to maintain the end-user mappings. Moreover, you
won't be able to propose customizations like inserting newlines before
and/or after curly- and round-brackets -- because the coding rules in
different projects require different presentations.

HTH,

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: placeholders

2006-09-21 Thread Luc Hermitte
Hello,

* On Thu, Sep 21, 2006 at 10:43:54PM +0200, Kim Schulz [EMAIL PROTECTED] 
wrote:
 I want to add placeholders to some templates I have like
 +TITLE+ +DATE+ etc. 
 I then want to map a keyboard shortcut to do the following
  1. find next placeholder
  2. remove placeholder
  3. place cursor where placehoder where
  4. go into insert mode.
 
 I started out on the command, but got kinda stuck. 
 :map C-j /+.\++CR:s/+.\++//CR'.i
 
 it almost works, except that it places the cursor at the beginning of
 the line instead of at the place of the placeholder. 
 
 any ideas? 


Why don't you use already existing solutions ?

I'm maintaining a placeholder/bracketing system 
- http://hermitte.free.fr/vim/ressources/lh-map-tools.tar.gz
This is the latest UTF-8 friendly version.

Advertisement comment=someday I will have to release v1.0.0 and make an
announcement
This package offers several things:
- a documentation
- a markers/placeholders system that:
  - selects (as in select-mode) the marker/placeholder
  - works well in UTF-8 (at last!)
  - is compatible with a few vim options that change everything in
visual-selection management (like 'selection', 'magic', folders, ...)
  - provides forward and backward jumps
  - provides mappings for plugin-writers
  - can be customized in various ways
  - does not mess with neither @/, nor search history, nor any other
register
- several functions that can be used to implement plugins and ftplugins:
  - surround selection (unless the selection is a marker (workaround for
vim 7 versions))
  - expand text according to the context
  - ...
- smart-bracketing mappings:
  - the expansion respect the context (string, comment, ...)
  - takes advantage of the placeholders system
  - can be tuned for different filetypes.  
- it is maintained -- I heavily use this package everyday at work
  (solaris/linux) and at home (xp).
/

It is integrated in an advanced templating system (actually a fork of
mu-template that I'm maintaining)
- http://hermitte.free.fr/vim/ressources/mu-template.tar.gz
(I still have a few bugs to fix -- they mostly occur in a few wizards)

And also my set of ftplugins like the CC++ one:
- http://hermitte.free.fr/vim/ressources/lh-cpp.tar.gz
(A few files are missing from the archive for the class and doxygen
wizards).


Otherwise there exist a few other similar placeholders systems (either
forks of my work, or even complete and (simplified) rewrites).

HTH,

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: Specifying vim options in the files being edited

2006-09-08 Thread Luc Hermitte
Hello,

* On Fri, Sep 08, 2006 at 04:27:54PM -0400, Jean-Rene David [EMAIL PROTECTED] 
wrote:
 * Russell Bateman [2006.09.08 15:30]:
  You see that pretty well anything you can do on
  the ex command line in Vim (:set ignorecase,
  etc.), you can put in these modelines. 
 
 That's not true. You can only set options.

That's easily extensible. See
http://vim.sourceforge.net/scripts/script.php?script_id=83

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: Spell checking comments and strings

2006-09-08 Thread Luc Hermitte
Hello,

* On Sat, Sep 09, 2006 at 12:07:19AM +0200, A.J.Mechelynck [EMAIL PROTECTED] 
wrote:
 Noah Spurrier wrote:
 Is there a way to spell-check strings and comments using vim7.0 ?
 
 Well, spell-checking some parts of  files and not others is possible 
 *provided* that syntax highlighting is enabled and that the relevant 
 syntax script defines what should be spell-checked and what shouldn't; 
 see :help spell-syntax. The Python syntax script 
 $VIMRUNTIME/syntax/python.vim apparently defines no spelling or 
 non-spelling regions, so IIUC for that language spelling is 
 all-or-nothing.

I think that is not entirely true.
In the spell-checking plugin I did maintain, I had implemented a
workaround that injects the @Spell cluster in already existing syntax
definitions. The solution consists in a big and ugly hack that detects
syntax elements with string or comment in their name, to inject them
with the new cluster.

I've never checked if it worked correctly with Python, but I see no
reason why it shouldn't.

Of course the best solution is to have all syntax-plugin maintainers to
update their scripts.

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: Execute something when I enter in a directory

2006-09-05 Thread Luc Hermitte
* On Tue, Sep 05, 2006 at 09:51:31AM -0700, Chuck Mason [EMAIL PROTECTED] 
wrote:
 While I'm still new here, I would like to share my version based on
 Yakov's.  Below uses \\ directory separator so this will not work on
 any *nix.

Use instead match on '[/\\]', or fnamemodify()

 I could make it more os-independent by doing an `if' and `let
 cmdsep=whatever', but I'm positive there's a better way to do it.  Or
 maybe there's just a way to chop off the topmost directory name from a
 string. In any case, the function below simply seeks to the root of
 the filesystem searching for a _lvimrc and stops after finding one.

Check for instance
http://hermitte.free.fr/vim/ressources/vimfiles/plugin/local_vimrc.vim.
Several unusual cases are taken into account.

BTW, I do not need to backslash spaces with win32-vim on XP.
(:h escape() to backslash characters)


-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: silent make

2006-09-04 Thread Luc Hermitte
Hello Luis,

* On Thu, Aug 31, 2006 at 02:31:18PM -0300, Luis A. Florit [EMAIL PROTECTED] 
wrote:
 I use Vim and Quickfix to compile C++ programs. I have set
 
 let makeprg='g++ -o % %'
 
 as the compiler. My problem is that while compiling, vim goes to
 the console, distracting me. I don't need the console, if I use
 Quickfix! I would like it to stay in the buffer window.
 
  I made the following map:
 
 map silent EscEsc :echohl WildMenucr:echon Compiling 
 file...cr:silent! makecr:cw 4crC-wUp:echohl Nonecr:echo 
 crc-l
 
 that works great in gvim. It stays in the buffer, printing a bottom
 message Compiling file... while compiling. But this does not work
 for vim (console).
 
 How can I avoid vim to leave the buffer while compiling, without
 making something like ':silent !g++..., since I want to use Quickfix?


What about background compilation ? Your program can be compiled in
background while you will still be able to do whatever you whish in vim.

This topic has been discussed a few months ago. So far I know two
scripts able to acheive background compilation from vim.

I'm maintening one of them [1]. The result consists in a perl script
(which means perl is required, as well vim compiled to support remote
invocation through |+clientserver|) and a few VimL functions maintened
in a plugin that is still in alpha stage (the plugin does many more
things related to the management of compilation chains).

HTH,

[1] http://hermitte.free.fr/vim/ressources/lh-BTW.tar.gz

PS: I don't know if this email will reach the mailing or not as SORBS
filtering seems to have been reactivated.
-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: fast file locating plugin (like ido.el in emacs)

2006-08-08 Thread Luc Hermitte
Hello,

* On Tue, Aug 08, 2006 at 09:46:28PM +0800, Eddy Zhao [EMAIL PROTECTED] wrote:
 The plugin could considerably speedup file accessing performance,
 especially when I'm maintaining a large wiki docbase. So I really
 want to know
   - if vim have equivalent plugin like ido.el
   - if not, is there any simple way to achieve the same effect in
 vim? (don't want to explicitly edit directory and locate file)

I'm not sure this is what you are looking for, but just in case...
I'm maintaining a plugin [1] that provides facilities (commands
actually) to apply commands (Ex commands) on files found in various
lists of directories ($PATH, runtimepath, path, or anything
specified).

Amongs the commands I provide, there are two that look for a file in
path, and split-open (horizontally or vertically) a new window with the
file found.

If several files match (a glob pattern is expected), a dialog box asks
for the file to open. If the file is already opened in a window, the
window gains the focus.
Command completion is supported for the filenames.

HTH,


[1] searchInRuntime.vim. It should be the plugin #229 on SF.
-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: fast file locating plugin (like ido.el in emacs)

2006-08-08 Thread Luc Hermitte
* On Wed, Aug 09, 2006 at 01:02:54AM +0800, Eddy Zhao [EMAIL PROTECTED] wrote:
  - It seems that I can't locate file named aaabbb thru directly typing
bbb, do I always have to locate file begin with the first letter of
the filename?

If, as I guess, its implementation relies on the same functions than
searchInRuntime.vim, try *bbb for your filename.

HTH,

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: Running win32 vim and gvim under Cygwin and pure Windows XP

2006-07-26 Thread Luc Hermitte
Hello,


I run vim on Solaris, Linux and Cygwin (actually I use only the win32
native version of vim, generally the one compiled by Tony).
And I have one set of scripts for all systems.

* On Tue, Jul 25, 2006 at 12:14:43AM -0700, Gary Johnson [EMAIL PROTECTED] 
wrote:
 To that end, I have done a standard install of Cygwin, installed the
 standard vim for Windows from vim.sf.net, put C:\Program
 Files\Vim\vim70 in my Windows PATH, added
 
 export SHELL
 
 to my $HOME/.bash_profile, and added the following lines to the top 
 of my _vimrc (C:\Program Files\Vim\_vimrc):
 
 if has(win32)  $SHELL == /bin/bash  
 executable(C:/cygwin/bin/bash)
Running in Cygwin.

I though I was detecting cygwin presence on $CYGWIN -- as it is more
likelly to be widelly spread. But it seems I'm using either $OSTYPE or
$TERM. 

More over I don't have any c:/ drive, and the shell can be anything.

BTW, we can also detect cygwin presence with executable('cygpath') ;
as long as cygwin paths are in the $PATH, because the windows box is set
to have cygwin in the $PATH, or because vim is launched from cygwin.

 In addition, I have found it necessary to make some changes to some
 plugins (ctags.vim and ccase.vim) following this example in 
 $VIMRUNTIME/ftplugin/perl.vim:

Indeed. Plugins need to transform a few things in order to be portable.
In my plugin system_utils.vim, I provide a few functions that help in
that purpose. I use them in my other plugins when I need to call
external programs like aspell, mkdir, ...

 So my questions to anyone else using Vim and Cygwin on Windows XP 
 are:  Does what I'm doing make sense?

Yes.

 Is there some way to fix the 'shellxquote' problem other than
 modifying every plugin I use as I've done above?

None that I know of.

 Is there a better way of doing any of this?
 
 I suppose I could build a Cygwin-aware vim binary, but I have
 successfully avoided having to compile anything under Windows so far
 and would really like to avoid that headache.

The problem is deeper than just having the right vim executable. There
are many different vim executables running on various system. As plugin
writers, we have to make our plugins portable. Discarding one vim binary
because there is another (patched) one that is compatible with the
plugin is not the solution.


Note: in case you are interrested, you will found on my web site:
- a shell script that lauches win32-vim from cygwin and that translates
  pathnames (and only pathnames) - cyg-wrapper.sh
- a plugin that provides a few functions to detect the current system
- .vimrc specific settings according to the current box vim is running
  on
- a few plugins that call external programs (lh-vim-spell, triggers)
- a compiler plugin-filter for cygwin that translates :make outputs
  from posix pathnames to windows pathnames. (- experimental plugin
  BuildToolWrapper (lh-BTW.tar.gz in vim/ressources/)

HTH,

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: insert space after comma based on context

2006-06-30 Thread Luc Hermitte
Hello,

* On Fri, Jun 30, 2006 at 09:03:57AM +0800, Dr Bean [EMAIL PROTECTED] wrote:
   Is there a way to not insert a space based on context around the
   cursor so that if the text before cursor is [xxx, or (xxx, no space
   will be inserted?
 
  He used the function InsertIfNotAfter() I define in my C++ ftplugin
  cpp_set.vim available in lh-cpp.tar.gz [1].
  In your case, I guess it will look like:
 
  inoremap silent ,
  \ c-r=InsertIfNotAfter(',', ', ', '[[(][^]]\+')cr
 
 Just for my own benefit, and to refresh my memory about what this
 means:
 
 It's a mapping to add a space after the comma, but only when the comma
 is not preceded by something the regex matches.

I must admit I never remember which parameter is expanded when.
If the pattern is matched, we expand the first parameter. The second
otherwise.

 What the regex matches is an opening bracket or parenthesis followed
 by a number of non-closing-bracket characters.
 
 Shouldn't the closing parenthesis be included also in the regex?
 '[[(][^])]\+'

Of course. You're right.

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: How to recognize different matching classes

2006-06-24 Thread Luc Hermitte
Hello,

* On Sat, Jun 24, 2006 at 08:52:47AM +0800, Dr Bean [EMAIL PROTECTED] wrote:
 On Fri, 23 Jun 2006, [EMAIL PROTECTED] wrote:
 
  PPS: In lh-cpp.tar.gz, you will find many examples of use. The
  patched, but not yet uploaded, version contains the following
  context-aware mappings and abbreviations:
 
 I'm looking forward to seeing those patches.

Done. I'll finish to play with svn latter.

 Your bracketing system is great.

Thanks ^^

 I wish I could only use the repeat . command to save even
 more typing labor.

That's something I miss too. I'm not sure there is a workaround. We can
always play with recorded macros, or quick'n'dirty mappings.

...
--ifinsert if statement   {{{
  Inoreabbr buffer silent if C-R=Def_AbbrC('if ',
  \ '\c-f\if (!cursorhere!) {\n!mark!\n}!mark!')cr
 
 [...]
 'if' is what is expanded.

'if' is what is expanded within comment/string context.

 C-R= inserts the results of the Def_AbbrC function,
 which does some whitespace substitutions.

Def_AbbrC() does some other things like:
- adding \n before (,{ and after ),} according to options.
- removing markers/placeholder according to another option.

 [...]
 I don't know what the c-f does.

It forces to reindent the line where the cursor is, it works in
INSERT-mode.
I see I have hard-coded c-f. It is not the best solution as I should
have used what is defined after the `!' in 'cinkeys'.

 
--,ifinsert if statement
   todo provide smappings
  vnoremap buffer silent localleaderif
  \ c-\c-n@=Surround('if (!cursorhere!) {', '}!mark!',
  \ 1, 1, '', 1, 'if ')cr
 
 This allows you to highlight some text, type '\if' and
 hey presto, the text becomes the body of an if statement.

Indeed.
Surround() has also another responsibility. I wrote it before vim7
permit to distinguish between visual-mode mappings and select-mode
mappings. Surround() checks if the current selection is a
marker/placeholder. If so, it expands 'if' in insert-mode (which will
result in the activation of the previous `if' abbreviation), otherwise
it does its surrounding work.
It also accepts some other options regarding reindentation, ...

 [...]

Otherwise, your analysis of my examples are correct.


 One problem I have in using the mappings is in perl many of the
 conditional keywords can be used in 2 ways.  In a compound statement
 'if' works just like in C. However it may also be used to modify a
 single statement, as in 'print Hello, world if 1'.
 
 I need to work out how to make the mappings context-sensitive to
 this. Like expand 'if' only if it is the first word in the line.

May be, you can look into InsertIfNotAfter() that I define at the end
of ftplugin/cpp/cpp_set.vim (check the newly uploaded lh-cpp.tar.gz
tarball archive). I use it to define the abbreviation for `namespace'
and the mapping on m-t.

What you will need is to analyze the lines before the cursor. if the
`if' you are typing starts a new instruction, then you can expand 
`if (!cursorhere!) {\n!mark!\n}!mark!', otherwise just
`if (!cursorhere!);!mark!'.
checking for the previous non comment code can be a little tricky.

 I forgot there is quite a lot of documentation. I need to look at it
 more.

Feel free to ask for any precision.

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: File browsing in Vim

2006-06-21 Thread Luc Hermitte
Hello,

* On Tue, Jun 20, 2006 at 07:43:19PM -0700, Suresh Govindachar [EMAIL 
PROTECTED] wrote:
 
 I can type :find  (with space) and hit tab to see the list of files
 in the present directory.  If I know there is an 'o' in the file's
 name, I can type :find *o* and hit tab to see all files (in some
 search path that includes the present directory) with 'o' in their
 name;  etc.  Sorry I can't give you the specific details to set things
 up this way.

Setting 'path' should be enough. 'wildignore' does also have some
interesting impacts. And there is also an option, which I don't remember
the name, that automatically appends the file extension when not
specified.

Lately, I've enhanced my plugin SearchInRuntime, (#229 on SF IIRC) to
define some new commands that, like :find, search for files in 'path',
and also:
- ask us which file to open (if several match)
- (v)split-open in a new windows the file chosen.


Now, I set my 'path' on a projects basis. And quite exclusively use
SearchInRuntime and a.vim to search and open my projects files.


-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: run commands in background enhanced script

2006-06-21 Thread Luc Hermitte
* On Wed, Jun 21, 2006 at 02:07:58PM +0200, Marc Weber [EMAIL PROTECTED] 
wrote:
 Hi. Here is my enhanced script.
 Should now work for all windows users with python enabled vim too.

Perl is likely more portable than python. For instance I have perl
installed on the solaris box I'm working on at work, while Python is
not.

 If you don't have any comments I'll add it to vimscripts an vim.org

Here are a few new thoughts then.

 = runinbg.vim 
 ==
  author : Marc Weber
  purpose: run commands in background and continue with your work
  os: 
linux with bash or python enabled, 
windows with bash or python enabled (not yet tested but should work)
 
  usage: see RunMakeInBG
  eg call RunMakeInBG('make all')
  or
  eg call RunMakeInBG(['make','all'])

I guess users will prefer commands over explicit functions calls.

NB: My plugins always start with
let s:cpo_save=cpo
set cpovim
if exists(g:loaded_runinbg) 
  \  !exists('g:force_reload_runinbg')
  let cpo=s:cpo_save
  finish 
endif
let g:loaded_runinbg = 1
and end with:
let cpo = s:cpo_save
 
  todo? kill processes on exit?
  handle stderr output with python, too

Indeed, stderr is quite important. 21 (or maybe even better
shellredir, I don't know) is a good friend as it won't desynchronize
stdout and stderr.

 if has('gui-running')  FIXME: get vim executable name insteadn (cargs 0)
   let s:vim=gs:vim

The string literal is odd.

 else
   let s:vim=s:vim
 endif
 let s:vim=/usr/bin/gvim

May be you can try executable('gvim') instead. In the perl module I've
defined, the heuristic I use is to search in $PATH : gvim.exe, vim.exe,
vim or gvim (in this order).
I guess on some *nix, we can always do a 
   :let vimpid = libcallnr(libc.so, getpid, )
   :let vimpath = matchstr(system('pmap '.vimpid.' | head -2 | tail -1')
   \ 'someregex')
On windows, (with the perl module when vim is not in the $path) I'm
looking for vim in the latest directory in $VIM (don't forget the
versionning scheme don't follow the lexical order;
i.e.: vim70  vim63b  vim63  vim62)


  add your tasks here
 fun! BackgroundJobHasStarted()

Script local functions is often a better default choice.


HTH,

-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: colseb_a.vim script, closign tags for vim /java.?

2006-06-11 Thread Luc Hermitte
* On Sun, Jun 11, 2006 at 03:13:22AM +0200, Marc Weber [EMAIL PROTECTED] 
wrote:
 I want the script to automatically close 
 
 function with 
 endfunction
  [...]
 
 Using it with java I could imagine to complete
 try {
 
 with
 } catch () {
 }
 [...]
 But I don't know exactly what to put in here?
 This is my attempt which didn't work yet.
 Can you help me?

Did you search for already existing solutions ?

For instance, I have a set of ftplugins for CC++ [1] (and another for
VimL, ...) that expand `try', `for', ... in the complete form (with
brackets, placeholders, ...) when not within comment/string literal
contexts.

I know there are a lot of similar [2] solutions out there.

HTH,

[1] http://hermitte.free.fr/vim/ressources/lh-cpp.tar.gz (I have to
upload the UTF-8 friendly version of the plugin)
[2] If you except the context-awareness
-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Regression in gvim 7.0.00x

2006-05-24 Thread Luc Hermitte
Hello,

I've been observing a regression on gvim since the release of vim 7.0.
I'm observing it on gvim 7.0.000 on windows, gvim 7.0.015 (or 17, I do
not remember) on Linux (gui=GTK2/Athena). It seems I do not have it with
the console version on Linux -- I haven't had the opportunity to test
the following lines of code with the console version.

I don't remember the problem on gvim 7.0e (at least I do not have it on
vim 7.0a on windows)


The problem consists in the combination of a few things:
- a nmapping selects (as in select-mode) a few characters
- an imapping calls a function (through i_CTRL-R) that executes the
  previous mapping with :normal, and then returns \esc to terminate
  the INSERT-SELECT mode and finish in select-mode.

Here are a few VimL lines that reproduce the problems.
Go in insert mode and type !exp!, Three lines are inserted, and
toto should be selected. It is not anymore

Hitting !jp! in normal-mode, or in insert-mode, selects toto as
expected.

Note: I have found a VimL workaround by returning
\c-\\c-n\c-\\c-ngv\c-g from I_expand_n_jump().
But there is still a regression I cannot explain.


--- % 
function! N_jump()
  call search('toto')
  let select = 'v' . virtcol('.').'|o'
  if selection == 'exclusive' | let select = select . 'l' | endif
  call search('toto\zs')
  return select.\c-g
endfunction

nnoremap !jp! @=N_jump()cr
imap !jp! c-\c-n!jp!

function! I_expand_n_jump()
  let str = toto\ntiti\ntutu 
  let l = line('.')
  put=str
  exe l
  normal !jp!
  return \esc\right
endfunction

inoremap !exp! c-r=I_expand_n_jump()cr
--- % 


-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: SNR, maparg(), and UTF-8

2006-05-22 Thread Luc Hermitte
Hello,

* On Wed, May 17, 2006 at 08:13:05PM +0200, A.J.Mechelynck [EMAIL PROTECTED] 
wrote:
 The problem has existed for a long time. The iconv() workaround
 works correctly with vim 7.0.012 on linux, but not with vim 7.0.000
 (default win32 build) on windows.
   
 Do you have +iconv or +iconv/dyn in :version? For better work with
 various encodings you need iconv.dll in some readable place.
 
 
 On windows build, I have +iconv/dyn IIRC. As it is the standard build
 from sourceforge, I guess the DLL is correctly provided -- I'll check
 that tomorrow.
 Can the function iconv() continue to transform characters without the
 DLL ?
 
 Without iconv.dll, Vim can only convert between UTF-8 and Latin1 (see 
 :help iconv()).
 
 To see if the +iconv feature is currently available, use :echo 
 has('iconv') (without the double quotes but with the singole quotes). 
 The answer should be 1 (you've got it) or 0 (you haven't).

   :echo has(iconv)
returns 1.

I guess I will have to forget about doing stuff like 
fun! s:Foo()
return foo
endf
fun! s:Bar()
 85 is the current scriptname
return bar\c-R=\SNR85_Foo()\crbar
 return iconv(bar\c-R=\SNR85_Foo()\crbar,
 \ 'latin1', encoding)
endf
inoremap bfb c-r=sidBar()cr



-- 
Luc Hermitte
http://hermitte.free.fr/vim/


SNR, maparg(), and UTF-8

2006-05-16 Thread Luc Hermitte
Hello,

I have a problem with an old hack that works fine in latin1, but starts
to cause problems in UTF-8.

The hack helps to replace activation key-sequences from i-mappings with
their mapped value, which are actually calls to script-local functions.

What is quite odd is that I have a workaround on Linux (by calling
iconv()) which has no, useful, effect on Windows (win32 build).

The problem has existed for a long time. The iconv() workaround works
correctly with vim 7.0.012 on linux, but not with vim 7.0.000 (default
win32 build) on windows.

Is there a solution to my problem (may be a patch for vim) ? Or have I
to change the scope of my i-mapped local-functions to global ?

Thank in advance for any hint.

Here follows a simplified viml code that illustrates what I'm trying to
achieve.

--- % 
 script1
function! s:foo()
   complex computations according to context, ...
  return foo
endfunction

inoremap !foo! c-r=sidfoo()cr

 ==
 script2 in real situation
function! s:bar()
  let foo = '!foo!'
  let m = maparg(foo,'i')
  if strlen(m) != 0
exe 'let m=' . 
   \ substitute(m, '\(.\{-1,}\)', '.\\\1.', 'g') . ''
if has('iconv')
   uncomment the following line to activate the workaround on linux
   let m = iconv(m, 'latin1', encoding)
endif
  endif
  return 'bar'.m.'bar'
endfunction

inoremap bfb c-r=sidbar()cr
--- % 


-- 
Luc Hermitte
http://hermitte.free.fr/vim/