Re: Why bottom-posting is prefered on Vim Mainling List?

2007-05-30 Thread Jean-Rene David
* [EMAIL PROTECTED] [2007.05.29 05:15]:
> See, though I always do trim, I still suffered
> from those who do not trim and use
> bottom-posting.

I take it your mail program doesn't have a
"hide-quoted-text" function. Who says text-based
mail programs are primitive? :-)

-- 
JR


Re: vim 7.1 and cr/lf interpretation

2007-05-15 Thread Jean-Rene David
* A.J.Mechelynck [2007.05.15 08:01]:
> If you had, as I already told you twice (this is
> the third one) done
> 
>   :set fileformats=
>   :e ++ff=dos list02.p
>   :w
> 
> your file would have been repaired immediately.
> SO WHY DIDN'T YOU?

Or equivalently:

:e list02.p
GA " add ^M at the end of the last line
:w
:e

-- 
JR


Re: omni-completion

2007-05-09 Thread Jean-Rene David
* Normandie Azucena [2007.05.09 09:30]:
> this will seem to be a dumb question.
> what is omni-completion?
> How can I use it in vim?
> How can I create my own?

Have you given 

:h omni-completion

a try?

-- 
JR


Re: Filename completion with all directories in 'path'?

2007-04-19 Thread Jean-Rene David
* Ben Kovitz [2007.04.19 20:00]:
> Is there a way to make filename completion
> (pressing tab at the command line in :find) use
> all the directories in the 'path'?

Not exactly what you ask, but here is a nice
little script I use quite a bit which you might
find helpful:

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

HTH,

-- 
JR


Re: about fonts in gvim

2007-04-18 Thread Jean-Rene David
* shawn bright [2007.04.18 12:45]:
> is there a way i can permanently set the font
> for gvim ?  i can't find a config file for it.

:h 'guifont'

-- 
JR


Re: CLTR-N and enter

2007-04-17 Thread Jean-Rene David
* Eric Leenman [2007.04.17 04:15]:
> Is it possible to select the right word with
> another key then the enter-key, and thus staying
> on the same line before CTRL-N was pressed at
> all?

Yes, just continue typing...

See:

:h popupmenu-keys

It defines the only keys which are special in the
popup menu. Any other key will just have its
normal effect.

-- 
JR


Re: Troubles configuring vim (multi-questions)

2007-04-16 Thread Jean-Rene David
* Gene Kwiecinski [2007.04.16 11:45]:
> Displays "^I" just fine, but trashes actual
> indentation, at least for me (dunno if there's
> any magical 'vim' setting, like ":set
> keepindent" or something).

set listchars+=tab:>-

-- 
JR


Re: command to delete just whitespace

2007-04-15 Thread Jean-Rene David
* shawn bright [2007.04.15 20:15]:
> Hey there, i am looking for a command that will
> delete all whitespace up until the first
> character.
> 
> for example
> 
> []some_characters
> []some_characters.

:s/^\[\]\zs\s*//

-- 
JR


Re: Setting font in console vim

2007-04-12 Thread Jean-Rene David
* [EMAIL PROTECTED] [2007.04.12 10:30]:
> I can set the font in gvim using:
> Set guifont=
> 
> But how do I do the same with console vim?

You change the console font. :-)

If you use cygwin I can tell you how I do it for
rxvt or xterm.

-- 
JR


Re: delete buffer questions

2007-04-09 Thread Jean-Rene David
* alebo [2007.04.09 15:00]:
> But if I use another kind of deletion like dw, I
> couldnt fetch it from the buffers 1-9, only from
> the first "unnamed" buffer. Why is this so and
> which kind of delete operations are supported in
> the delete buffers?

If you delete less than one line, the data is put
in the "small-delete" register: "-

:h quote-

It is number 3 in the list of register types found
at:

:h registers

You can see its current content by doing:

:di -

-- 
JR


Re: how to delete all occur of a character

2007-04-09 Thread Jean-Rene David
* Przemyslaw Gawronski [2007.04.09 09:45]:
> :argdo %s/\"//g | update

" is not special, so no need to quote it.

:argdo %s/"//g | update

-- 
JR


Re: How to open a BIG file quickly?

2007-04-05 Thread Jean-Rene David
* Tom Purl [2007.04.05 12:00]:
> > I need to do that quite often. They are usually
> > log files from a long running program in debug
> > mode.
> 
> Actually, you can think of a log file as a sort
> of flat file database.  Here's an example

I appreciate all the help but I really don't have
a problem with large files. I *do* preprocess my
large files with grep/awk/perl in all sorts of
ways and *do* use vim to view and edit the
resulting chunks.

I am not the OP, and I was just mentioning log
files because someone sounded surprised one might
legitimately need to edit a 1GB file.

And before somebody mentions it, I do know about
logrotate... :-)

-- 
JR


Re: How to open a BIG file quickly?

2007-04-05 Thread Jean-Rene David
* Tom Purl [2007.04.05 10:30]:
> On Thu, April 5, 2007 2:38 am, ³Â·½ÈÙ wrote:
> > If I want to open one 1G bytes size
> > file,it's really slow.

I suggest splitting it into smaller chunks with
another tool.

> Just out of curiosity, why are you trying to
> edit a 1 GB file with any text editor?  I'm
> assuming that these files are flat file
> databases.  

I need to do that quite often. They are usually
log files from a long running program in debug
mode.

