Project specific settings

2007-05-14 Thread Marius Roets

Hi All,
I know this has been covered before, but I can't seem to find it by
searching Vim tips, so please excuse me if this has been ask many times
before.

I always uses spaces to indent my code, but a current project requires
me to use tabs. How could I make this setting only be in effect for this
one project, assuming that the project will always be a in a specific
directory.

Thanks
Marius


Why does VimResized get triggered 4 times per resize

2007-03-09 Thread Marius Roets

Hi everybody,
Can somebody explain the following behaviour to me. In my .vimrc I put
the following:
 --START --
function ResizeEvent()
  let lines = lines - 1
  execute '!echo resizing '.lines . '  test.txt'
endfunction

autocmd VimResized * call ResizeEvent()
  END ---
Now for every resize event, I get 4 lines in test.txt. The result is
that I end up with 'lines' being decreased 4 times, instead of just
once.

Thanks
Marius


Only half a command line in GVim

2007-03-08 Thread Marius Roets

Hi everybody,
I have been using GVim on X11 for years. Recently I have changed my
window manager to Compiz. Now, all (and I have many) sessions I have
created before the switch, shows only half the command line when I
load them. For instance when I type :q, I see only one . of the : and
the top half of the q. New files and sessions seem to be ok.

One way to solve this, would be to delete all saved session, and
recreate them, but I was wondering if somebody didn't know of an
easier way to fix this.

Thanks
Marius


Re: Getting out of netrw

2006-11-03 Thread Marius Roets

On 11/3/06, Jean-Rene David [EMAIL PROTECTED] wrote:


I thought of using :q but that closes vim if only
one window is open.

Am I missing something obvious?


I use :Sexplore (or :Vexplore) to open the explorer. Then it's not a
problem using :q. Or if you really want to be fancy, put this in your
.vimrc:
function MyExplore()
 tabnew
 Explore
 nmap buffer leaderq :qcr
endfunction

nmap F2 :call MyExplore()cr

Then F2 opens explorer in a new tab, and leaderq closes the tab, and
you should be back where you were before pressing F2.

Marius


Re: active links for opening files

2006-10-31 Thread Marius Roets

On 10/30/06, Yakov Lerner [EMAIL PROTECTED] wrote:

On 10/30/06, Michael M. Tung [EMAIL PROTECTED] wrote:
 Hi all:

 I am working on a simple plugin and want to make vim
 open a file which appears in text e.g. as

   [/tmp/test.txt]

 by clicking on it. The path and filename always appears
 in brackets.

You can do this by mapping  MouseDown and MouseUp
pseudo-keys:

nmap MouseDown .
nmap MouseUp ..

Yakov


Or rather LeftMouseRelease etc.


Re: BUG: mksession saves lcd in incorrect place

2006-10-24 Thread Marius Roets

On 10/24/06, Bram Moolenaar [EMAIL PROTECTED] wrote:



I see the problem.  I'll fix it.



Thanks Bram!


Re: BUG: mksession saves lcd in incorrect place

2006-10-24 Thread Marius Roets

On 10/24/06, Bram Moolenaar [EMAIL PROTECTED] wrote:



I see the problem.  I'll fix it.



This works correctly now after applying patch 7.0.147. Thanks again Bram.

Marius


Re: Quickfix behaviour

2006-10-23 Thread Marius Roets

On 10/20/06, Yegappan Lakshmanan [EMAIL PROTECTED] wrote:


The above problem with the quickfix window and the 'switchbuf' option
set to 'usetab' is now fixed by patch 7.0.146.

- Yegappan


This works perfectly now. Thanks a million.

Marius


BUG: mksession saves lcd in incorrect place

2006-10-23 Thread Marius Roets
Hi everybody,

I believe I have found a bug in Vim 7.0.146, relating to mksession and
lcd. Here is a small example. 
1) Open Vim
2) :e file1.txt
3) :tabe temp/file2.txt Any different directory
4) :lcd %:h
5) :mks test.vim
6) Close vim
7) Open vim
8) :source test.vim
9) The second tab is empty. The reason is that in the file test.vim the
order of events are (ignoring the uninteresting stuff):
 - cd where-ever-file1-is
 - edit file1.txt
 - tabnew
 - edit file2.txt
 - lcd where-ever-file2-is/

So even the second tab contains the correct lcd, the files opened in the
wrong directory. 

To manually fix the problem in the test.vim file:
/^lcd/
dd
/^edit file2/
P
:wq

Alternatively, the full path should be used to open file2.txt

Regards
Marius



Re: Quickfix behaviour

2006-10-21 Thread Marius Roets

On 10/20/06, Yegappan Lakshmanan [EMAIL PROTECTED] wrote:


The above problem with the quickfix window and the 'switchbuf' option
set to 'usetab' is now fixed by patch 7.0.146.

- Yegappan


Thanks, I will check it out.

Marius


Quickfix behaviour

2006-10-19 Thread Marius Roets

Hi everybody,
In a quickfix window, selecting an error (pressing enter) takes you to
that error. The way it does this is by opening the file in the window
above the quickfix window (if it is not open already, in which case it
jumps to the open buffer, assuming the buffer is in the same tabpage).
There are 2 problems I have with this situation. I can think of
solutions to them using a ftplugin and remapping enter, but I
thought maybe somebody had solved them already.
1) I would like to open a new window/tab, rather than use the one
above the quickfix window.
2) If the buffer is already open in another tab page, I'd like to jump
there, instead of opening it in this tab again.

Hope this is understandable.

Regards
Marius


Re: Quickfix behaviour

2006-10-19 Thread Marius Roets

On 10/19/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:



 1) I would like to open a new window/tab, rather than use the one
 above the quickfix window.

:h 'switchbuf' - split

 2) If the buffer is already open in another tab page, I'd like to jump
 there, instead of opening it in this tab again.

:h 'switchbuf' - useopen, usetab


Thanks, it works great with one exception. When the quickfix is the
only window in the tab (i.e. :tab copen), then it does not respect
usetab (it opens a new split). If I do a :new to have a empty open
window above the quickfix window, and then jump to an error, it works
perfectly. Strange.

Thanks
Marius


Re: Question about listchars

2006-10-19 Thread Marius Roets

On 10/19/06, Jeff Lanzarotta [EMAIL PROTECTED] wrote:

Hello,

I have the following in my vimrc,


 This shows spaces and tabs characters. Visual Whitespace.
set listchars=tab:»·,trail:·
set list


That all work well and good, but I would like to disable this display
of visual white space temporarily, do something, and then reset it back
to what I had. Is there a way to do this?

Peace,

How about this in your .vimrc
nmap F5 :set invlistcr
imap F5 esc:set invlistcra

and then F5 would toggle list on and off.

HTH
Marius


Using output of Vim commands in scripts

2006-10-16 Thread Marius Roets

Hi everybody,
Is it possible to use the output of Vim commands in a script? My
specific problem currently is that I would like to use the output of
:tabs in a script. I cannot find a Vim function that does the same as
this command. Any ideas?

Thanks
Marius


Strange behaviour of C-X and C-A

2006-10-11 Thread Marius Roets

Hi everybody,

I'm using Vim 7.0.94 on Linux. I use C-A and C-X from time to time to
increment/decrement numbers. However when there is a leading zero I
get very strange behaviour with both.
Example:
01
02
03
04
05
06
07
08
09
10
11

:nmap F7 C-Xj
I position the cursor on 01 and press F7, this works fine up to 08.
For 08, 09 and 10, the leading zero dissapears.
:nmap F7 C-Aj
Use the same unmodified list.
This is even weirder. 07 becomes 010, 08 becomes 9, and the rest seems ok.

Do others see the same behaviour. What am I missing?

Thanks
Marius


Re: Strange behaviour of C-X and C-A

2006-10-11 Thread Marius Roets

On 10/11/06, Peter Palm [EMAIL PROTECTED] wrote:

Op woensdag 11 oktober 2006 11:46, schreef Marius Roets:




set nrformats-=octal