-- 
JR


Re: OT: Reply-To munging [was: [SOLVED] Need advice on pattern matching using match()]

2007-04-04 Thread Jean-Rene David
* Michael Klier [2007.04.04 17:30]:
> I am sure this has been questioned before but why is the
> "Reply-To:" header field not set via the mailing-list?

Short answer: because it makes it more difficult
to reply to the author without making it easier to
reply to the list.

Long answer:
http://www.unicom.com/pw/reply-to-harmful.html

-- 
JR
$ grep reply .muttrc
folder-hook . bind index r reply
folder-hook .*-L$ bind index r list-reply


Re: ok, new question on search

2007-04-02 Thread Jean-Rene David
* shawn bright [2007.04.02 12:00]:
> when i do a search like  /text
> it highlights all of the matches and i can use n
> and N to navigate.  how do i turn the
> highlighting off when i am done?

There's a command to do exactly that:

:nohlsearch

This will turn off highlighting for the current
search. Highlighting will come back for the next
search.

Note that this is different from the 'hlsearch'
option, whose effects are permanent.

Of course you can map this:

:map  :nohlsearch

-- 
JR


Re: need a new way to scroll

2007-03-30 Thread Jean-Rene David
* shawn bright [2007.03.30 09:15]:
> I know that i can do 20Ctrl-E or Y to do 20 at a
> time, but thats kinda long, is there another way
> that might be cool, maybe map 20 lines down to
> some key i don't use much ?

Use the power of mappings!

:nmap  20
:nmap  20

I also often use H, M, L combined with zb, zz and
zt. I like being able to move around while keeping
control of the cursor position. And it allows
moving by half-screens, which I also find
convenient since I always have enough context to
follow the code.

-- 
JR


Re: How to remove 2 or more empty lines when closing the the file?

2007-03-30 Thread Jean-Rene David
* Eric Leenman [2007.03.30 06:45]:
> With the follwing subtitue it's possible to
> remove blocks of 3 empty lines
> :%s/^\n\{3}//
> 
> How do you need to change it, so that it does
> remove blocks of 2, or more,
> empty lines?

:%s/^\n\{2,}//

> And how do you give this command just before
> closing the file?

One way is to use autocommands. 

:au BufLeave * :%s/^\n\{2,}//

Note that this implementation will give you a
warning if the pattern is not found.

See 

:h autocmd-events

if BufLeave isn't exactly what you want,

:h autocmd-patterns

if * isn't exactly the file pattern you want, or

:h autocommand

For the general discussion.

-- 
JR


Re: Search & Replace in VIM Script

2007-03-27 Thread Jean-Rene David
* oskar [2007.03.27 11:25]:
> I have a vim script which I want to use to
> search & replace a part out of a given line. The
> fields in the line are based on field length and
> the field I want to change starts at position 33
> and ends after 4 charachter.

Sample data and the result you expect would make
things so much easier...

This will match characters in columns 33-36:

/\%33c

:h /\%c

-- 
JR


Re: Deleting some lines from a log file

2007-03-27 Thread Jean-Rene David
* Eddine [2007.03.27 09:45]:
> ENTRY
> 
> 184
> 185  
> **;
> 186  *   PGMs Complexes   1 : enable - O : disable
>   *;
> 187  
> **;123
> 
> 188
> 189   %include "&pgm.MainComplex.sas"; ** Macro principale
> Base et Queries **;
> NOTE: %INCLUDE (level 1) file E:\IFM
>  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
> is file E:\IFM
>  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.
> 
> 269 
> +**;
> MPRINT(MAINCOMPLEX):
> **;
> 
> RESULT :
> 
> NOTE: %INCLUDE (level 1) file E:\IFM
>  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
> is file E:\IFM
>  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.
> 
> **;
> 
> (for a try :%s/^[0-9]*/TEST/ didn't work).

You are close. The problem is that this pattern
will match *every* line, since you accept "zero or
more" digits at the beginning of the line.

Try:

:%s/^[0-9]\+/TEST/

Using \+ instead of * in the pattern will match
"one or more" instead of "zero or more".

Then to also match lines that begin with MPRINT:

:%s/^\([0-9]\+\|MPRINT\)/TEST/

Then to delete them (make sure you undo the
previous substitution...):

:g/^\([0-9]\+\|MPRINT\)/d

HTH,

-- 
JR


Re: Error format and quickfix

2007-03-27 Thread Jean-Rene David
* Christophe Dupre [2007.03.27 07:15]:
> Here is what I get when I do copen.
> 
> || ccsc main.c +FH +P +DC +LO +EA +STDOUT I+="..\Includes"
> || >>> Warning 201 "C:\Project\Test\OnlineMS\Firmware\Source\rs232.c"
> Line 48(1,1): Assignment inside relational expression
> || *** Error 12 "C:\Project\Test\OnlineMS\Firmware\Source\main.c" Line
> 97(3,4): Undefined identifier   j
> ||   1 Errors,  1 Warnings.
> [...]

To avoid mistakes, it would be easier if you
provided your *compiler's* output, not what you
see in the quickfix window. For example, in the
above, one has to deduce that the line wrap has
been added by vim, but it may as well have been in
the compiler's output. Another reason will be
apparent below.

> I guess what I need to define is the format for
> only these 2 lines (correct me if I'm wrong) ,
> and can ignore the rest.

Yes, I think this is correct.

> || >>> Warning 201 "C:\Project\Test\OnlineMS\Firmware\Source\rs232.c"
> Line 48(1,1): Assignment inside relational expression
> || *** Error 12 "C:\Project\Test\OnlineMS\Firmware\Source\main.c" Line
> 97(3,4): Undefined identifier   j
> 
> Here is what I think I should define.
> \|\|\ \>\>\>\ %t\ %n\ %f\ Line\ %lXXX%m
> \|\|\ \*\*\*\ %t\ %n\ %f\ Line\ %lXXX%m
> Can you spot anything wrong here?

Yes. 

The || characters at the beginning of the line are
added by vim on lines it doesn't recognize. You
needn't parse them because they are not part of
you compiler's output.

> How do I deal with the (1,1), and the (3,4)?

That depends what they mean. 

-- 
JR


Re: How to turn a q recording into a map?

2007-03-23 Thread Jean-Rene David
* [EMAIL PROTECTED] [2007.03.23 19:45]:
> I was thinking that there should be a way to
> take the register lines and automatically turn
> them into an noremap (including adding the @ to
> start register playback). Has anyone perfected
> this?

If you want your mapping to follow the (possibly
changing) content of q:

map  @q

If you want your mapping to stay fixed even if
register q changes:

:exe "map  " . expand(@q)

and then you can map that...

map  :exe "map  " . expand(@q)

HTH,

-- 
JR


Re: Customizing vim: How to change the char before commands

2007-03-22 Thread Jean-Rene David
* Some user [2007.03.22 15:00]:
>  RANT 
> Though I don't really get the reason why every
> command is preceded by colon.

Not to nitpick, but commands themselves don't
really care about the colon. The colon is used to
*change mode*.

In normal mode, you can just type away your
commands without any colon, ever. 

Command-line mode accepts just one command at a
time, so you need to re-enter a colon for each new
command to re-enter command-line mode.

For multiple successive commands, you can use
either Ex mode or the command window:

:h Ex-mode
:h cmdwin

It sounds like you would like to be able to do
everything from normal-mode. But then you would be
lacking a lot of the expressive power of vim
commands.

> It should be one keypress, like maybe
> semi-colon. 

map ; :

> One quick question, please if you could answer:
> what if I want to map something like a two keys
> in succession to something, like gg for save, gz
> for quitting and saving. How would it change?

map gg :w
map gz :wq

-- 
JR


Re: Count characters

2007-03-22 Thread Jean-Rene David
* Harald Kröll [2007.03.22 13:30]:
> Is there some function or script to count
> characters (letters without whitespaces) in vim?

One way is to use the 'substitute' command's
ability to tell you how many items it replaced. So
if you type:

:%s/\S/&/g

You will get a message saying how many non-blank
characters were found and replaced by themselves.

-- 
JR


Re: Quck Add & Remove comments

2007-03-22 Thread Jean-Rene David
* Andreas Bakurov [2007.03.22 09:00]:
> I trying to find a way to quickly remove and add one line comments (//
> or /* */) to Java or C/C++ code.
> What is a effective "combo" to achieve this.

You could do this manually with mappings and such,
but I find there are so many special cases
(especially with the C-style /* */ type of
comments) that I prefer using a plugin in which
most of the dirty work can be hidden away.

Here is one:

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

-- 
JR


Re: question about search

2007-03-22 Thread Jean-Rene David
* Dave Land [2007.03.22 08:15]:
> " Command-[ and Command-] put the prev/next match at top of screen
> map  kNz " put prev match at top of screen
> map  jnz " put next match at top of screen

Very recently on the list someone suggested these
very simple and elegant mappings:

nnoremap n nzz
nnoremap N Nzz

The up-side is you don't need to remember a new
keystroke -- the down side is you lose the old
behavior.

-- 
JR


Re: Consistently exit "message display" with 'q'?

2007-03-20 Thread Jean-Rene David
* Bram Moolenaar [2007.03.20 11:45]:
> > How many times did I repeat a command just because
> > I had pressed  one time too many...
> 
> You can type "g<" to go back to the messages.

Thanks! Didn't know about that.

Reading the help, this only brings back the last
viewed page of messages though. Not quite the same
thing as bringing up the complete output of the
last command.

-- 
JR


Re: Consistently exit "message display" with 'q'?

2007-03-19 Thread Jean-Rene David
* [EMAIL PROTECTED] [2007.03.19 22:30]:
> The more frustrating thing is: if I continuously
> scroll down in the 'more-prompt' mode, the
> 'more-prompt' will eventually quits the display
> and the message are disappeared forever, so I
> must be careful NOT to press any key when the
> last line of message are shown. 

I'm fairly sympathetic to this concern.

How many times did I repeat a command just because
I had pressed  one time too many...

-- 
JR


Re: How to show path?

2007-03-16 Thread Jean-Rene David
* Peng Yu [2007.03.16 16:30]:
> Can somebody let me know how to show the current
> value of "path"?

:set path?

-- 
JR


Re: How to switch between horizontal split and vertical split?

2007-03-13 Thread Jean-Rene David
* Peng Yu [2007.03.13 12:15]:
> Suppose I have horizontal splited window1 and
> window2, is there any way to change them into
> vertical split and vice versa?

CTRL-W H
CTRL-W J

Note the capital "H" and "J".

-- 
JR


Re: match html tag

2007-03-13 Thread Jean-Rene David
* Albie Janse van Rensburg [2007.03.13 10:00]:
> You are looking for %.  In order to enable the
> use of it, you need to enable the matchit
> plugin.  See :help matchit

matchit is an external plugin.

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

-- 
JR


Re: visual mode acting up

2007-03-11 Thread Jean-Rene David
* Simon Jackson [2007.03.12 01:30]:
> when i have text selected in visual mode, i type 'y' and instead of
> yanking the text it overwrites it. anyone know why?

Maybe it's been mapped to something else.
What does:

:verbose vmap y

say?

Does the overwriting text give a clue to where it
came from?

-- 
JR


Re: Searching within a delimited area

2007-03-02 Thread Jean-Rene David
* Afton Lewis [2007.03.02 13:30]:
> How would I search for a regex within a particular area? 

Once the text is selected visually, you could do:

:g/regex/#

which will appear as

:'<,'>g/regex/#

This will display all matching lines with line
numbers prepended.

Not as sophisticated as the other solutions you
got, but sometimes it's enough.

-- 
JR


Re: mark an anchor

2007-03-02 Thread Jean-Rene David
* Bin Chen [2007.03.02 09:45]:
> If I am in line 100, now I want to search a key
> which will lead me to wherever. I want to back
> to the place before the seach, can vim support
> anchor for me to back?

If I understand your question, CTRL-O will do what
you want.

:h CTRL-O

-- 
JR


Re: Mapping to the "numerical" - and + and *

2007-03-01 Thread Jean-Rene David
* Eric Leenman [2007.03.01 13:30]:
> >How were you planning to use those?
>
> I want to use these as cut, paste and copy iso
> CTRL-X, V and C.

Cutting and copying are compound operations in the
sense that you need to specify /what/ they are
going to act on. There are many ways to do this,
depending on the mode you are in.

> I now got
> :vnoremap  "+p
> :vnoremap  "+d
> :vnoremap  "+y

This looks fine.

What you want to act on is implicitly the visual
selection.

> :noremap  "+p

This is fine.

> :noremap  "+d
> :noremap  "+y

Here you will need to specify *what* you want to
"cut" or "paste" with a motion command after you
have pressed  of .

> :inoremap  "+d
> :inoremap  "+y

These are "insert-mode" mappings. So of course you
get "+d in your text. This is exactly what you
told vim to do.

What do you *mean* when you are in insert mode and
want to "cut" or "copy"? "Copy" what?

One possibility is to revert to normal mode and
follow the command with a motion:

:inoremap  "+d
:inoremap   "+p

> :inoremap  "+p

This is meaningful but the syntax is incorrect.
Tony gave you the answer for this one.

> I tried the help CTRL-R but I don't follow that.

It would help if were more explicit about the
parts you don't understand.

In normal mode, pressing "+p means: 
'put the content of register + after the cursor'.

In insert mode, pressing "+p means: 
'insert " then + then p'. 

It has nothing whatsoever to do with registers.
This is where CTRL-R helps you. + is the
insert-mode equivalent of "+p in normal-mode.

-- 
JR


Re: Mapping to the "numerical" - and + and *

2007-02-28 Thread Jean-Rene David
* Eric Leenman [2007.02.28 08:00]:
> Is it possible to map the - and + and * keys on
> the "nummerical section of a keyboard" (in other
> words the keys in the group where the num-lock
> key is also)

That part of the keyboard is sometimes referred to
as the "keypad". You can refer to those keys in
vim with the following (from :h key-notation, near
the end of the table):

notationmeaning equivalent  decimal value(s)~
---
[...]
 keypad +*keypad-plus*
keypad -*keypad-minus*
 keypad **keypad-multiply*

> to functioan as cut, paste and copy?

In vim, "delete" always saves the deleted data
somewhere. So in that sense, it's equivalent to
"cut", as long as you know where vim put the
stuff. The other operations are referred to in vim's
documentation as "put", and "yank".

These operations usually require more than one
keystroke. How were you planning to use those?

-- 
JR


Re: trying to leave the GUI world and enter the world of VIM

2007-02-27 Thread Jean-Rene David
* Peter Michaux [2007.02.26 22:00]:
> Does vim have the concept of a project of files? 

You might want to look at this:

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

Found by searching vim.org with the keyword
'project'.

HTH,

-- 
JR


Re: search something from vim in certain directory

2007-02-22 Thread Jean-Rene David
* Peng Yu [2007.02.22 16:15]:
> I read the help. But I still don't see how to search in all the *.h
> and *.cc in a certain directory. Do I have to rely on the external
> command "find"?

It would help if you told us what version of vim
you use and what you tried.

If you have vim 7, you can use:

:vimgrep pattern directory/**/*.h

See

:h wildcard

Otherwise:

:grep -r pattern directory

though that will search all files in the
directory, recursively.

If your 'shell' is zsh, then you can use zsh's
recursive globbing patterns:

:grep pattern directory/**/*.(h|cc)(.)

If you use indexing with glimpse, you can specify
which files in which directory to index.

man glimpse
man glimpseindex

-- 
JR


Re: search something from vim in certain directory

2007-02-22 Thread Jean-Rene David
* Peng Yu [2007.02.22 11:15]:
> I have a C++ project in some dir say "project"
> or its subdir. Although I can use find and grep
> outside vim to search for any word in "project".
> But this is not very convenient.

Well you can use an external grep from within vim.
One advantage is that it's relatively fast and you
can use the quickfix window. An inconvenient is
that you can't use vim regex.

:h grep
:h grepprg

If you have vim 7, then you can use vimgrep.

:h vimgrep

If your project is large, you could also use an
indexing program like "glimpse". See

http://www.vim.org/tips/tip.php?tip_id=1021

-- 
JR


Re: How to: display only the lines that have a matching pattern and fold /hide others.

2007-02-21 Thread Jean-Rene David
* Muddassirali Mirzani [2007.02.21 07:30]:
>  Is there a way to display only the lines that match
>  a search pattern and hide/fold others.

The foldutil plugin makes that very easy. I use it
quite a bit.

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

-- 
JR


Re: :wq vs ZZ

2007-02-13 Thread Jean-Rene David
* Gene Kwiecinski [2007.02.13 17:00]:
> [...]
> I never liked ":wq", because you gotta do
> 
>   depress 
>   <:>
>   release 
>   
>   
>   

For most actions in vim, I too often look for the
very fastest, fewest-keystrokes way. However
quitting is not one of them.

I agree with Tim's point: when I quit I prefer
being forced to be explicit about *how* I quit.

-- 
JR


Re: How to diff in gvim

2007-02-13 Thread Jean-Rene David
* Naim Far [2007.02.13 07:54]:
>   When using diffsplit I have to supply the full
>   path of the second comparison file, what if I
>   simply want the comparison to be done with
>   another already opened buffer?!

I usually do this in two phases. First setup the
vertical split, then use:

:windo diffthis

To setup the split, here are two easy ways
depending on whether you know the buffer number or
not:

If you do (and say that number is 2):

:vert sb 2

If you don't:

:vert sb 

will give you a list of opened buffer to choose
from. You can use completion again after typing a
few characters. But it might be even quicker to
use ":ls" to find out the buffer number and use
the first method above.

HTH,

-- 
JR


Re: Deleting control line feed in string

2007-01-30 Thread Jean-Rene David
* Mueller Stefan [2007.01.30 07:56]:
> How can I delete a control line feed in a string

:s/\\n//

Should do what you want. Insert range as
appropriate.

Or

:let value = substitute(string, "n","","g")

:h substitute()

Discusses this specific case.

HTH,

-- 
JR


Re: disable é ma p in tex-suite

2007-01-23 Thread Jean-Rene David
* neolistic [2007.01.23 10:15]:
> * Jean-Rene David-2 wrote:
> > See here for a possible solution:
> > 
> > http://vim-latex.sourceforge.net/index.php?subject=faq&title=FAQ#faq-e-acute
>
> I think this solution can work but I don't have
> the perms for the plugin direcory, is there a
> solution to unmap or surmap the é?

[Please don't top-post]

The solution given uses only files in your home
directory. It should work even if the plugin is
globally installed. Do you mean you don't have the
required permissions in your own home directory?

-- 
JR


Re: disable é ma p in tex-suite

2007-01-23 Thread Jean-Rene David
* neolistic [2007.01.23 09:15]:
> I use the tex-suite with VIM7.0 and it's very useful but tex-suite have a
> auto-defined insert-map for the key é and I don't want to use this map, I
> want that when I'm in insert mode and I press the key é, vim insert the
> character é

This is probably the most frequently asked
question on the latex-suite mailing list.

See here for a possible solution:

http://vim-latex.sourceforge.net/index.php?subject=faq&title=FAQ#faq-e-acute

-- 
JR


Re: Reformat in visual area - vmap question

2007-01-12 Thread Jean-Rene David
* DervishD [2007.01.12 07:45]:
>  * A.J.Mechelynck <[EMAIL PROTECTED]> dixit:
> > [...]
> > Beware of ' and ` though: they are used in 
> > Normal mode for "mark" movements.
> 
> Yes, but both keys do the same, so I'm on
> the safe side if I choose only one of them,
> am I wrong?

They are similar but not quite the same.

:h mark-motions

-- 
JR


Re: Folding away based on a seach

2007-01-11 Thread Jean-Rene David
* Samuel Wright [2007.01.11 06:15]:
> I have a todo list of single line entries.
> I'd like to fold everything away apart from a custom seach, say
> 
> :customsearch urgent
> 
> would fold away all lines that did not contain urgent.
> 
> Has this been done already in some way?

Yes.

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

-- 
JR


Re: Find and replace in visual area.

2007-01-08 Thread Jean-Rene David
* Silva, Paulo [2007.01.08 11:30]:
> I'm trying to do a replace in a selection.
> After selecting the area, with v, directional keys, v again (or not -
> both give the same result).
> 
> Then I type
> :%s/\%V20/21/

Don't know why it doesn't work on your end. Works
here. In any case, to do what you want, you can
just select an area and, while still in visual
mode, type:

:s/20/21

This will appear as:

:'<,'>s/20/21

in your status line. The '< and '> indicate the
beginning and end of the current visual area.

HTH,

-- 
JR


Re: Making do something different

2006-12-19 Thread Jean-Rene David
* Chuck Mason [2006.12.13 17:15]:
> In :help it follows links
> (Maybe there's a helptags file?).

Bingo.

:h helptags 

> [...]
> For instance I have a line that looks like:
> 
> ... sometext somenumber1 someothertext2
> 
> And if the user presses  anywhere on the line I would like to take
> somenumber1 and do something with it (follow it by replacing the current
> buffer with another file referenced by the number). If the line doesn't
> start with ... Then ignore the keypress.  I think I can handle all that
> but I want to know if its possible to:

One way:

Define a function which will determine if your line
matches and act accordingly:

function! Foo()
   if getline(".") =~ "^\\.\\.\\."
  " extract somenumber1 and
  " do something with it
   else
  " do nothing
   endif
endfunction

And use autocommands to determine whether your
function should be called or not depending on
which buffer you're in:

autocmd BufEnter *.tmp map  :call Foo()
autocmd BufLeave *.tmp unmap 

All that is left is extracting "somenumber1".

-- 
JR


Re: aligning text to a certain column

2006-12-05 Thread Jean-Rene David
* Lev Lvovsky [2006.12.05 13:53]:
> how can I align text under and after the cursor
> position to a  specific column number?  

:.,$s/^\s*/   /g

will align the first non-blank on the fourth
column, from the cursor's line to the end of the
file.

> and probably just as important, how can I  
> find out which column number a cursor is at ;)?

In normal mode:
:h g_Ctrl-G

In scripts:
:h getpos()

or add %c to your status line to have it all the
time.

:h statusline7}

-- 
JR


Re: Using to jump thru help tags

2006-11-27 Thread Jean-Rene David
* DervishD [2006.11.27 12:45]:
> Well, I've done this mapping to be able to jump to the next "tag"
> in the help file using :
> 
> :nnoremap/\|\S\+\|:nohll
>
> The problem is that when I hit , the "tags" flash a bit,
> because the search command highlight them and the ":nohl" turns hl
> off. Moreover, this interferes with my searchs, if any.

Using search() doesn't modify the search register
so you won't have either of those problems.

> Do anybody has any suggestion? 

Yes:

nnoremap   :call search('\|\k\+\|')

> Thanks a lot in advance :)

No problem.

-- 
JR


Re: search and replace function in vimrc

2006-11-27 Thread Jean-Rene David
* Samuel Wright [2006.11.27 11:15]:
> The regular expression works if I call it
> directly, but when I write
> 
> :function FixJHIndex
> 
> it just echoes the function definition. What am
> I missing?

:function does exactly as documented.

You want:
:call FixJHIndex()

See

:h :call
:h :function

-- 
JR


Re: compile code from within vim

2006-11-26 Thread Jean-Rene David
* atstake atstake [2006.11.26 20:45]:
[...]
> eg. if it's a .pl file it would do "perl
> filename", show the result and if there's any
> error it would take me to the line where the
> error is.
> 
> Is there any easy way to do this with functions?
> Any example would be greatly appreciated.

To change the compiler based on file extension,
you can use autocommands:

:au BufNewFile,BufReadPre *.pl set makeprg=perl\ -c\ %
:au BufNewFile,BufReadPre *.c  set makeprg=make
:au BufNewFile,BufReadPre *.py set makeprg=pychecker\ %
etc.

To jump to the errors found, you can use the
quickfix window. Depending on the compiler you
use, you may need to tweak the 'errorformat'
option. This tells vim how to parse the error
file.

:h :make
:h 'makeprg'
:h 'errorformat'
:h quickfix

-- 
JR


Re: Searching/replacing literally

2006-11-23 Thread Jean-Rene David
* Meino Christian Cramer [2006.11.23 02:45]:
>  I want to search a longer string totally
>  literally...regexp totally switched of, no
>  exceptions.

function! LiteralSearch(string) range
   let l:pattern = escape(a:string, '\\/.*$^~[]')
   let @/ = l:pattern
   normal n
endfunction

:command -nargs=1 LS call LiteralSearch ()

Then:

:LS .*$

Will match one time in this message, in the
function code above instead of matching every
line.

Map as desired.

HTH,

-- 
JR


Re: search and replace multiple lines

2006-11-15 Thread Jean-Rene David
* mark [2006.11.15 16:00]:
> I want to change the order off these three
> 
> 1=red
> 2=blue
> 3=orange
> 
> into
> 
> 3=orange
> 2=blue
> 1=red
> 
> Suggestions ?

You don't specify the overall structure of the
file, but if these 3 lines are separated by blank
lines (say), and unless you need the interactivity
of vim, I would use another tool.

% awk 'BEGIN { RS=""; FS="\n"; OFS="\n" } \
 { print $3,$2,$1 "\n"; }' << EOF
1=red
2=blue
3=orange

1=red
2=blue
3=orange
EOF
3=orange
2=blue
1=red

3=orange
2=blue
1=red

The separator can be something other than a blank
line too. As long as there is a recognizable
structure, why not take advantage of it?

-- 
JR


Search unfolded lines only

2006-11-13 Thread Jean-Rene David
Is there any way to search for text in open folds
only? For example, if fold 1 and fold 2 below are
closed and fold 3 is open, and placing the cursor
on the line which says "Start search here", I
would like to end up on the "foo" in fold 3 when
typing "/foo".

Start search here

{{{
   fold1
   foo
   fold1
}}}
{{{
   fold2
   foo
   fold2
}}}
{{{
   fold3
   foo
   fold3
}}}

-- 
JR
 vim: fdm=marker


Re: highlight after :s///g

2006-11-09 Thread Jean-Rene David
* Tim Chase [2006.11.09 17:30]:
>   :map  :let @/='~'

Using :match also works, and doesn't modify @/.

:match Search '~'

Note that this gives a warning if no previous
replacement string exists.

-- 
JR


Re: Getting out of netrw

2006-11-04 Thread Jean-Rene David
* Gary Johnson [2006.11.04 18:30]:
> When you open file A, then open file B, then
> want to go back to A, you don't do so by
> quitting B--you explicitly open A.

Looking at it that way, it makes good sense.

Thanks again for all the suggestions.

-- 
JR


Re: Getting out of netrw

2006-11-04 Thread Jean-Rene David
* Yegappan Lakshmanan [2006.11.04 13:00]:
> You can try using CTRL-^ to jump to the alternate buffer.

Good idea.

Most suggestions were useful, BTW, thanks all.

> This looks like a bug in netrw.

Well personally I find not having a "quit" or
"exit" function pretty close to a bug. But there
are so many ways around it I don't find it a very
serious one...

-- 
JR


Getting out of netrw

2006-11-03 Thread Jean-Rene David
Say I open vim7's new super duper file explorer
"netrw" to browse some local directory. Say then I
decide I don't want to open any new file and just
want to go back to what I was doing. What would be
the standard way to do that?

I can use  to eventually land up where I was
but I need to backtrack all the motion commands I
did in the netrw buffer.

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

Am I missing something obvious?

-- 
JR


Re: projects manager/explorer

2006-11-02 Thread Jean-Rene David
* victor NOAGBODJI [2006.11.02 11:45]:
> Just looking for something like that in gvim.
> Do you know something like that?

Searching for "project" on www.vim.org yields many
hits. 

I use the "project" plugin. I like it, despite
some warts.

-- 
JR


Re: what are blue "signs" appearing in vimdiff panes ?

2006-10-23 Thread Jean-Rene David
* Yakov Lerner [2006.10.23 07:00]:
> If you look at lines 879-884 of the left pane,
> and lines 1583-1588 of the right pane  you can
> see blue "signs" near line numbers. What do they
> signify ?

They mean those lines are an open diff fold. 

> I just did "vimdiff" and no special options.
> What do they mean, those spooky "signs", in the
> middle of no-difference region ?

Precisely that there are no differences in that
region, which is why it can be safely folded away
by the "fold" commands.

I notice you have the default 'context:6' in your
'diffopt', since there are 6 lines between the
delimited fold and the adjacent differences.

-- 
JR


Re: Question about listchars

2006-10-19 Thread Jean-Rene David
* Jeff Lanzarotta [2006.10.19 13:13]:
> If there a way to check and see if the listchar
> is actually set or not?

For options I change often, I use the following to
display its value in the statusline. 

function! OptSet(opt, string)
   if(exists("a:opt") && expand(a:opt))
  return a:string
   else
  return ""
   endif
endfunction

Then put the following in the statusline:

set statusline=%<%f\%h%m%r%y%{OptSet(&ic,'[ic]')}[...]
 

So in this specific case, if 'ic' is set, I will
have '[ic]' in my status line.

I use that for 'ic' and 'ws' because I toggle them
quite ofen.

HTH,

-- 
JR


Re: Can the mailing list owner set "Reply-to" field be [EMAIL PROTECTED]

2006-10-18 Thread Jean-Rene David
* A.J.Mechelynck [2006.10.18 23:30]:
> "Reply to Sender" is meant to reply only to the author of an email.
> 
> "Reply to All" is meant to reply to the author and all other recipients.

"Reply to All" usually results in the author
receiving duplicates. However since most mailers
offer nothing but those two choices, it's probably
the lesser of evils. Most mail clients suck.

Decent mailers have "Reply to list" which avoids
sending replies to both the mailing list and the
author. Some mail clients suck less. 

;-)