Yep, this did it. Thanks!!

Marius


Uppercase keywords

2006-10-02 Thread Marius Roets

Hi Vimmers,
I have a big a (3000+ lines) source code file. The syntax highlighting
works perfectly, so all keywords are highlighted correctly. Is there
any way that I can use this fact to convert all keywords to uppercase,
or do I have to do them all one by one?

Thanks
Marius


Turning abbreviations on and off

2006-09-25 Thread Marius Roets

Hi everybody,

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.

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.

Thanks
Marius


cpp ftplugins not loaded

2006-09-10 Thread Marius Roets
Hi everybody,

I have a quick question regarding ftplugins. I created a directory in my
after/ftplugin directory for each filetype, with several plugins in
each. Up to now I had a directory called c, which served to hold plugins
for both c and c++ files, and this worked well. However I decided to
split the c++ plugins, and created a new directory called cpp. When I
edit c++ files, the filetype is correctly detected (cpp), but still only
the plugins in c directory are loaded. Those in the cpp directory are
ignored. 

Summary:
~/.vim/after/ftplugin/c/* - Are loaded for both c and c++ files
~/.vim/after/ftplugin/cpp/* - Ignored, even for cpp files

I'm probably missing something simple here, so any pointers will be
appreciated.

Thanks
Marius



Re: cpp ftplugins not loaded

2006-09-10 Thread Marius Roets
Hi Yakov,
On Sunday 10 September 2006 12:27, Yakov Lerner wrote:
 I created file ~/bat/my.dir.vim/after/ftplugin/c/xxx.vim containing line
 call input(This is after/ftplugin/c/xxx.vim)
 and file ~/bat/my.dir.vim/after/ftplugin/cpp/cpp_xyz.vim containing line
call input(This is after/ftplugin/cpp/cpp_xyz.vim)
 When I do 'set ft=cpp', both files are loaded.
 When I do 'set ft=c', only 1st file is loaded.
 So my vim7 behaves as expected.
 Mine is vim7.0.86

 I suggest that you insert 'call input()' with distinct prompt into your
 ~/.vim/after/ftplugin/cpp/*  to distinguish between case (1) whether
 those files are not loaded vs (2) files are loaded but do not take
 effect. Additionally you can use :scriptnames to see whether scripts
 are loaded.

 Which vim version is yours.
7.0.94

I followed your advice and great was my surprise to see that it works as
expected. I've been trying in vain to recreate the situation where it
didn't work. Somewhere I must have done something wrong, and corrected it
in the meantime, but I'll be darned if I know what:) I think I will have
to write this one off to too many late nights.

Apologies for the unnecessary post.


Marius



Re: cpp ftplugins not loaded

2006-09-10 Thread Marius Roets
Hi Tony,
On Sunday 10 September 2006 12:51, A.J.Mechelynck wrote:
 AFAIK both sets should be loaded. See:

 - BufRead and BufNewFile autocommands for the concerned file extension
 (*.c, *.cpp, *.c++, etc.)
 - FileType autocommand
 - function s:LoadFTPlugin in $VIMRUNTIME/ftplugin.vim
 - c ftplugins are invoked by $VIMRUNTIME/ftplugin/cpp.vim
(snip)

 If the plugins in the three last lines of the list above aren't sourced
 it might conceivably be a bug in the code for the runtime[!] command
 (e.g. storing the arguments in static storage instead of on the stack)
 but I doubt it.
Thanks for the advice, but it seems to working now. See my post to
Yakov. Still don't know what I did wrong. Sorry :)

Marius



Re: Can I make my sesion forget it's a session

2006-08-31 Thread Marius Roets

On 8/30/06, A.J.Mechelynck [EMAIL PROTECTED] wrote:



A session is not only a number of settings, it's also one or more
editfiles etc. To make a session forget all that makes it a session, use

:qa

followed by

vim

or

gvim

(the latter may be entered in an Alt-F2 popup). Once you are satisfied
that you have what you want, use the :mksession command (q.v.). Or, if
you have a GNOME build of gvim, you can log out of the (kde or GNOME)
window manager and let gvim save its session transparently.

See
:help :mksession
:help :mkview
:help -o
:help -S
:help gnome-session

If the above (starting a new session afresh) is too drastic for you, you
may _first_ use :mksession, then edit the session file (e.g. by removing
the settings you don't want anymore) and finally :qa and gvim -S

Best regards,
Tony.


Hi Tony,
Thank for your suggestions. These were the sort of solutions I had in
mind, I was just hoping there might be something simpler. It just
means, for each session I have to reopen every window the way it was,
and then save the session again, which is what I was trying to avoid.
But if there is no other way.

Thanks
Marius


Re: How to insert text via script/function call ?

2006-08-18 Thread Marius Roets

On 8/18/06, Meino Christian Cramer [EMAIL PROTECTED] wrote:

Hi,

 I often need to place a header above a function defintion (C-source)
 fpr documentational purposes.

 What I treid is to write a short function for vim, which dioes insert
 the text skeleton -- but I did not find any already existing function
 in the API which does this for me. With :i I got weird effects --
 sure my fault, but... .

 How can I insert text via a script ?

 Kind regards,
 mcc



Hi
I got this in my .vimrc:

function! ReadSkeleton()

  if exists (g:Skeleton_path)
 let skeleton_path = g:Skeleton_path
  else
 let skeleton_path = getcwd()
  endif

  let filenameList = split (glob ( skeleton_path . /*.*) , \n)
  let filenameList = insert (filenameList, Select skeleton to load)
  let choiceList = copy (filenameList)
  let choiceList = map (choiceList, 'index(filenameList,v:val) .. . v:val')
  let choiceList[0] = Select skeleton to load
  let listLen = len(choiceList)
  let choiceList = add (choiceList, listLen . . Browse for some
other folder (gui ONLY))
  let choice = inputlist(choiceList)
  echo choice
  let skeletonName = 
  if choice == listLen
 Do the browse thingie if possible
 if has(browse)
   let skeletonName = browse(0,Select session to
restore,skeleton_path,)
   echo skeletonName
endif
  elseif choice  0
 Load the file
 let skeletonName = filenameList[choice]
  echo setting skeletonName to . skeletonName
  endif
  if skeletonName != 
 execute 0read  . skeletonName
  endif
endfunction
nmap F4 :call ReadSkeleton()cr
let Skeleton_path = /home/mroets/.vim/skeletons

I put all the skeletons for programs (perl, c , php etc), each in
their own file in a directory, and set Skeleton_path to this directory
in my .vimrc. Now I press F4 and choose which skeleton I want for my
new file.

HTH
Marius


Re: Search all text files in a directory for text

2006-08-18 Thread Marius Roets

On 8/18/06, Jerin Joy [EMAIL PROTECTED] wrote:

Hi,

I have a lot of source code distributed over a directory hierarchy
structure. I always need to find class declarations, instances where
variables are set etc. Usually I just go to command line and run
something like
find . -name *.vr -print | xargs grep 'class foo'

Isn't there an easier way to do this in vim? I can't use cscope since
the source is not in C.

Jerin


--
http://jerinj.blogspot.com/
--



Exuberant ctags supports 33 languages. Maybe yours is one of them:

http://ctags.sourceforge.net/

Marius


Re: Creating a syntax file with folding

2006-08-16 Thread Marius Roets

On 8/15/06, Charles E Campbell Jr [EMAIL PROTECTED] wrote:



   syn clear
   syn region xBlock transparent fold matchgroup=Delimiter start=begin
end=end contains=xBlock


Regards,
Chip Campbell



I do believe you are a genius. Thanks.

Marius


Re: gP-confusion

2006-08-16 Thread Marius Roets

On 8/16/06, Meino Christian Cramer [EMAIL PROTECTED] wrote:

Hi,

 finally I found (nearly) what I am searching for...but...

 I wanted a command which after doing a y$ from in the midth of a
 line, puts my yanked text after the end of the line and the cursor
 right after the put text.

 The help of gP states (my im is nocompatible):

 [x]gP Just like P, but leave the cursor just after the new
text.  {not in Vi}


 But it seems I understand the help wrongly. Example:

   This is a very boring example of a line.
   x

 (x=position of the cursor)

 I do a y$gP and the line looks like:

   This is a very boring example of a line.a very boring example of a line.
   x

 The help says:
  ...but leave the cursor just after the *new*
text.


Hi,
Using your example of a boring line I got:
This is a very boring example of a line.
   x
Doing y$P I get :
This is a very boring example of a line.s a very boring example of a line.
  x
and y$gP I get :
This is a very boring example of a line.s a very boring example of a line.
   x
This might be case of the help being slightly ambiguous. I think what
it means is, after the new text *starts*, and not at the end of the
new text. If you see no need for the gP function, you could do
:nmap gP gP$
which would give you the behaviour you expected.

HTH
Marius


Re: gP-confusion

2006-08-16 Thread Marius Roets

On 8/16/06, Marius Roets [EMAIL PROTECTED] wrote:

On 8/16/06, Meino Christian Cramer [EMAIL PROTECTED] wrote:
 Hi,

  finally I found (nearly) what I am searching for...but...

  I wanted a command which after doing a y$ from in the midth of a
  line, puts my yanked text after the end of the line and the cursor
  right after the put text.

  The help of gP states (my im is nocompatible):

  [x]gP Just like P, but leave the cursor just after the new
 text.  {not in Vi}


  But it seems I understand the help wrongly. Example:

This is a very boring example of a line.
x

  (x=position of the cursor)

  I do a y$gP and the line looks like:

This is a very boring example of a line.a very boring example of a line.
x

  The help says:
   ...but leave the cursor just after the *new*
 text.

Hi,
Using your example of a boring line I got:
This is a very boring example of a line.
x
Doing y$P I get :
This is a very boring example of a line.s a very boring example of a line.
   x
and y$gP I get :
This is a very boring example of a line.s a very boring example of a line.
x
This might be case of the help being slightly ambiguous. I think what
it means is, after the new text *starts*, and not at the end of the
new text. If you see no need for the gP function, you could do
:nmap gP gP$
which would give you the behaviour you expected.

HTH
Marius


My first line should be:
This is a very boring example of a line.
 x
to get the results I described. Strange fonts in gmail, sorry.

Marius


Re: gP-confusion

2006-08-16 Thread Marius Roets

On 8/16/06, Yakov Lerner [EMAIL PROTECTED] wrote:




gp  puts after the cursor, gP puts before the cursor.

When you want to paste at the front of the line, you want
gP, like 0gP. When you want to paste at the end of the
line, you'll want to use $gp.

So your command for yanking till end of line and appending
at end of line will be:
y$$gp
*not* y$$gP. y$$gP would insert at the wrong place, 1 character before
end of line.

Yakov


Of course, you're right. Ignore my message, I got confused:)

Marius


Creating a syntax file with folding

2006-08-15 Thread Marius Roets

Hi everybody,
I am trying to create a syntax file with folding. However after
pouring over the documentation for hours, I seem to be stuck. I want
to, for instance, fold a begin/end block. I have created a simple
syntax file with just this line:

syntax region xBlock start=begin end=end transparent
contains=xBlock,xKeyword fold

As expected, this works well. However 'begin' and 'end' are keywords. So I add:
syntax keyword xKeyword begin
This breaks the fold. It no longer sees the begin. I changed it to
syntax match xKeyword \begin\
And now it works again. Now for 'end'. I know that defining it as a
keyword is problematic, so I do a match again.
syntax match xKeyword \end\
This breaks the fold again however. Even though every 'begin' starts a
new fold, 'end' doesn't end them. I tried adding keepend to the
region, but then the first 'end' ends all folds. There must be
something that I am not understanding. Any help would be appreciated.

I have included a file I have used to test.

Thanks
Marius

#
Test file
#
function myFunction
begin
  some code;
  command;
  and ;
  other stuff;

  begin
 a new
 block;
  end;


  and some;
  more stuff;

end;