-- 
JR


Re: search visual block

2006-10-18 Thread Jean-Rene David
* David Fishburn [2006.10.18 22:00]:
> " Courtesy of Michael Naumann, Jürgen Krämer
> " Visually select text, then search for it
> if version >= 602
> " Here are two enhanced versions of these mappings which use VIM 6.2's
> " getregtype() function to determine whether the unnamed register
> contains
> " a characterwise, linewise or blockwise selection. After the search has
> 
> " been executed, the register *and* its type can then be restored with
> " setreg().
> vnoremap  * :
>   \let old_reg=getreg('"')
>   \let old_regmode=getregtype('"')
>   \gvy/=substitute(substitute(
>   \escape(@", '\\/.*$^~[]' ), "\n$", "", ""),
>   \"\n", '\\_[[:return:]]', "g")
>   \:call setreg('"', old_reg, old_regmode)
> vnoremap  # :
>   \let old_reg=getreg('"')
>   \let old_regmode=getregtype('"')
>   \gvy?=substitute(substitute(
>   \escape(@", '\\/.*$^~[]' ), "\n$", "", ""),
>   \"\n", '\\_[[:return:]]', "g")
>   \:call setreg('"', old_reg, old_regmode)
> else
> " If you use both VIM 6.2 and older versions these mappings
> " should be defined depending on the current version.
> vnoremap  * :let old_reg=@"
>   \gvy/=substitute(substitute(
>   \escape(@", '\\/.*$^~[]' ), "\n$", "", ""),
>   \"\n", '\\_[[:return:]]', "g")
>   \:let @"=old_reg
> vnoremap  # :let old_reg=@"
>   \gvy?=substitute(substitute(
>   \escape(@", '\\/.*$^~[]' ), "\n$", "", ""),
>   \"\n", '\\_[[:return:]]', "g")
>   \:let @"=old_reg
> endif

This is where I got my inspiration. Note the exact
same credits. But I found the mappings so
illegible that I rewrote them as functions. 

I don't find using a function to be much of a
"con" compare to the "pro" of legibility. The
function I posted today has already been hacked
and made better. It would take much more time and
thought to modify these monsters...

Reading the comments at the top, I thought for a
minute that the mapping could search for a
blockwise visual region. That would be pretty
neat.

-- 
JR


Re: automatically going from header file to implementation file

2006-10-18 Thread Jean-Rene David
* Naim Far [2006.10.18 13:00]:
>  Does any body know a way of automatically going
>  from header file to its implementation file?!
>  and vice versa?!

a.vim : Alternate Files quickly (.c --> .h etc)
http://vim.sourceforge.net/scripts/script.php?script_id=31

-- 
JR


Re: search visual block

2006-10-18 Thread Jean-Rene David
* Robert Cussons [2006.10.18 09:29]:
> Everything seems to work fine now, except the
> searched for items aren't highlighted like they
> normally are when I search

Whether or not search items are highlighted
depends on the value of the 'hlsearch' option.

The search item gets highlighted on my end when the
option is set. Is yours set?

:set hls?

-- 
JR


Re: search visual block

2006-10-18 Thread Jean-Rene David
* Benji Fisher [2006.10.18 09:15]:
>  I try to avoid such problems by not including raw CR, ESC, etc.
> characters in my vim scripts.  I suggest replacing the two :execute
> lines with
>  execute "normal ?" . l:pattern . "\"
> and
>  execute "normal /" . l:pattern . "\"

I was looking for a way to avoid the literals.
Thanks for that. That's definitely better.

-- 
JR


Re: search visual block

2006-10-18 Thread Jean-Rene David
* Robert Cussons [2006.10.18 06:30]:
> I did notice that between the if and else there
> are " which just act as comments as they are on
> newlines,

Sorry, I should have known that wouldn't come out
right. There's a literal newline between the
quotes. You can enter it by pressing
.

Here's that section of code with the literal
newline entered as two separate characters:

if a:direction == 'b'
   execute "normal ?" . l:pattern . "^M"
else
   execute "normal /" . l:pattern . "^M"
endif

> I was selecting text in visual mode, then
> pressing / or ? and I just get the normal action
> of pressing / or ?

Well you could do it with "/" and "?" but I like
to keep their behavior intact as it is useful to
extend the visual region.

I remapped "*" and "#" instead, as shown in these
lines:

vnoremap  * :call VisualSearch('f')
vnoremap  # :call VisualSearch('b')

I prefer that because these don't have any special
meaning in visual mode and it ties in nicely with
the "search next/previous word" function they have
in normal mode.

-- 
JR


Re: search visual block

2006-10-17 Thread Jean-Rene David
* Lev Lvovsky [2006.10.17 17:15]:
> Is it possible to search for a string by
> selecting that string in  visual mode?  Meaning,
> if I highlight something, and then want to
> search for that thing which is highlighted in
> the rest of the doc?

You already got lots of good answers. Here's
another one.

I've had this in my vimrc for years, and use it
when the string I'm searching for is not a
keyword. It works both forward and backward, puts
the searched pattern in the search history and
doesn't screw up any register.

"--< cut here >---
" Search for visually selected text {{{
" From an idea by Michael Naumann, Jürgen Krämer.
function! VisualSearch(direction) range
   let l:saved_reg = @"
   execute "normal! vgvy"
   let l:pattern = escape(@", '\\/.*$^~[]')
   let l:pattern = substitute(l:pattern, "\n$", "", "")
   if a:direction == 'b'
  execute "normal ?" . l:pattern . "
"
   else
  execute "normal /" . l:pattern . "
"
   endif
   let @/ = l:pattern
   let @" = l:saved_reg
endfunction

vnoremap  * :call VisualSearch('f')
vnoremap  # :call VisualSearch('b')
"--< cut here >---

HTH,

-- 
JR 
[who has a vague remembrance that this subject has
come up before]


Re: How to directly enter visual mode from insert mode ?

2006-10-03 Thread Jean-Rene David
* Ivan Vecerina [2006.10.03 12:15]:
> [...]
> Best case, I can type:   lv
> [...]
> Is there an easy way to do so ?

According to 

:h i_esc

there is not builtin way to do this. But you could
use a mapping:

imap  lv

-- 
JR


Re: Specifying vim options in the files being edited

2006-09-08 Thread Jean-Rene David
* 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.

Excerpt from :help modeline:

   No other commands than "set" are supported, for
   security reasons (somebody might create a
   Trojan horse text file with modelines).

-- 
JR


Sharing vimproject file between WinXP and cygwin

2006-07-19 Thread Jean-Rene David
I've been using the Project plugin for many years
now and I like it a lot. However one problem keeps
bugging me.

I would like to share my ~/.vimprojects file
between my cygwin and windows version of vim.

The problem is the paths for the project. When I
enter a posix path, the windows version doesn't
recognize it and vice-versa. I could run the file
through a small script which converts the paths
with cygpath but keeping them synchronized would
be cumbersome.

Any ideas?

-- 
JR