Re: gVim closing randomly.

2015-08-27 Thread Paul Isambert
Le jeudi 27 août 2015 à 13:44, John Little a écrit:
> On Thursday, August 27, 2015 at 9:14:20 PM UTC+12, Paul Isambert wrote:
> > Vim (GUI) ... simply closes abruptly...
> 
> How are you starting gvim?  If you start it in a terminal window,
> there might be messages from vim saying what's happening.  If I
> start gvim in a terminal, then pkill it, a message appears in the
> terminal where I started it.

I hadn’t thought of that. I usually don’t start gvim from the
terminal, but I might try that route until it closes and see if
anything is printed.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: gVim closing randomly.

2015-08-27 Thread Paul Isambert
Le jeudi 27 août 2015 à 04:26, Ben Fritz a écrit:
> On Wednesday, August 26, 2015 at 2:27:37 AM UTC-5, Paul Isambert wrote:
> > Hello there,
> > 
> > Vim (GUI) has behaved strangely for the past few weeks (or perhaps
> > months): it simply closes abruptly, without reason, a few times per
> > week. Swap files are deleted, so it seems Vim is closing “normally”.
> > 
> > Has anybody encountered the same problem, and if so, any solution?
> > 
> > (I’m running Arch.)
> > 
> 
> Maybe you're accidentally pressing ZZ or ZQ?

That’s a possibility of course, but I can’t see why I would have made
those accidental key presses in the last weeks only. Also, console Vim
doesn’t close randomly. And finally, I remember (but I’m not 100%
sure) that the closing often occurs when I’m not doing anything.

Thanks anyway,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


gVim closing randomly.

2015-08-26 Thread Paul Isambert
Hello there,

Vim (GUI) has behaved strangely for the past few weeks (or perhaps
months): it simply closes abruptly, without reason, a few times per
week. Swap files are deleted, so it seems Vim is closing “normally”.

Has anybody encountered the same problem, and if so, any solution?

(I’m running Arch.)

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: aligning comments; struggle with determination whether quote is part of command or not

2015-08-18 Thread Paul Isambert
> i want to align all those vim comments, which are not the first
> non-whitespace character on the line and also not part of an command, etc.
> 
> Example:
> 
>" aligns all quotes which are not the first character at the beginning of
> the line
>nnoremap a1 :Tabularize /^\@
>nnoremap a2 :Tabularize /\(^\s*\)\@
> 
> 
> => should not match, because the comment is alone on the first line and the
> second and third quote are part of the command
> 
> 
>   Plug 'flazz/vim-colorschemes'   "  Vim colorschemes
> 
> => should match, the comment has non-whitespace characters before it.
> 
> 
> trying
> 
> :Tabularize /\(^\s*\)\@ 
> Orginal: http://ur1.ca/nh1ac
> result: http://ur1.ca/nh1as
> 
> 
> Orginal: (first example)
> result: http://ur1.ca/nh1c2
> 
> 
> in short:
> ==
> how can i "parse" vim scripts in a regex, to determine, if the actual
> matched quote is part of a command or a comment?

Try this pattern (replace “othercommandshere” by, well, other
commands):

  \(\(\(nnoremap\|nmap\|othercommandshere\).*\)\|^\s*\)\@http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Search in selection - difference in behaviour between ':s' and '/' (or ':/')

2015-08-18 Thread Paul Isambert
Le mardi 18 août 2015 à 03:05, trismarck a écrit:
> This is based on: 
> http://vim.wikia.com/wiki/Search_and_replace_in_a_visual_selection
> and was supposed not to be about \%V, which just works.
> 
> Lets suppose that one does the following:
> - V, select a few lines
> - ':', followed by either 's' or '/': ':s' or ':/'
> - type a search pattern [and a replacement text for 's']
> If that's the case, then typing ':s//' will replace 
> text _within selection_ and typing ':/' will search the text within 
> _the entire file_. I don't understand why those two behave differently.
> 1. Could you describe why there is a difference in behaviour between the 
> above.

:s[ubstitute] is a command that can operate on a range, here the
selection. :/ isn’t a command at all, it is a line specifier:
it means the range is bounded by the next occurrence of .
There should be a command after that: :/pattern/dosomething.

> 5. Why doesn't ":'<,'>/" work 'as expected' - search for  
> within selection (selection specified by the special 'selection' range)?

It works as expected, but not as / (not :/) which is the proper search
command. If you want to search within a range, see “:help search-range”.

> 6. What would it mean if after selecting a few lines, one would just type '/' 
> (instead of ':/') (~so that the ranges '< and '> do not appear) - is the 
> selection ignored entirely in this case and a search on a file is just 
> performed?

The selection is ignored, but / in visual mode is used to extend the
selection, so it’s normal it searches the whole file.

In other words: if you want to search inside the selection, do the
following: go into visual mode, leave it, and search with
“/\%V\%V”. If you want to move the cursor of the visual area
with a search, use / in visual mode. As for “:/”, I guess you’ll
understand it better when you really need it: apply a command on a
range delimited by a pattern.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I cannot realise a :map why ??

2015-07-29 Thread Paul Isambert
Le mercredi 29 juillet 2015 à 07:22, aubertin.sylvain a écrit:
> Le mardi 21 juillet 2015 10:02:15 UTC+2, aubertin.sylvain a écrit :
> > For instance I should like to make F9 stand for   papa
> > Following VIM Manual (by Moolenaar) I type :
> > :map  ipapa (5 characters for  and 4 characters for  )
> > But it doesn't work. Instead of « papa «  , it returns 
> > Something is wrong, but where ??  Thanks for your reply.
> 
> AT  LAST  I USED  F9 WITH SUCCESS
> 1.  I load my shell   with « vim shellname »

That means you load a file named “shellname”.

> 2 I see my shell. At the bottom (on the left side ) I find the name of my 
> shelL Please What is the name of this mode ?On my text I can delete 
> usimg x or dd. But  F9 gives me  nothing.

That sounds like normal mode.

> 3 I go to another mode whose name I ignore again.  It is in two parts.  Above 
> I have the text of my shell and below I have a list which contains ancient 
> commands

That sounds like the command-line window. Did you type “q:”?

> 4 I find my map command and enable it with a CR. List disappears.

Yeah, that’s the command-line window.

> 5 I go back to my shell. THIS TIME WHEREVER I AM IT INSERT.S « papa » WITH 
> SUCCESS  
> I repeat I do that outside insert mode.
>  So  map works if it is freshly enabled.  I think it is impossible to have a 
> permanent   :map

It depends on what you mean by “permanent”. If you mean “from one Vim
instance to the next”, well, yes that’s impossible, but that’s also
pretty much what a .vimrc file is used to: to store command you want
executed every time you open Vim.

Now I’m sorry if I’m a bit rude, but judging from your interventions
here I must ask: did you read the ... manual?

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I cannot realise a :map why ??

2015-07-24 Thread Paul Isambert
Le vendredi 24 juillet 2015 à 10:01, aubertin.sylvain a écrit:
> Le mardi 21 juillet 2015 10:02:15 UTC+2, aubertin.sylvain a écrit :
> > For instance I should like to make F9 stand for   papa
> > Following VIM Manual (by Moolenaar) I type :
> > :map  ipapa (5 characters for  and 4 characters for  )
> > But it doesn't work. Instead of « papa «  , it returns 
> > Something is wrong, but where ??  Thanks for your reply.
> 
> Following Zyx I looked at :h :map-special-keys, in which I found the 
> following example:  :map OP :echo "yes"
> Ityped it and vim replied: impossible to modify, 'modifiable' is desactivated.
> So there is somewhere the possibility to activate 'modifiable'. Do you know 
> where?MANY THANKS 

That’s because you must have tested the mapping in a buffer containing
the help file, which is non-modifiable by default (and you probably
don’t want to modify it). Try it with an ordinary buffer.

Anyway the answer to your original request was probably John’s reply:
you’re looking for an insert mode mapping and you have defined a
normal mode one instead.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: what does & mean in the vim command?

2015-07-08 Thread Paul Isambert
Le mercredi 08 juillet 2015 à 08:00, elearn2...@gmail.com a écrit:
> Here is a viim command
> 
> nnoremap  f :!firefox 'http://127.0.0.1/%:t' &  
> 
> What does & in the end of the command mean?

“” is simply return; without it, the mapping would enter the
commandline but not execute it. As for “&”, it is used to run jobs in
the background in Linux, so Vim doesn’t hang.

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: syntax region end when either pattern occurs?

2015-06-30 Thread Paul Isambert


Le mardi 30 juin 2015 à 15:43, Nikolay Pavlov a écrit:
> 2015-06-30 9:09 GMT+03:00 Paul Isambert :
> >
> > You can move “{3}” outside the group:
> >
> > end=/\v^%(\.|\-){3}$/
> >
> > and since chances are pretty low that you’ll have lines mixing “-” and
> > “.”, you can use the more relaxed:
> >
> > end=/\v^[.-]{3}$/
> 
> These are not different. I did not move `{3}` out of the group because
> it will *in both cases you presented* match something like `.-.`.

Oups, yeah, my bad.
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: syntax region end when either pattern occurs?

2015-06-29 Thread Paul Isambert
Le lundi 29 juin 2015 à 19:05, Nikolay Pavlov a écrit:
> 
> 
> 2015-06-29 18:52 GMT+03:00 Rick Dooling :
> > I am trying to syntax highlight yaml blocks in Markdown files.
> >
> > Right now, I can get it so it handles either blocks that look like this:
> >
> > ---
> > author: me
> > document: Help
> > ---
> >
> > or
> >
> > ---
> > author: me
> > document: Help
> > ...
> >
> > But not both. Is there a way to do both?
> >
> > I tried end=\(/^---$/\|/^\.\.\.$\)  but that didn't work
> 
> end=\(/^---$/\|/^\.\.\.$\)
> 
> Syntax for such items is end={separator}{regex}{separator}[offsets].
> In your example separator is `\` which really results in something
> weird because `\` is *always* an escape character. This has no chances
> to work, you need to use `end=/\v^%(\.{3}|\-{3})$/`.

You can move “{3}” outside the group:

end=/\v^%(\.|\-){3}$/

and since chances are pretty low that you’ll have lines mixing “-” and
“.”, you can use the more relaxed:

end=/\v^[.-]{3}$/

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Execute a command from cursor position to the end of the line

2015-06-19 Thread Paul Isambert
> >>   nnoremap  :Execute
> >
> >Could you provide the content of your Execute() function?  It would
> >help to replicate the behavior you want on an extract of the line.
> 
> 
> The ones I currently have are:
> 
> #   :Voom
> #   :se foldmethod=marker
> #   :.,$VoomSort

I think Tim wanted the definition of the Execute command.

Anyway, you can get the content of a line from the cursor to its end
with:

getline(".")[col(".")-1:]

You can pass that to whatever does you execution in you original
command.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Inconsistent mapping of .

2015-06-17 Thread Paul Isambert
Le mercredi 17 juin 2015 à 16:55, Christian Brabandt a écrit:
> Am 2015-06-17 10:23, schrieb Paul Isambert:
> >Le mercredi 17 juin 2015 à 10:02, Christian Brabandt a écrit:
> >>Am 2015-06-17 08:36, schrieb Paul Isambert:
> >>>Hello there,
> >>>
> >>>If I do this:
> >>>
> >>>cnoremap  Z
> >>>
> >>>then  properly prints Z in the commandline. On the other hand,
> >>>this:
> >>>
> >>>noremap!  Z
> >>>
> >>>remaps  in insert mode but not in the commandline, as it
> >>>should. An easy workaround is to replace “noremap!” with “inoremap”
> >>>and “cnoremap”, but this looks like a bug, doesn’t it?
> >>
> >>What version is this?
> >
> >7.4 with patches 1-729, running on Arch.
> 
> I can't reproduce this. Can you reproduce with vim -u NONE -N?

Ouch, no I can’t. Sorry I didn’t try that before. I’ll investigate and
report here if needed.

Thanks,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Inconsistent mapping of .

2015-06-17 Thread Paul Isambert
Le mercredi 17 juin 2015 à 10:02, Christian Brabandt a écrit:
> Am 2015-06-17 08:36, schrieb Paul Isambert:
> >Hello there,
> >
> >If I do this:
> >
> >cnoremap  Z
> >
> >then  properly prints Z in the commandline. On the other hand,
> >this:
> >
> >noremap!  Z
> >
> >remaps  in insert mode but not in the commandline, as it
> >should. An easy workaround is to replace “noremap!” with “inoremap”
> >and “cnoremap”, but this looks like a bug, doesn’t it?
> 
> What version is this?

7.4 with patches 1-729, running on Arch.

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Inconsistent mapping of .

2015-06-16 Thread Paul Isambert
Hello there,

If I do this:

cnoremap  Z

then  properly prints Z in the commandline. On the other hand,
this:

noremap!  Z

remaps  in insert mode but not in the commandline, as it
should. An easy workaround is to replace “noremap!” with “inoremap”
and “cnoremap”, but this looks like a bug, doesn’t it?

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Moving to "next" tag in HTML

2015-06-10 Thread Paul Isambert
Le mercredi 10 juin 2015 à 19:38, Ben Fritz a écrit:
> On Wednesday, June 10, 2015 at 11:11:37 AM UTC-5, Chris Lott wrote:
> > Let's say I'm editing text, I'm in insert mode, and my cursor is at
> > the position marked by the | character:
> > 
> > Question 2|
> > 
> > And I want to move the cursor after the closing tag (or before the next 
> > tag):
> > 
> > Question 2|
> > 
> > Is there a simpler way to do this than either: ESCwwwa or ESCf > 
> 
> Slight improvement:
> 
> f<;i
> 
> or:
> 
> f>a
> 
> or:
> 
> l%a
> 
> Alternate approach, good for big (especially multiline) jumps:
> 
> vati

 instead of  can also save you one keystroke:

f<

Also, if you’re doing that often, a mapping seems like a good idea.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sourcing .vimrc for use in bash shell?

2015-06-04 Thread Paul Isambert
> Is it possible to source .vimrc so that the mappings and settings
> within are available for command line editing in the shell?

Command line editing as in ZSH’s ZLE? You can always write some script
that reads the .vimrc and adapts it to whatever line editor you’re
using, but I guess that’s non-trivial.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question about mapping...

2015-05-25 Thread Paul Isambert
>Does anyone know how I can prevent the cursor from moving when I go from
>INSERT to normal mode...

That’s Vim’s usual behavior.

> or revise my mapping so that it works regardless
>of where the cursor is within the word when ctrl-d is pressed?

You can use  instead of going in full normal mode:

inoremap  gUiw

The problem is that you will end up at the beginning of the word, no
matter where you started. Perhaps that’s not a problem?

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to determine whether an option is boolean?

2015-05-05 Thread Paul Isambert
> Some vim options are boolean, i.e. integers with the possible values 0 and 1. 
> You can, e.g., set `ai` and `noai` or use `let &ai = 1`. Other options are 
> numeric/integer or string values.
> 
> type(&option) can only be used to distinguish string from bool/int options. 
> exist('&noai') returns 0, so it cannot be used to distinguish bool from int 
> options. Is there another way to determine whether an option is a bool (an 
> int that takes only the values 0 or 1) or an int?

Off my head:

function! IsBoolean (option)
  if !exists("&" . a:option)
return 0
  endif
  let bool = 1
  exe "let old = &" . a:option
  try
exe "set no" . a:option 
  catch
let bool = 0
  endtry
  exe "let &" . a:option . " = " . old
  return bool
endfunction

I’m not sure setting and resetting the option is 100% harmless for all
options, though.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Add milliseconds to strftime()

2015-04-23 Thread Paul Isambert
Le vendredi 24 avril 2015 à 08:02, av a écrit:
> I'd like to know if it is possible to get the milliseconds() in this 
> expression for example:
> 
> echo strftime("%Y-%m-%d_%H:%M:%S")

Given that “strftime()” is based on the C function, and since there is
no mention of milliseconds in “man strftime”, I guess the answer is no.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: quickly viewing a directory of files

2015-04-04 Thread Paul Isambert
Le samedi 04 avril 2015 à 21:21, Chris Lott a écrit:
>I have a directory of files with names like 'clips-20150101'
>'clips-20150102' etc. I need to open a file, jump to a particular string,
>optionally yank some arbitrary text, and repeat for every file in the
>directory. What's the quickest way to do this in Vim?

What about simply passing the filenames as arguments to Vim, something
like “vim clips-*” (assuming you’re on *nix), then use “n” to repeat
the search (after you’ve defined it once) and jump where you want,
yank your text, then “:next” to the next file?

If the text you want to yank is predictible (I’d guess from the
search), you can automate the whole process with “gn” (visual mode on
the last search) and “y”.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to indicate multiple window lines that belong to a long line in a file

2015-04-04 Thread Paul Isambert


> It will show ▲ at the beginning of a line that is continued from the line
> above. When choosing the character for showbreak, I tried to choose a symbol
> from the digraph table so that it is not mixed up with the normal
> characters.

You can also use the NonText highlight group to differentiate
characters. I use a simple “>” as a ‘showbreak’ symbol, but it is
slight less visible than normal characters (grey instead of black).

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to indicate multiple window lines that belong to a long line in a file

2015-03-31 Thread Paul Isambert
Le mercredi 01 avril 2015 à 04:21, 'Paul' via vim_use a écrit:
> Currently I use "set number" for this purpose. But it takes a lot of window
> space. So I wonder whether there is a better way to do it, such as the way
> used in Emacs window (showing a little line wrap symbol at the end of a
> window line if it continues to the next window line), or maybe show
> alternative background colors for different long lines? Any ideas?
 
I’m not sure I understand your request correctly, but perhaps the
showbreak option is what you’re looking for?

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: js reference in vim

2015-03-28 Thread Paul Isambert
Le vendredi 27 mars 2015 à 10:13, Егор a écrit:
> Perlusers has perldoc and some vim plugins, like perlsupport, allows to view
> reference about perl keyword in new split. Is there a way to do something
> like this for javascript?

This might not help you much, but anyway. I have this for R (here in
simplified form):

" This is in ftplugin/r.vim.
function! s:RHelp (f)

  " Split screen.
  silent split R\ Help

  " Call to the 'R' command to display help; a bit of string
  " manipulation is actually performed on the result, to remove
  " formatting of the R help.
  exe "0read !R --slave -e '?" . a:f . "'"

  " Not necessary, but I have additional things in
  " ftplugin/rhelp.vim.
  set ft=rhelp

  " Set the cursor at the beginning of the file.
  call cursor(1, 1)
endfunction

" I now use ':Rhelp keyword'.
com! -buffer -nargs=1 Rhelp call s:RHelp()

This shouldn’t be too hard to adapt to JS if you can find a reference
in appropriate form. On that point, I don’t know if there exists a JS
doc readable in a terminal.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deleting lines steered by another file

2015-03-08 Thread Paul Isambert
Sorry, this line

  exe "silent g/[^[:alnum:]]" . matchstr(l, '\d\+') . "[^[:alnum:]]/delete"

should have been:

  exe "silent g/[^[:digit:]]" . matchstr(l, '\d\+') . "_/delete"

(I did not read your message properly.)

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deleting lines steered by another file

2015-03-08 Thread Paul Isambert
Le dimanche 08 mars 2015 à 06:05, meino.cra...@gmx.de a écrit:
> Hi,
> 
> hopefully this can be done with vim in some way:
> (using Linux)
> 
> I have an file (html) which contains lines containing lines
> like this one
> (some stuff)1741_word_anotherword(some stuff)
> 
> (pattern: .*_.*)
> 
> I another file I have only a list of numbers, which may or may not
> listed in the first file. A certain sorting may or may not be present.
> 
> I want to delete all lines from the first file, which are listed in
> the second file.
> 
> Is that possible with vim?

This little code should do what you want:

for l in readfile("/path/to/your_second_file")
  exe "silent g/[^[:alnum:]]" . matchstr(l, '\d\+') . "[^[:alnum:]]/delete"
endfor

Put that in a vim script, while in the buffer containing the first
file, source it with:

:source /path/to/the/script

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Search pattern while excluding some words

2015-03-06 Thread Paul Isambert
Le vendredi 06 mars 2015 à 08:30, John Cordes a écrit:
>  First a small bit of background. I have created a little
> bash script which runs pdftotext on a PDF file (containing
> obituaries, with surnames in upper-case), then invokes vim
> commands to massage the resulting text file, basically to
> break the file into paragraphs.
> 
>  I then open the resulting text file in
> vim and search for surnames which may have remained
> embedded within a paragraph; I use
> 
>  /[A-Z]\{4,\}
> 
>  for this (ignoring the occasional 3 letter surname).
> 
>  Here's my question: while running this search on 4 or
> more uppercase characters, I would like to be able to skip
> past (ignore) certain commonly occurring 'words' such as
> RCMP, QEII, SPCA and such. I want to jump immediately to
> the next occurring surname.

You can try something like this (add other acronyms as you will):

/\<\(RCMP\|QEII\|SPCA\)\@![A-Z]\{4,\}

It means match any uppercase word of at least four letters, so long as
RCMP, etc., doesn’t match at the same position (which is the beginning
of a word, thanks to \<).

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: syntax highlighting for class names

2015-03-02 Thread Paul Isambert


Le dimanche 01 mars 2015 à 10:07, Mark Volkmann a écrit:
> Thanks Paul! I'm probably close now, but not quite there. Do you see anything 
> wrong with this?
> 
> syntax keyword jsClassKeywords class extends contained
> syntax region javaScriptClassName start=/^class \| class /hs=e+1 end=/ 
> /he=s-1 "contains=jsClassKeywords

First, your “contains” keyword in the second line is commented out.
Second, ending the region with a space is ill-advised (even though, to
be honest, I don’t understand why the region stops at the space after
“class”, given that start and stop patterns aren’t supposed to
overlap ... anybody?). An opening brace is the right way to go.
Finally, but that’s just personal preference, if you don’t need a
region, use a simple match:

syntax match javaScriptClassName +^\s*class.\+i\ze{+ 
contains=jsClassKeywords

If you really want a region:

syntax region javaScriptClassName start=+^\s*class+ end=+{+me=e-1 
contains=jsClassKeywords

I hope that’ll be what you want.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: syntax highlighting for class names

2015-03-01 Thread Paul Isambert
Le dimanche 01 mars 2015 à 06:36, Mark Volkmann a écrit:
> I wanted to highlight Foo and Bar in the following line:
> 
> class Foo extends Bar {
> 
> I have this working now using the following:
> 
> syntax region javaScriptClassName start=/^class \| class /hs=e+1 end=/ 
> /he=s-1 oneline
> " Can't start the start pattern with a space because javaScriptClassName 
> already consumed it.
> syntax region javaScriptExtendsName start=/extends /hs=e+1 end=/ /he=s-1 
> oneline
> 
> However, I also wanted to treat "class" and "extends" as keywords and 
> highlight those.
> When I do that, my regions above stop working.
> Not sure why I can't have both.

You should use contained groups, e.g.:

syn keyword jsClassKeyword class extends contained
syn match jsClass +^\s*class.\+\ze{+ contains=jsClassKeyword

See “:help syn-contains”.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Defining Region focused on current page

2015-02-26 Thread Paul Isambert
Le jeudi 26 février 2015 à 04:57, Ni Va a écrit:
> On Thursday, February 26, 2015 at 4:31:40 PM UTC+1, Gary Johnson wrote:
> > On 2015-02-26, Ni Va wrote:
> > > Hi,
> > > 
> > > I would like to define a region based on current page displayed of
> > > opened buffer.
> > > 
> > > How can I define that ?
> > 
> > I don't know what you mean by "define a region", but you can
> > visually select all the lines on the current displayed page with
> > 
> > HVL
> > 
> > H moves the cursor to the first line of the window; V starts
> > visual mode linewise; L moves the cursor to the last line of the
> > window.
> > 
> > Regards,
> > Gary
> 
> Hi Gary,
> 
> I know visual selection but I just want to define a region to set this 
> command line :
> 
> syntax sync region ... in order to do syn only on current displayed page

See “:help \%l” and “:help line()” (especially with “w0” and “w$”) and
you should be able to do something like:

exec 'syntax region YourRegion start=+\\%' . line('w0') . 'l+ end=+\\%' . 
line('w$') . 'l+'

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with command on script

2015-01-15 Thread Paul Isambert
Le jeudi 15 janvier 2015 à 01:08, Cesar Romani a écrit:
> I'm using vim 7.4.580 on Windows 7. I have the following code to delete
> a displaced range of lines on a text:
> 
> --
> function! Foobar(num) range
>   exe (a:firstline+a:num).','.(a:lastline+a:num).'d'
> endfunc
> com! -range -nargs=1 Foobar call Foobar()
> --
> 
> When I select a range of lines and run 'call Foobar(5)' it works,
> but when I run 'Foobar 5' it doesn't work.
> 
> Where can be the error?

The range isn’t passed from the command to the function call; the
command should be defined as:

com! -range -nargs=1 Foobar ,call Foobar()

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Question about setting default syntax highlighter

2014-07-17 Thread Paul Isambert
Le jeudi 17 juillet 2014 à 11:45, Carfield Yim a écrit:
> Hi, I need to use vim to edit config files for Visual Studio project
> a lot, all the config file are XML but edit with *.conf. How can I
> config vim to use XML syntax highlighter for all *.conf file?

See “:help new-filetype”. You must do something like:

au BufNewFile,BufRead *.conf set filetype=xml

and save that in e.g. $HOME/.vim/ftdetect/filetype.vim.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Tabs for indentation, spaces for alignment - possible in vanilla vim?

2014-06-28 Thread Paul Isambert
Le samedi 28 juin 2014 à 11:33, Bruno Sutic a écrit:
> Hi,
> I would like to use tabs for indentation and spaces for alignment.
> This "idea" is also described here: 
> http://vim.wikia.com/wiki/Indent_with_tabs%2C_align_with_spaces#Smart_tabs
> 
> To put it simple:
> - tabs should be used at the beginning of the line
> - spaces should be inserted when after any character in the line
> 
> The article linked above proposes a 'smart tab' plugin to achieve this. 
> Unfortunately, this plugin breaks snipmate plugin which also uses tab.
> 
> So I wonder, is there a way (an option maybe) to achieve this without a 
> plugin?
> I tried `:h 'smarttab'`, but that does something else.

Try this:

function! s:TabOrSpace ()
  let c = col(".")
  if c == 1 || getline(".")[c-2] =~ '\t'
return "\t"
  else
return " "
  endif
endfunction
inoremap   TabOrSpace()

Then  (you can change the key, of course) will insert a tab if at
the beginning of the line or after a tab, and a space (you can make it
return more) otherwise.

I’m not 100% sure that’s what you want, but I hope it helps anyway.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: dynamically replace = to " = " when followed by [A-z0-9]

2014-06-16 Thread Paul Isambert
Le lundi 16 juin 2014 à 09:54, BaRud a écrit:
> Hi,
> I am trying to replace "=" by " = " only when the previous character is 
> [A-z0-9]
> so, "blah=" should be dynamically replaced by "blah = ", but not !=.
> 
> In a vim, I can do this by
> 
>%s/\v([A-z0-9])\=/\1 = /g
> 
> but, can it be dynamic, or atleast check the current line for every = entered 
> and replace that?

You already have received solutions, here’s a one-liner:

inoremap  = getline(".")[col(".")-2] =~ '[[:alnum:]]' ? " = " : "="

Not thoroughly tested, mind you.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sorting a List of Numbers

2014-06-10 Thread Paul Isambert


Le mardi 10 juin 2014 à 08:01, Benjamin Klein a écrit:
> I did notice that the sort() help says that it sorts based on the
> String representation of the items,

Me neither, which is why I called it a bug.

> so I guess this is at least
> *mentioned*, but I agree in considering it a bug. At the very least
> I'd expect an alternate function to be built in.

It isn’t a bug if it is designed to work as mentioned; let’s call it a
bad decision :) (Does anybody knows the reason why, if any?)

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Sorting a List of Numbers

2014-06-10 Thread Paul Isambert
Le mardi 10 juin 2014 à 07:15, Ben Klein a écrit:
>let numbers = [7, 9, 18, 12, 22]
>echo sort(numbers)
> 
>[12, 18, 22, 7, 9]
> 
>What's going on here? Is there some way by which I can sort these as
>Numbers and not Strings?


If you use “sort(numbers, 'MyCompare')” with “MyCompare()” define as
in the help for “sort()”, it works well.

On the other hand, I’d say sorting numbers as strings is definitely a
bug in this situation.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Vim as prose editor - how to remove '~' and '@'

2014-06-07 Thread Paul Isambert
Le samedi 07 juin 2014 à 10:39, James Freer a écrit:
> I am trying out gvim and vim for use as a prose editor for writing - rather
> than programmer coding.
> 
> Whilst doing pgup and pgdn one gets ~ and @ on the screen and I was
> wondering if it was possible to remove them.

For the “@”, use

set display=lastline

I don’t think you can remove the “~” for the missing lines, but you
can hide it with something like:

hi NonText guifg=bg

(and something similar for the console). Beware, this will also hide
other things, see the help on hl-NonText.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Another SRT questions

2014-04-16 Thread Paul Isambert
Le mardi 15 avril 2014 18:26:41 UTC+2, Jeri Raye a écrit :
> How do I add this to the function you send in your reply on my previous SRT 
> question?
>     :%s/[.?!]\_s\+\zs[a-z]/\=toupper(submatch(0))/g

Simply like this:

function! LowerSub ()
  %s/[.?!]\_s\+\zs\l/\u&/g
  for l in range(1, line("$"))
if getline(l) =~ '-->' && getline(prevnonblank(l-2)) =~ 
'[[:alpha:]].*[^.?!]$'
  call setline(l+1, substitute(getline(l+1), '^.', 
'\=tolower(submatch(0))', ''))
endif
  endfor
endfunction

I’ve used John’s simpler syntax, where “&” means the whole matched pattern.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Another SRT questions

2014-04-14 Thread Paul Isambert
Le lundi 14 avril 2014 10:58:19 UTC+2, Jeri Raye a écrit :
> Hi,
> 
> I have an SRT file that have dialog sentences that sometimes ends halve way 
> with a dot. 
> And then a next sensentence starts.
> This text doesn't start then with a uppercase character, but with a lower 
> case letter.
> 
> 
> For example: 
> I want to tell you this. and also this.
> 
> How to change this into:
> I want to tell you this. And also this.
> 
> 
> It's basicly search for " chars>. "
> 
> I played with getline and toupper() in an function call, but got lost.

This time it’s quite easy:

:%s/\.\_s\+\zs[a-z]/\=toupper(submatch(0))/g

Use the “g” flag iff “gdefault” is off. If you want to target other
punctuation marks:

:%s/[.?!]\_s\+\zs[a-z]/\=toupper(submatch(0))/g

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to change an SRT file

2014-04-12 Thread Paul Isambert
Jeri Raye  a écrit:
> Hi,
> 
> I have an srt file where every new subtitle starts with a capital letter.
> See here an example.
> 
> +-+
> 12
> 00:01:35,095 --> 00:01:38,598
> The people you see
> actually lived.
> 
> 13
> 00:01:38,598 --> 00:01:41,601
> All the words
> they speak
> 
> 14
> 00:01:41,601 --> 00:01:44,604
> Were spoken
> or written by them.
> 
> 15
> 00:01:46,606 --> 00:01:50,110
> +-+
> 
> I would like to change this.
> I would like that only the new subtitle that follow after an dot (.) of the
> previous subtitle starts with a captial letter.
> 
> So in the example shown, in subtitle 14, the word 'Were' should be changed
> in 'were'.
> 
> How to do that?

Define this function somewhere:

function! LowerSub ()
  for l in range(1, line("$"))
if getline(l) =~ '-->' && getline(prevnonblank(l-2)) =~ 
'[[:alpha:]].*[^.?!]$'
  call setline(l+1, substitute(getline(l+1), '^.', 
'\=tolower(submatch(0))', ''))
endif
  endfor
endfunction

and call it (“:call LowerSub()”) in your SRT file. I’ve added the
question/exclamation marks to the dot because it seemed to make sense,
but you can change that easily.

If you wait a few days (or even a few hours), some wizard should come
up with something using “:global” :)

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Do you use status line plugins like powerline or airline?

2014-03-15 Thread Paul Isambert
Charles Campbell  a écrit:
> Joseph Orbegoso Pea wrote:
> > I'm curious to gain some insight on powerline/airline usage. If you know 
> > what powerline and airline are, can you answer this poll?
> > http://www.easypolls.net/poll.html?p=531ade39e4b061af6f246519

I can see the results, but I can’t vote.

> I use StlShowFunc.vim which shows the name of the current function that 
> I'm editing in the status line (C, C++, Matlab, Maple, perl, sh, tex, 
> vim, fortran).  Its available at:
> http://www.drchip.org/astronaut/vim/index.html#STLSHOWFUNC

That’s an excellent idea! I’ll certainly use it soon (the idea, not
the plugin, since I use my own statusline).

Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How should I modify a normal mode map set by a plugin?

2014-03-11 Thread Paul Isambert
Hello Ethan,

Ethan Hereth  a écrit:
> I have a question that I think should have a better answer.
> 
> I used to have a couple normal mode maps in my .vimrc that went like this:
> 
> nnoremap n nzz
> nnoremap N Nzz
> 
> which, as I'm sure I don't need to tell most of you, causes the next search 
> result to be centered (usually) when the user presses n/N. These maps worked 
> great for a long time... Until I installed the IndexedSearch plugin, which I 
> do really like by the way. This broke my maps which annoyed me for quite some 
> time until today when I decided to track down the cause.
> 
> Typing 'verbose map n' gave me the following:
> 
> n n * :let v:errmsg='':silent! norm! n:call 
> 34_ShowCurrentSearchIndex(0,'!')
> Last set from ~/.vim/bundle/IndexedSearch/plugin/IndexedSearch.vim
> 
> So now I see that the IndexedSearch plugin has stolen my maps. So, for now I 
> have changed the appropriate lines in the IndexedSearch.vim plugin as follows 
> to get back the previous behavior without losing IndexedSearch's addition. 
> So, I'm happy now.
> 
> nnoremap n :let v:errmsg='':silent! norm! nzz:call 
> ShowCurrentSearchIndex(0,'!')
> nnoremap N :let v:errmsg='':silent! norm! Nzz:call 
> ShowCurrentSearchIndex(0,'!')
> 
> My question is: Is there a better way to do this? Instead of actually 
> modifying the plugin code I'd like to simply modify the map after 
> IndexedSearch has set it. I did skim both Google and ':help map' but nothing 
> popped out at me as answering my question.

Add a plugin in your “after” directory, e.g.:

" Beware, no 'noremap' this time!
nmap n nzz
nmap N Nzz

in “$HOME/.vim/after/plugin/IndexedSearch.vim” (replace “.vim” with
“vimfiles” if you’re on Windows). Files in “after” are loaded, well,
after anything else.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Dumb question: variables in the statusline

2014-02-27 Thread Paul Isambert
"Ben Klein" 
>
> (Maybe this will be like last time, where I just had to send the
> question to the list before I could realize how idiotically wrong I
> was...)
> 
> 
> I have a function which takes ... arguments, and when I try to call
> it from another function to set the statusline, I basically get:
> 
> 
> 
> E121: Undefined variable: a:1
> E116: Invalid arguments for function
> FunctionFromWhichIAmTryingToGetAStatusline(a:1)
> 
> 
> So the function getting the error is more or less:
> 
> 
> function! SetUpTheStatusline(...)
> setlocal statusline=%!FunctionFromWhichIAmTryingToGetAStatusline(a:1)
> endfunction
> 
> 
> And that is just getting those two errors.
> 
> 
> To be clear, I have verified that there is indeed a:1 in the
> SetUpTheStatusline() function. I can do (it seems) anything with it
> -- even use it in the call to
> FunctionFromWhichIAmTryingToGetAStatusline() -- except for using it
> in a function called in the statusline.
> 
> 
> What am I doing wrong?

“statusline” is a string, so I guess the correct form is:

exe "setlocal statusline=%!FunctionFromWhichIAmTryingToGetAStatusline('" . 
a:1 . "')"

Of course, a:1 should be of the proper type.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Adding a file name to a template

2014-02-06 Thread Paul Isambert
> I would like to know if I can put the file name into the template
> automatically. This is what I have in my .vimrc to create the
> template:
> 
> augroup filetype_html
> autocmd!
> autocmd BufNewFile * silent! 0r $HOME/.vim/templates/%:e.tpl
> augroup END


Try defining the autocmd as:

autocmd BufNewFile * silent! 0r $HOME/.vim/templates/%:e.tpl | exe "normal! 
ggA " . expand("%")

Or, to make things a bit safer, use this function:

function! LoadTemplate ()
  let [fi, sk] = [expand("%"), expand("$HOME/.vim/templates/") . 
expand("%:e") . ".tpl"]
  if filereadable(sk)
exe "silent 0r " . sk
exe "normal! ggA " . fi
  endif
endfunction

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Copy the matched substring only with :g

2014-01-15 Thread Paul Isambert
> > - I've replaced \l\u with \(\l\u\|\u\l\), otherwise words starting
> > with an uppercase letter won't be found.
> 
> Why so?  Doesn't the \a* take care of it?

No, there no way for '\a*\l\u\a*' to match on e.g. "Initial": if the first \a
matches, then there is nothing left for \u; if that \a doesn't match, then the
first letter must match \l, and that won't work either.

By the way, what I've sent you will only copy the first match of each line. If
you wanted all camelcased words to be copied, it'll need further work.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Copy the matched substring only with :g

2014-01-15 Thread Paul Isambert
"BPJ" :
> Is there any way when using :g to copy the matched substring only?
> 
> I want to find all lines with CamelCase words and copy those
> words to the bottom of the buffer.
> 
>  :g/\a*\l\U\a*/t$
> 
> copies the whole line, but I want to get the part of the line
> matching the pattern.

Quick solution:

g/\a*\(\l\u\|\u\l\)\a*/call setline(line('$')+1, matchstr(getline('.'), 
'\a*\(\l\u\|\u\l\)\a*'))

Notes:
- I've replaced \U with \u, since \U means [^A-Z].
- I've replaced \l\u with \(\l\u\|\u\l\), otherwise words starting with an
uppercase letter won't be found.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Do developers use vim exclusively or alternate with an IDE?

2014-01-13 Thread Paul Isambert
"Vadim Konovalov" :
> > From: vim_use@googlegroups.com On Behalf Of Paul Isambert
> > Knowing Vimscript is a good idea, but you can use
> > Python if that is easier to you.
>
> Why artificially narrowing area of choice??
> I am using Perl and perfectly happy with it.

Because the OP mentionned Python; before using Vimscript exclusively, I myself
scripted Vim with Lua, so I definitely did not mean Python is the only
alternative. So of course I could have said

Knowing Vimscript is a good idea, but you can use
the other scripting languages Vim supports.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Do developers use vim exclusively or alternate with an IDE?

2014-01-13 Thread Paul Isambert
"Sam Bituser" :
> I have been trying hard to use vim wherever possible, but while I
> enjoy using it when I know what I am doing, sometimes it's just
> quicker to use a mouse. Does this feeling of frustration ever go
> away? I would like to note that I alternate between HTML, CSS, C#,
> Python and Php. I am on windows.

I never feel the need to use anything but Vim. The point is observing yourself
and then script Vim (or find an existing script) to make it a more comfortable
place. Knowing Vimscript is a good idea, but you can use Python if that is
easier to you.

On the other hand, there is nothing wrong with the mouse or alternating with
other tools. What matters is being comfortable, regardless of what Vim
fundamentalists can think. But it's true Vim can be tailored so finely to your
needs that I'd recommend giving it a good try before switching – even
temporarily – to anything else.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: background variable always set to light

2014-01-07 Thread Paul Isambert
> moreover, still as far as i know, changing that variable should not
> alter the current colors, but instead it does.

It is normal that setting 'background' does change some colors; see :help
'background':

When 'background' is set Vim will adjust the default color groups for the
new value.  But the colors used for syntax highlighting will not change.

In other words: colors that are not set by the color scheme are set to
defaults, which change according to the value of 'background'.

Why the option is reset to 'light', though, I don't know.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: \@= doesn't seem to be working in very magic mode

2013-12-30 Thread Paul Isambert
Mohit Sharma  a écrit:
> Hey guys,
> 
> Are \@* (\@=, \@! etc.) supported in vim's "very magic" mode? It doesn't
> seem to be working for me e.g.
> 
> for text "foobar" when I do
> 
> >>/\vfoo(bar)\@= matches foobar
> >>/foo\(bar\)\@= matches foo correctly
> 
> it matches the entire foobar instead of just foo. Is this expected?

@ shouldn’t be escaped with \v, because only [0-9A-Za-z_] have their
usual (unescaped) meaning; the correct pattern is:

\vfoo(bar)@=

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: vim: toggle between tabs and toggle between buffers

2013-12-13 Thread Paul Isambert
De: "ping song" :
> I tried these pseudo-codes, but these are just 1 time thing and won't
> change over time...couldn't figure out a good way.
> 
> 
> ;if more than one tab, don't hack
> 
> if tabpagenr("$") > 1
> unmap gt
> unmap gT
> ;otherwise , if there is one tab, use gt,gT,Ngt to switch between
> buffers
> else
> 
> if v:count == 0
> map gt :bn
> map gT :bp
> else
> map gt :exec "b" . v:count
> endif
> endif

Do this:

function! s:nswitch (n)
  if tabpagenr("$") >= a:n
exe "tabnext" a:n
  else
exe "buffer" a:n
  endif
endfunction

noremap  gt :call nswitch(v:count)

Now Ngt goes to tab N if it exists, to buffer N otherwise.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: vim: toggle between tabs and toggle between buffers

2013-12-12 Thread Paul Isambert
"ping song" :
> currently I have a map to quickly switch between 2 tabs:
> 
> nmap ,l :exe "tabn “.g:lasttab
> au TabLeave * let g:lasttab = tabpagenr()
> 
> it works nice.
> 
> but I'm thinking to extend that to another scenario, that if I got
> only one tab left but still have multiple buffers, the same map will
> toggle between the last 2 buffers used instead of tabs.
> 
> how to archive this ?

Check whether there exists more than one tab page; if not, use ":b #" as
indicated by Marc:

function! s:switch()
  if tabpagenr("$") > 1
exe "tabnext" g:lasttab
  else
b #
  endif
endfunction
noremap  ,l :call switch()

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Selecting an IPv4-address?

2013-12-11 Thread Paul Isambert
Ben Fritz  a écrit:
> On Wednesday, December 11, 2013 10:45:12 AM UTC-6, Paul Isambert wrote:
> > 
> > > It looks like your complicated script just acts on the last search
> > 
> > > match, just like gn does built-in.
> > 
> > 
> > 
> > Actually it's a bit smarter, in that it also selects the IP address you're 
> > on
> > 
> > (with the cursor); the idea is that you probably want to select what your
> > 
> > cursor is closer to. Of course that's just a matter of how the OP really
> > 
> > works, but I thought an alternative solution sometimes helps, and a little
> > 
> > complicated script can be really time-saving.
> > 
> > 
> 
> I see, that's kind of clever. You'd need a workaround like pressing 0 first 
> for gn to work. I wonder if gn could be made smart enough to just work if the 
> cursor is currently on the match but not at the first character?

You still have the problem that / always match after the cursor
(unless, of course, you explicitly use something like “\%#” in the
regexp, but that’s quite impractical).

> > Plus you simply need "dI", "yI", etc.
> > 
> 
> You can also just use dgn, ygn, etc. One extra character, without a shift 
> key...same basic effort.

Oh, I didn’t know “gn” what that clever. I’ve discovered it myself
last week or so, and haven’t had time to really use it. 

... a few seconds later ...

Trying it right now: actually it does select the match if the cursor
is on it, the next match otherwise. So you can map something like:

/``gn

which will select the match the cursor is on, if any. And you could
also add a bit of “:nohl” to make things cleaner.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Selecting an IPv4-address?

2013-12-11 Thread Paul Isambert
> On Wednesday, December 11, 2013 6:42:05 AM UTC-6, Paul Isambert
> wrote:
> > 
> > let s:patt = '\%(\d\{1,3}\.\)\{3}\d\{1,3}'
> > 
> 
> [snip]
> 
> > 
> > onoremap  I :call findIP()
> > 
> > 
> > 
> > This lets you use "dI", "yI", etc., to delete/yank/etc. the IP
> > address that is
> > 
> > the closer to the cursor. This way you don't have to move at the
> > beginning of
> > 
> > the address you want, simply as close to it as possible. If there's
> > only one
> > 
> > address on the current line, you don't have to move the cursor at
> > all.
> > 
> 
> It looks like your complicated script just acts on the last search
> match, just like gn does built-in.

Actually it's a bit smarter, in that it also selects the IP address you're on
(with the cursor); the idea is that you probably want to select what your
cursor is closer to. Of course that's just a matter of how the OP really
works, but I thought an alternative solution sometimes helps, and a little
complicated script can be really time-saving.

Plus you simply need "dI", "yI", etc.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Syntax: group which can be contained or uncontained

2013-12-11 Thread Paul Isambert
> I'm trying to write my own syntax file for a language where there are
> a lot of groups of the form
> 
> :syn match langSomeGrp /^\s*KeyWord.*/
> 
> The problem is that there are also end-of-line comments
> :syn match langComment /--.*/
> 
> which can either stand on a line of its own OR be contained in a
> group like the above. How do I express that? Is it OK to have a
> contains=grpB in the declaration of a match grpA without a
> containedin=grpA in the declaration of match grpB?

Yes. "contains=X" and "containedin=Y" are two ways to declare the same thing:
a group is contained in another one. So

syn match Foo /whatever/ contains=Bar
syn match Bar /xyz/

and

syn match Foo /whatever/
syn match Bar /xyz/ containedin=Foo

are equivalent. You still have to add "contained" to Bar in both cases if
necessary, but since your comment can be on a line of its own it is not always
contained.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Selecting an IPv4-address?

2013-12-11 Thread Paul Isambert

> In the case I use it btw. something like vt; (handling a dhcpd.conf)
> is the fastest way so far.

Event faster:

onoremap ; t;

which lets you use "d;", "y;", etc., as "dt;", "yt;".

And since we're having quite some fun (and automating repetitive behaviors is
one of the strong points of Vim), you can try:

let s:patt = '\%(\d\{1,3}\.\)\{3}\d\{1,3}'
function! s:findIP ()
  let [l, c] = getpos(".")[1:2]
  let c -= 1
  let L = getline(l)
  let diff = 1
  let e = 0
  while 1
let [s, e] = [match(L, s:patt, e), matchend(L, s:patt, e)]
let [d1, d2] = [s-c, c-e]
if s <= -1
  break
elseif d1 <= 0 && d2 <= 0
  let best = [s, e]
  break
else
  let [d1, d2] = [abs(d1), abs(d2)]
  if d1 <= diff || d2 <= diff
let best = [s, e]
let diff = d1 < d2 ? d1 : d2
  endif
endif
  endwhile
  if exists("l:best")
call cursor(l, best[0]+1)
normal! v
call cursor(l, best[1]+1)
  endif
endfunction

onoremap  I :call findIP()

This lets you use "dI", "yI", etc., to delete/yank/etc. the IP address that is
the closer to the cursor. This way you don't have to move at the beginning of
the address you want, simply as close to it as possible. If there's only one
address on the current line, you don't have to move the cursor at all.

(Note: the script was not thoroughly tested!)

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Search and stay

2013-11-30 Thread Paul Isambert
Andrew Stewart  a écrit:
> > Based on this very real annoyance, and having a little bit of time to kill, 
> > I
> > wrote the code below: not only does it removes the 'hlsearch' problem, but 
> > it
> > also makes search easier by foregrounding matches and letting you jump from
> > one to the next without leaving the search. I find it quite comfortable, but
> > of course others might find that just terrible. Here's how it works:
> 
> 
> I really like this – thanks!
> 
> > If anybody is interested, I can make that into a plugin (rewriting it a 
> > little
> > bit less sloppily, because it will fail in some cases, plus it requires a 
> > few
> > options to be really interesting), in case, of course, such a plugin does 
> > not
> > already exist :)
> 
> 
> That would be great, if you have the time.  I'd prefer to drop in a plugin 
> that enlarge my vimrc.

Not so easy after all if you want things to work properly and with a
few interesting bells and whistles.

I’m working on it, but it’ll take more time than expected (it always
does). At least I have the plugin’s name: spotlight. That part I’m
quite satisfied with!

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trouble with getpos()/setpos().

2013-11-30 Thread Paul Isambert
Christian Brabandt  a écrit:
> Hi Paul!
> 
> On Sa, 30 Nov 2013, Paul Isambert wrote:
> 
> > > You are in *linewise* visual mode, so it doesn't really make sense, to 
> > > have the column somewhere different then either 0 or MAXCOLUMN.
> > 
> > Thanks Christian, I’m not in linewise visual mode, but just after I’ve
> > left it; I would understand if I were still in that mode, but that’s
> > not the case.
> 
> Actually, you are, since that mode is remembered for I think gv.

Indeed. But then it really looks like a bug to me, or at least an
unwanted side-effect; you can’t rely on a function that depends on the
last – unknown – mode and doesn’t work half of the time. Or does that
serve any purpose?

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trouble with getpos()/setpos().

2013-11-30 Thread Paul Isambert
Christian Brabandt  a écrit:
> Hi Paul!
> 
> On Sa, 30 Nov 2013, Paul Isambert wrote:
> 
> > Hello all,
> > 
> > I’ve encountered a behavior which really smells like a bug, but I’d
> > like to check here beforehand to be sure:
> > 
> > Go into linewise visual mode and leave it. Show the position of the '> mark 
> > with:
> > 
> > echo getpos("'>")
> > 
> > It returns something like (if you were on line 23):
> > 
> > [0, 23, 2147483647, 0]
> > 
> > where the very big value for the column means you were in linewise
> > visual mode. Now try to set the '> mark with e.g.:
> > 
> > echo setpos("'>", [0, 25, 12, 0])
> > 
> > “0” is echoed, meaning nothing went wrong. Use “getpos("'>")” again to see
> > the position of the mark, this time you’ll see:
> > 
> > [0, 25, 2147483647, 0]
> > 
> > The line was changed, but not the column. And it seems to happen
> > whenever the column number has that big value, i.e. whenever you went
> > into linewise visual mode.
> > 
> > Am I missing something?
> 
> You are seeing implementation details, leaking into the Vim API.
> 
> You are in *linewise* visual mode, so it doesn't really make sense, to 
> have the column somewhere different then either 0 or MAXCOLUMN.

Thanks Christian, I’m not in linewise visual mode, but just after I’ve
left it; I would understand if I were still in that mode, but that’s
not the case.

> Also note, that '< will always be the upper position of these two marks 
> within the buffer, while '> will always be the lower position of those 
> two marks. (e.g. you can't set '> to a lower line then '< and you can't 
> set '< to a larger line number then '>)

I’d noticed that. Actually, if you try to set '> before '<, the former
is set to the current value of the latter, which is set to the new
value. 

> Das muß ein Esel sein, der mit fünfzig Jahren noch dieselben
> Anschauungen hat wie vor zwanzig Jahren.
>   -- Otto von Bismarck

Good ol’ Otto :)

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trouble with getpos()/setpos().

2013-11-30 Thread Paul Isambert
glts <676c7...@gmail.com> a écrit:
> Paul,
> 
> On Saturday, November 30, 2013 10:03:07 AM UTC+1, Paul Isambert wrote:
> > I’ve encountered a behavior which really smells like a bug, but I’d
> > like to check here beforehand to be sure:
> > 
> > Go into linewise visual mode and leave it. Show the position of the '> mark 
> > with:
> > 
> > echo getpos("'>")
> > 
> > It returns something like (if you were on line 23):
> > 
> > [0, 23, 2147483647, 0]
> > 
> > where the very big value for the column means you were in linewise
> > visual mode. Now try to set the '> mark with e.g.:
> > 
> > echo setpos("'>", [0, 25, 12, 0])
> > 
> > “0” is echoed, meaning nothing went wrong. Use “getpos("'>")” again to see
> > the position of the mark, this time you’ll see:
> > 
> > [0, 25, 2147483647, 0]
> > 
> > The line was changed, but not the column. And it seems to happen
> > whenever the column number has that big value, i.e. whenever you went
> > into linewise visual mode.
> > 
> > Am I missing something?
> 
> I tripped over this myself in the past and posted it here as a bug.
> 
> But it's documented behaviour. :h setpos(), the last paragraph:
> 
> > This does not restore the preferred column for moving vertically. See
> > |winrestview()| for that.

Thank you David. I’d seen that part without really reading it nor
understanding what it means. In particular, how does it explain that
“setpos()” doesn’t set the column if and only if the current column is
“infinite”, whereas it works ok otherwise?

To put it another way, if “setpos()” is half useless, why does it
exit to begin with?

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Trouble with getpos()/setpos().

2013-11-30 Thread Paul Isambert
Hello all,

I’ve encountered a behavior which really smells like a bug, but I’d
like to check here beforehand to be sure:

Go into linewise visual mode and leave it. Show the position of the '> mark 
with:

echo getpos("'>")

It returns something like (if you were on line 23):

[0, 23, 2147483647, 0]

where the very big value for the column means you were in linewise
visual mode. Now try to set the '> mark with e.g.:

echo setpos("'>", [0, 25, 12, 0])

“0” is echoed, meaning nothing went wrong. Use “getpos("'>")” again to see
the position of the mark, this time you’ll see:

[0, 25, 2147483647, 0]

The line was changed, but not the column. And it seems to happen
whenever the column number has that big value, i.e. whenever you went
into linewise visual mode.

Am I missing something?

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Search and stay

2013-11-28 Thread Paul Isambert
Le lundi 25 novembre 2013 11:51:51 UTC+1, Paolo Bolzoni a écrit :
> Dear list,
> 
> I often search text in the latex documents to move around.
> So I press / and Vim shows me the
> place because I have incsearch active.
> 
> Can I just stay in the place without pressing enter?
> I am asking because I also have hlsearch on and while
> it is normally useful in this particular case is not.

Based on this very real annoyance, and having a little bit of time to kill, I
wrote the code below: not only does it removes the 'hlsearch' problem, but it
also makes search easier by foregrounding matches and letting you jump from
one to the next without leaving the search. I find it quite comfortable, but
of course others might find that just terrible. Here's how it works:

- Type  (in normal mode).
- Type your regex search as you would with a normal search (it is echoed in
the command line).
- Use  to jump to the next match, and  to jump to the previous
one. You can also continue searching after that.
- Hit  to exit and position the cursor on the current match.
- Hit  to end the whole thing without moving the cursor.
- You might want to change the color in the line:
hi searchRest guifg=#AA
or adapt it for the terminal (I'm using gVim).

If anybody is interested, I can make that into a plugin (rewriting it a little
bit less sloppily, because it will fail in some cases, plus it requires a few
options to be really interesting), in case, of course, such a plugin does not
already exist :)

Best,
Paul

" Put this code somewhere.
hi link searchFound Search
hi link searchHigh  Error
hi searchRest guifg=#AA

function! s:search (str, opos, ...)
  let str = a:str
  echohl Type
  redraw
  echo "Searching for: "
  echohl None
  echon str
  let ch = getchar()
  for n in a:000
if n >= 0
  call matchdelete(n)
endif
  endfor
  " : cancel the whole thing.
  if ch == 27
call cursor(a:opos[1], a:opos[2])
  " Other chars, except , which does nothing (the cursor is already
  " where it must be).
  elseif ch != 13
if ch == "\"
  let str = substitute(str, '.$', '', 'g')
elseif ch != 9 " 9 is .
  let str  .= nr2char(ch)
end
let rest  = matchadd('searchRest', '.*')
let found = matchadd('searchFound', str)
"  moves to the next match,  to the previous one.
let f = ch == 9 ? '' : (ch == "\" ? 'b' : 'c')
let pos   = searchpos(str, f)
call cursor(pos)
let high  = matchadd('searchHigh', '\%' . pos[0] . 'l\%' . pos[1] .'c' . 
str)
call s:search(str, a:opos, rest, found, high)
  endif
endfunction

nnoremap  :call search('', getpos('.'))
" End of code.

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Search and stay

2013-11-25 Thread Paul Isambert
"Paolo Bolzoni" :
> I often search text in the latex documents to move around.
> So I press / and Vim shows me the
> place because I have incsearch active.
> 
> Can I just stay in the place without pressing enter?
> I am asking because I also have hlsearch on and while
> it is normally useful in this particular case is not.

I've been wishing that could be done for some time now, but you can't;
however, you can use a mapping like:

cnoremap  :nohls

which does what you want with ; note that when used in the
command-line while not searching it will remove the previously highlighted
search, if any.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: "vim blog" plugin anyone?

2013-11-23 Thread Paul Isambert
"Keith Kaple" :
> I'm a developer and pretty much do everythig in vim, I was wondering
> if a plugin existed which would do the following.
> 
>   1 record my activity daily and append to a vim_blog.datestamp
>   2 "activity" would be a simple adding somthing like:
> added #lines deleted #lines changed #lines in
> /whatever/path/to/file
>   3 activity is recorded on :wq but not on just :w
>   4 the daily files would be collected in a subdir under .vim
>   somewhere
>
> Does this exist today or does anyone have suggestions on approaches?

There is no Vim on the computer I'm using now, so I can't help you very 
precisely, but I would suggest the following course:

1. Use the BufReadPre autocommand to copy each file before it is edited, and 
pasting the contents into a temp file (use "tempname()" for that); save the 
file's real path and the path to the temp copy in a list. The list will look 
like this:

[ ["/path/to/file1.ext", "/tmp/copy/of/file1.ext"], ["/dir/of/file2.ext", 
"/tmp/copy/of/file2.ext"], ... ]

2. When leaving Vim (hence in the VimLeave autocommand), run through your list 
and diff all edited files (comparing the current version with the one saved in 
the temp file) and write the result in your log file.

Sorry I can't be more specific. And simpler ways are perhaps possible.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Run console command before :w

2013-11-18 Thread Paul Isambert
Gary Johnson  a écrit:
> On 2013-11-18, Paul Isambert wrote:
> > "Егор"
> > > 18.11.2013 13:54, Paul Isambert написав(ла):
> > > > "Егор":
> > > >> How can I run console command before saving file? Is it possible
> > > >> to
> > > >> do it when type :w?
> > > > It depends on what you want to do exactly; you can try:
> > > >
> > > >  :execute "!cmd" | w
> > > >
> > > > (see "help :bar" on why you can't simply use ":!cmd | w").
> > > >
> > > > If you want to do something whenever you write a buffer to a file,
> > > > use the
> > > > BufWrite autocommand.
> > > >
> > > > Best,
> > > > Paul
> > > >
> > > Ok, next question.
> > 
> > You're welcome.
> > 
> > >I use autocmd BufWrite * execute "!apache restart"
> > > Now i need hit  two times when use :w Is it possible to fix
> > > it?
> > 
> > I guess you're looking for
> > 
> > autocmd BufWrite * execute "silent !apache restart"
> 
> There is no need for the :execute command here.  The following will
> suffice.
> 
> autocmd BufWrite * silent !apache restart

Oh yes, I’ve blindly modified the OP’s code, which was a mix of my first two 
solutions.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Run console command before :w

2013-11-18 Thread Paul Isambert
"Егор" 
> 18.11.2013 13:54, Paul Isambert написав(ла):
> > "Егор" :
> >> How can I run console command before saving file? Is it possible
> >> to
> >> do it when type :w?
> > It depends on what you want to do exactly; you can try:
> >
> >  :execute "!cmd" | w
> >
> > (see "help :bar" on why you can't simply use ":!cmd | w").
> >
> > If you want to do something whenever you write a buffer to a file,
> > use the
> > BufWrite autocommand.
> >
> > Best,
> > Paul
> >
> Ok, next question.

You're welcome.

>I use autocmd BufWrite * execute "!apache restart"
> Now i need hit  two times when use :w Is it possible to fix
> it?

I guess you're looking for

autocmd BufWrite * execute "silent !apache restart"

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Run console command before :w

2013-11-18 Thread Paul Isambert
"Егор" :
> How can I run console command before saving file? Is it possible to
> do it when type :w?

It depends on what you want to do exactly; you can try:

:execute "!cmd" | w

(see "help :bar" on why you can't simply use ":!cmd | w").

If you want to do something whenever you write a buffer to a file, use the
BufWrite autocommand.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Question about markdown-syntax-recognition

2013-11-13 Thread Paul Isambert
Niels Kobschaetzki  a écrit:
> On Wed, Nov 13, 2013 at 12:32:08PM +0100, Paul Isambert wrote:
> >De: "Niels Kobschätzki" 
> >> I am taking notes with markdown-syntax and often use nested unorderd
> >> lists. For example:
> >> - Test1
> >>   - Test2
> >> - Test3
> >>   - Test4
> >>
> >> With the first three lines the "-" gets colored correctly as an
> >> unordered list marker. But starting from Test4, so the third
> >> indentation
> >> the "-" doesn't get highlighted anymore. What can I do to change
> >> this?
> >> I took a look into the syntax file of markdown and I guess
> >> syn match markdownListMarker "\%(\t\| \{0,4\}\)[-*+]\%(\s\+\S\)\@="
> >> contained
> >> is the line that is responsible for it but I have no idea what I need
> >> to
> >> change to add a few indentations. I tried changing the 4 to a 5 but
> >> that
> >> didn't help.
> >> So, what do I have to do?
> >
> >Change 4 to 6 :)
> >
> >Actually you could even do
> >
> >  syn match markdownListMarker "\%(\t\| *\)[-*+]\%(\s\+\S\)\@="
> >
> >I don't know why it is originally limited to 4 spaces (or exactly one tab);
> >this way any number of spaces is ok.
> 
> Thanks a lot. That solved my problem :D

And I forgot (was reminded by a recent misunderstanding on this very
list), you should either

- write to the author of the syntax file so he changes it (in case
  there was no good reason to put a limit on the number of spaces, but
  that is quite unlikely);
- or write a markdown.vim syntax file yourself with something like:

source $VIMRUNTIME/syntax/markdown.vim
syn match markdownListMarker "\%(\t\| *\)[-*+]\%(\s\+\S\)\@="

In other words, don’t modify the original markdown.vim itself,
otherwise your change will be deleted on updates.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Question about markdown-syntax-recognition

2013-11-13 Thread Paul Isambert
De: "Niels Kobschätzki" 
> I am taking notes with markdown-syntax and often use nested unorderd
> lists. For example:
> - Test1
>   - Test2
> - Test3
>   - Test4
> 
> With the first three lines the "-" gets colored correctly as an
> unordered list marker. But starting from Test4, so the third
> indentation
> the "-" doesn't get highlighted anymore. What can I do to change
> this?
> I took a look into the syntax file of markdown and I guess
> syn match markdownListMarker "\%(\t\| \{0,4\}\)[-*+]\%(\s\+\S\)\@="
> contained
> is the line that is responsible for it but I have no idea what I need
> to
> change to add a few indentations. I tried changing the 4 to a 5 but
> that
> didn't help.
> So, what do I have to do?

Change 4 to 6 :)

Actually you could even do
  
  syn match markdownListMarker "\%(\t\| *\)[-*+]\%(\s\+\S\)\@="

I don't know why it is originally limited to 4 spaces (or exactly one tab);
this way any number of spaces is ok.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Paste with movements

2013-11-05 Thread Paul Isambert
- Mail original -
> De: "Егор" 
> À: "vim_use" 
> Envoyé: Mardi 5 Novembre 2013 08:26:16
> Objet: Paste with movements
> 
> I have text like this
> http://example.com/"; class="test-class">Link
> Now I want change link text. Also in buffer I have text I need to set
> to
> link. I need to put cursor on "L" paste from buffer with "P" key and
> then delete text from "L" till "<". Is it possible to paste text with
> deleting word? It would be great to do like this "pt<" paste till
> "<".
> Or if i want change link class, use 'pi"' like 'ci"'

Consider defining you own operator ":help map-operator".

The best I could come up with is:

function! s:delete (type)
  " I don't know why the motion must be forced to be inclusive with 'v'.
  exe "normal! `[dv`]"
endfunction
nnoremap  Pl:set opfunc=deleteg@

which defines {motion} to paste text (before the current poistion, like 
"P") and delete according to {motion}.

It's not very elegant (pasting is done before the motion is completed, which is 
confusing), plus it takes two undo's instead of one, but it may be the first 
step in the right direction.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Happy Birthday Vim

2013-11-02 Thread Paul Isambert
Tony Mechelynck  a écrit:
> Happy Birthday To You!
> Happy Birthday To You!
> Happy Birthday dear Vi-im!
> Happy Birthday To You!
> 
> and Many Happy Returns of the Day!
> 
> Vim is 12 years old today: its first public release (Vim 1.14 for the 
> Amiga) happened on 2 November 1991 on Fish disk #591.

You meant: Vim is 22. It has come of age some time ago :)

Happy birthday anyway! Whenever I must type something without Vim (and
quite often when typing something with it), I am reminded of how
wonderful modal editing is...

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I make a file not be recognized as a file type?

2013-10-28 Thread Paul Isambert
- Mail original -
> De: "Gary Johnson" 
> À: "vim use" 
> Envoyé: Lundi 28 Octobre 2013 18:54:19
> Objet: Re: How do I make a file not be recognized as a file type?
> 
> On 2013-10-28, Charles E Campbell wrote:
> > Nikolay Pavlov wrote:
> > >
> > >On Oct 28, 2013 7:35 PM, "Charles E Campbell" wrote:
> > >>
> > >> Nikolay Pavlov wrote:
> > >>>
> > >>> On Oct 28, 2013 7:14 PM, "Charles E Campbell" wrote:
> > >>> >
> > >>> > Paul Isambert wrote:
> > >>> >>
> > >>> >> Sam Roberts a écrit:
> > >>>
> > >>> >>>
> > >>> >>> On Fri, Oct 25, 2013 at 10:46 AM, Charles Campbell wrote:
> > >>> >>>>
> > >>> >>>> Do you have a comment character?  Use modelines.  Assuming
> > >% kicks off a
> > >>> >>>> comment, put the following at the bottom of the file:
> > >>> >>>
> > >>> >>> json does not, infamously, support comments
> > >>> >>>
> > >>> >>> But even if it did, I want ALL *.json to be not recognized
> > >as javascript.
> > >>> >>
> > >>> >> Delete the autocommand defined in filetype.vim:
> > >>> >>
> > >>> >>  :au! filetypedetect BufNewFile,BufRead *.json
> > >>> >>
> > >>> > Modifying a file such as filetype.vim that came with vim (ie.
> > >a system file) is a Bad Idea.  After the next update, the changes
> > >(long forgotten) will "disappear".
> > >>>
> > >>> There is no such :au***bang*** command in filetype.vim.
> > >Suggested method was removing the autocommand from vim in-memory
> > >structures.
> > >>>
> > >> Yes, there is.  Try looking at
> > >[/usr/local/share/vim/]vim74/filetype.vim line#968.  Suggested
> > >method involved removing the line from vim's distribution file.
> > >Bad Idea.
> > >>
> > >
> > >No, there is not. Reread the line, it suggests using banged
> > >version
> > >of autocommand to remove it. **Banged**. Line you are suggesting
> > >to
> > >look at contains **no** *banged* version. It also contains more
> > >then just *.json in a list of patterns. It does *not* contain
> > >string "filetypedetect" because it is specified at the top of the
> > >file with :augroup.
> > >
> > >Suggested method is undefining autocommand *after it was defined*.
> > >It though lacks information about where it should be put (most
> > >likely after :filetype ... on command), but it does not involve
> > >editing filetype.vim.
> > >
> > >
> > The method that was suggested by Paul Isambert was to delete the
> > line
> > setting up the json syntax recognition in the system file. Still a
> > bad idea.
> 
> No, that wasn't his suggestion.  That's what I thought originally,
> too, and had the same reaction as yours.  I almost wrote a reply,
> but I was tired, so I put it off.  Then I suddenly realized, "Oh,
> _that's_ what he meant!"
> 
> Paul's wording was unfortunately ambiguous:  "Delete the autocommand
> defined in filetype.vim:"  I'm not even sure I can rephrase it
> clearly.  He did not mean to delete the definition from the file; he
> meant to delete the autocommand, not from the file, but that which
> was defined in the file.

My suggestion was indeed to use ":au!" to remove the autocommand, and I used an 
ambiguous phrasing indeed that could be interpreted as "Delete the line in 
filetype.vim".

Peace, love, and happiness :)
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using substitute inside a map: v:val not recognized

2013-10-27 Thread Paul Isambert
Suresh Govindachar  a écrit:
> Hello,
> 
> How would one use substitute inside a map?
> 
> The following fails with error:  "E121: Undefined variable: v:val"
> 
>:let mylist=['c:\foo\hoo\boo', 'c:\foo2\boo2']
>:echo mylist
>:call map(mylist, substitute(v:val, 'o', 'p', 'g'))

:call map(mylist, "substitute(v:val, 'o', 'p', 'g')")

The second argument to map() is a string.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I make a file not be recognized as a file type?

2013-10-26 Thread Paul Isambert
Sam Roberts  a écrit:
> On Fri, Oct 25, 2013 at 10:46 AM, Charles Campbell
>  wrote:
> > Do you have a comment character?  Use modelines.  Assuming % kicks off a
> > comment, put the following at the bottom of the file:
> 
> json does not, infamously, support comments
> 
> But even if it did, I want ALL *.json to be not recognized as javascript.

Delete the autocommand defined in filetype.vim:

:au! filetypedetect BufNewFile,BufRead *.json

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Submatch and regex replace

2013-10-25 Thread Paul Isambert
stosss  a écrit:
> Starting out with a number at the beginning of the line and want to change
> it from a single or double digit to a triple digit such as 1 to 001 or 10
> to 010 and 100 stays as is
> 
> :%s@\(\d\+\)@\=printf("%03d", submatch(1))@
> 
> I also want to add some more information around it such as
> 
> :%s@\(\d\+\)@\1
> 
> It would be better to be able to do it in one pass so that I end up going
> from
> 
> 1
> 
> to
> 
> 1
> 
> I can do my second :s first and then do my first :s second.
> 
> Can I do this all in one pass? I haven't been able to figure out how to do
> what I want using the submatch example above and get the final result that
> I want.

Why not simply combine the two?

:%s@\d\+@\='' . 
submatch(0) . ''

Not the nicest line in the world, but it should work (note that I’ve
removed submatches to save a few characters).

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: containedin=Comment doesn't work

2013-10-17 Thread Paul Isambert
David Barnett  a écrit:
> I wanted to define a simple syntax highlight match for a literal word and
> have it only match inside comments. I tried
>   syntax match myword /WORD/ containedin=Comment contained
> but quickly found that this doesn't do much since the Comment group is
> never used literally, but only linked to by other groups like vimComment.
> 
> Is there a way I can get my syntax group matched in all Comment syntax
> groups without adding each one individually?

This might not be very elegant but it should work (once tailored to your needs,
of course):

" Add this to your .vimrc file.
hi def link MyWord TODO

function! s:commentword()
  syn clear MyWord
  redir => groups
  silent hi
  redir END
  let groupnames = map(split(groups, '[\n]'), 'matchstr(v:val, "^\\S\\+")')
  for g in groupnames
if g =~ 'Comment'
  exe 'syn match MyWord /WORD/ contained containedin=' . g
endif
  endfor
endfunction

augroup CommentGroup
  au!
  au Syntax * call s:commentword()
augroup END
" End of code.

It relies on the fact the highlight groups for comment generally
contain “Comment” in their names. We could be even smarter and check
for each group whether it is ultimately linked to the Comment group,
but then opening a new file is noticeably slower.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Vim on XP

2013-10-11 Thread Paul Isambert
Phil Dobbin  a écrit:
> After starting with computers in '87 with the now Classic Mac OS & going
> onto OS X in 2000 & Linux in 2005, today I was presented with my very
> first Windows machine (XP Pro) for a project I'm doing.

Poor you. You escaped from Apple, and now you’re stuck with Microsoft...

> The second thing I did after installing Chrome was to install gVim74 &
> place a highly curtailed `_vimrc` & the directory  `vimfiles` from the
> result of `:echo $HOME' in the appropriate place.

That’s how I use gVim on Windows at work.

> I'm wondering if anybody can point me in the right direction of some
> good online resources for Vim on Windows so I can get up to speed
> quickly with regards to plugins, tips & tricks, etc?

I don’t think there’s anything special, except for those plugins that
rely on Python or anything else (I have some Lua code which I can’t
use on Windows because it requires a Lua library that I can’t install
for some reason). The only thing I can see is to use the Cream
version, which has a full Vim up-to-date for Windows, unlike the Vim
for Windows downloadable from the Vim site, which often lags behind.

(Note: I don’t use many plugins, so perhaps I’m missing something
important.)

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Something to wrap a selection

2013-09-29 Thread Paul Isambert
Harry Putnam  a écrit:
> Paul Isambert  writes:
> 
> > I say goodbye here, the code follows. I’ll hope you’ll be satisfied
> > this time (there might be glitches, I did not test the command much,
> > just basic tries).
> 
> Oh boy, yup this baby works now.
> 
> Man, you went so far beyond the call of duty, and let me tell you that
> it was really appreciated here.

If duty there was, it was only not to give you half-baked code. Plus
writing scriptlets is so funnier than dish-washing.

> There are so many examples and techniques in that code I will be
> learning from it for a good while.
> 
> Oh, and I promise not to post one more thing to this thread.. : )

But you should if the code goes wrong. By the way there was a small
mistake. In:

let s:commentfile = expand(":p:h") . "/.markchangerc"
if filereadable(s:commentfile)
  let s:data = readfile(s:commentfile)
  for line in s:data
if line !~ '^#' && line =~ '='
  let s:matches = matchlist(line, '\([^=[:blank:]]\+\)\s*=\s*\(\S\+\)')
  if len(s:matches)
let s:markchangecomments[s:matches[1]] = s:matches[2]
  endif
endif
  endfor
endif

you should replace all occurrences of “line” with “s:line”, otherwise
it defines a global variable whereas you want it to be only visible in
the script (I’m used to loop variables being local, à la Lua).

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Something to wrap a selection

2013-09-28 Thread Paul Isambert
Harry Putnam  a écrit:
> Paul Isambert  writes:
> 
> > The code relies on an analysis of the “comments” option, which is
> > normally set by filetype. For .conf files, I can see that the option
> > is ambiguous (for our purpose), as it contains several characters for
> > one-line comments, and the code picked up the wrong one (the first
> > encountered).
> 
> Thanks for your efforts.  The script is doing what I wanted alright
> but it appears not to know any comment char other than //.
> 
> I named the input file:
> some.conf
> some.rc
> some.bash
> some.pl
> 
> And every case it inserts '//'.
> 
> Finally I opened a real, honest to god, perl script and tried it
> there. And still it inserts '//'

There’s obviously something wrong with filetypes or the setting of the
‘comments’ option. Since I don’t know where it comes from, and since
relying on the ‘comments’ option was not very sound anyway, we’ll
follow another course of action, see below.

> I wonder if there is a way to make vim tell me what kind of file it
> thinks its editing?
> 
> Or maybe better still a way for me to tell vim what kind of file I
> want it to be editing (temporarily at least)
> 
> My googling keeps getting tangled up with piles of *.vim files, 
> echoing $RUNTIME blah blah and so on and so on.  Not finding a definitive
> way to choke it out of vim for the current file.
> 
> Just typing :Filetype lets me know:
>filetype detection:ON  plugin:ON  indent:ON
> 
> But how can I coax vim into telling me what the current filetype is?

Use ‘:echo &filetype’ to see the buffer’s filetype, and ‘:echo &comments’
for the comments (and ‘:echo &option’ in general for any Vim option).
The ‘comments’ option might be a bit cryptic, see ‘:help format-comments’
if you want to understand it – but the code below doesn’t rely on all
that anyway.

> Or barring all that maybe just make the script insert octathorps in
> all cases.  At least that would be useful most of the time.

Let’s not give up! What you’re asking for is really not complicated, I
just shouldn’t have relied on ‘comments’ to begin with (the option is
not meant to insert comments, but to format commented paragraph
properly; it doesn’t have to be unambiguous for its own purpose).

The new command works as follows; type:

:MarkChange {optional keywords}

(The keywords work as in the previous versions of the code.)

If no comment sign is recorded for the current filetype, the code will
analyze the ‘comments’ option and ask you whether the character(s) it
found are ok; if not, you can give it something else. Then you will be
asked whether you want that comment to be remembered, and it can be
remembered either for the current session only (until you exit Vim) or
until the end of time (more or less); in the latter case, an external
file will be used to remember comments from session to session. If a
comment is remembered for a given filetype, you will not be asked
again to confirm whether it’s ok or not, unless you use:

:MarkChange! {optional keywords}

which asks for confirmation and allows you to change the comment
again, as if none were recorded. 

(Not using a recorded comment and/or not remembering the comment you
will use may be useful for files containing several languages; for
instance, a vimscript file can contain snippets of Lua or Ruby or
whatever, which you’ll comment with a special character, but you’ll
probably want to keep the default Vimscript comment.)

The external file used to record comments is created the first time
you want a comment to be definitely remembered. It will be called
‘.markchangerc’, and you’ll be able to modify it by hand. It will be
located in the same directory as the file where the ‘:MarkChange’
command is defined; if that is in your .vimrc file, then
‘.markchangerc’ will be where your .vimrc file is ($HOME, I should
guess). Actually, I guess you’d better put the entire code in a file
of its own (say ‘markchange.vim’) and put that file in ‘.vim/plugin/’
(itself in $HOME by default), so the ‘.markchangerc’ file will be
there too and won’t puzzle you a few years hence when you find it in
$HOME, and you’ll be able to delete all relevant files when the code
doesn’t suit your needs anymore. Better yet, use ‘pathogen’ (see
http://www.vim.org/scripts/script.php?script_id=2332).

I say goodbye here, the code follows. I’ll hope you’ll be satisfied
this time (there might be glitches, I did not test the command much,
just basic tries).

Best,
Paul

" Put this somewhere.
let s:markchangecomments = {}

let s:commentfile = expand(":p:h") . "/.markchangerc"
if filereadable(s:commentfile)
  let s:data = readfile(s:commentfile)
  for line in s:data
if line !~ '^#' &

Re: Something to wrap a selection

2013-09-26 Thread Paul Isambert
Harry Putnam  a écrit:
> Paul Isambert  writes:
> 
> 
> > For any further fun, try “:help [range]”.
> 
> Oh no... you're not getting off that easy... hehe.

I was just trying to advertise Vim’s excellent help :)

> Honestly, you'll probably wish you never started, but I'm not getting
> enough out of this bit of code to see how to make it do what I want.
> 
> Quest 1) How is the code determining what comment char to use?
> I created a file some.conf  With some commented lines followed by
> variable value.  The comments are `#', and yet the code uses '//'.
> Plus there is no space after // .  But seems like it should be '# '
>
> The emacs code tries to guess the right comment char, but if it
> doesn't know from the file name, then it asks me which one to use.

The code relies on an analysis of the “comments” option, which is
normally set by filetype. For .conf files, I can see that the option
is ambiguous (for our purpose), as it contains several characters for
one-line comments, and the code picked up the wrong one (the first
encountered).

The new code below does the following thing: “:MarkChange” can be
called with a exclamation mark, as in:

:MarkChange! {}

Without the mark, it works as before, trying to find the proper comment
sign by itself. With the exclamation mark, it will prompt for the
proper symbol. The code could be modified further so those symbols are
stored in an external file and you won’t have to specify them again.
(Another syntax that you may prefer is “:MarkChange {optional sign}”,
with, I hope, an obvious semantics, while the command would always
prompt for keywords.)

As for the space, the new code below adds it.

> Quest 2)
> Further, the already commented lines are not recommented as in my
> posted example (Not the first post... I had it wrong there) So, In
> that case, I can't tell at a glance, 2yrs later, what the original 
> suggested value was
> 
> Example:
> Lets say we start with this:
> 
>   # commented line1
>   # commented line2
>   # suggested value
>   my newvalue
> 
> Or maybe as often this:
> 
>   # commented line1
>   # commented line2
>   suggested value
>   my_newvalue
> 
> 
> 
> After calling MarkChange, I want to see this:
> 
>  # Keywords: whatever I typed
>  # [Keydate: DATE] 
>  # # commented line
>  # # commented line
>  # # suggested value
>  my_newvalue
> 
> or
> 
>  # Keywords: whatever I typed
>  # [Keydate: DATE] 
>  # # commented line
>  # # commented line
>  # suggested value
>  my_newvalue
> ----   ---=---   -   
> 
> so I can see right away what was the original value and how I changed
> it.

That’s no big problem. The new code does that, although you’ll have to
uncomment “my_newvalue” by hand.

> I tried changing even a few minor things in the code and right away it
> blows up and fills the buffer with numerous threats and warnings hehe.
> 
> I'm not understanding the syntax much at all.

Man, you can write in Elisp but not in Vimscript? Those Emacs users
are very strange indeed.

Anyway, here’s the code:

" Put this in your vimrc file.
function! s:markchange (kw, com) range
  if a:com
let comment = input("Comment sign, please?\n")
  else
" Retrieve the one-line comment string, hoping it exists (could be
" defined otherwise, too).
let comment = matchstr(&comments, '[[:alnum:]]\@,call 
s:markchange(, 0)
" End of code.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Something to wrap a selection

2013-09-26 Thread Paul Isambert
Harry Putnam  a écrit:
> Paul Isambert  writes:
> 
> [...]
> 
> >> It will look like this when done and I've removed the one comment
> >> to let the new rule work 
> >> 
> >>   # Keywords: Replace old rule with new experimental rule 
> >>   #[Keydate:130922_214226 0 - Sun Sep 22, 2013
> >>   # This is the default setting because blah blah blah
> >>   # more blah blah blah blah blah
> >>   # current rule in rc file
> >>   New rule replacing line above
> >>   # &&
> >
> > ... how is the “current rule in rc file” identified as an old code
> > line to be commented? Here I’ll assume it is the last but one line,
> > following your example, but I suppose it’s quite unlikely that it will
> > always be so. The “:MarkChange” command should be called while the
> > region to be processed is selected; it could be modified so it is
> > called on the old code (to be commented) and then find the limits of
> > the entire region by itself (e.g. with blank lines).
> 
> Thanks for the input, I'm just getting started trying to understand
> and use your suggestions.
> 
> It's going to sound horribly lame, but I'm already stuck just trying
> to call the function you wrote.
> This isn't the way, I can see  
>   :markchange  NOT
> 
> So how is it called?

You shall try to call the Ex command (defined with “:com”) called
MarkChange, not the function (defined with “:function”) called
s:markchange (why I didn’t put uppercase letters in the later case, I
don’t know, except probably that I don’t have too, unlike the Ex
command).

Select (in visual mode) the lines you want to modify, and type

:MarkChange 

If the keywords aren’t given, the command will prompt for them.
Actually, since you’re in visual mode, the command line will appear as:


:'<,'>MarkChange 

and you could also not go in visual mode at all and specify line
numbers instead, e.g.:


:30,35MarkChange 

For any further fun, try “:help [range]”.

> Also I'm afraid I was not very clear about what I'm after.  So
> explaining a bit further. 
> 
> I didn't expect the code to try to identify anything special in the
> selected section, like an uncommented line.  Just to comment it all
> after asking me for Keywords.
> 
> A typical entry in a rc file with some helpful commented lines might
> look like:
> 
> # helpful info
> # commented value
> 
>   Then I might add
> 
> # helpful info
> # commented value
> uncommented value
> 
> Then I would select those three lines, call my handy wrapping code
> which would first prompt for keywords, then insert what I gave
> it along with the commented word  `Keywords:' like:  
> 
>   # Keywords: prompted words
> 
> then Todays date
>
>   #  [todays date]
> 
> next - it would comment every thing selected:
> 
>   # # helpful info
>   # # commented value
>   # uncommented value
> 
> And finally the closing symbol
>   
>   # &&
> 
> So the end result would be:
> 
>   # Keywords: prompted words
>   #  [todays date]
>   # # helpful info
>   # # commented value
>   # uncommented value
> 
> Last step... I would manually uncomment the line I wanted:
> 
>   # Keywords: prompted words
>   #  [todays date]
>   # # helpful info
>   # # commented value
>   uncommented value
> 
> (Sorry if this seems a bit over the top... but wasn't able to make
> clear what I was after and my example was actually incorrect too.)

Your explanation is very fine, but there is one thing I don’t
understand: why commenting everything and not just the additional
lines (keywords, date, end symbol), so you won’t have to uncomment by
hand afterward?

The code below does just that: it adds the (commented) requested lines
without commenting the new code (nor the old code, since you
mentionned that you did that by hand, which is probably safer; that’s
actually the only difference with my original function). I hope it’ll
do what you want.

" Put this in your .vimrc file.
function! s:markchange (kw) range
  " Retrieve the one-line comment string, hoping it exists (could be
  " defined otherwise, too).
  let comment = matchstr(&comments, '[[:alnum:]]\@,call s:markchange()
" End of code.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Improve context syntax file

2013-09-26 Thread Paul Isambert
Nikolay Pavlov  a écrit:
> On Sep 26, 2013 2:12 PM, "Marco"  wrote:
> >
> > On 2013–09–26 Paul Isambert wrote:
> >
> > > > But I can't add it permanently. The underscore is only part of a
> > > > word in between the following blocks.
> > > >
> > > >   \unprotect… \protect %% or
> > > >   \starttexcode … \stoptexcode
> > >
> > > Since there is little chance that an underscore will immediately follow
> a
> > > control sequence anyway, I don't think defining it for the entire
> syntax file
> > > will cause any problem.
> >
> > I tried this. But iskeyword does not change the syntax highlighting.
> > It only seems to have an effect on the “*” and similar commands. So
> > changing iskeyword is probably not what I'm after.
> 
> It also affects \k atom. If changing &iskeyword does not affect syntax
> highlighting then it means this atom is not used.

Anyway it’s not a good idea since I had forgotten about math mode indeed.

> > > However, you can do something along the following lines:
> > >
> > >   sy match ControlSequence '\\[a-zA-Z]\+'
> > >   sy match SpecialControlSequence '\\[a-zA-Z_]\+' contained
> > >   sy region SpecialCode matchgroup=ControlSequence start='\\unprotect'
> end='\\protect' contains=SpecialControlSequence
> >
> > I tried this, but it removes all syntax highlighting. Frankly, I
> > have no idea of how the syntax highlighting works. I have to read up
> > the basics to understand how this exactly works. The issue seems
> > more complicated than anticipated. But thanks for the snippet, it's
> > something to start with.
> 
> You also need to make all other syntax groups be containedin=SpecialCode.
> Or add contains=... to SpecialCode definition for all groups you need to be
> highlighted.
> 
> Note that there is no need in defining two separate syntax groups. You can
> make two rules for ControlSequence where one will be contained and other
> will not.

You also need, above all, to define highlight groups (that was
implicit in my code, I thought you knew about that), e.g.:

  hi link ControlSequence Statement

But indeed you should learn a little bit more about highlighting (I’ve
always found modifying existing syntax files quite painful and easier
to start from scratch). Otherwise you may perhaps ask someone like
Aditya Mahajan, who is both an advanced ConTeXt user (he writes in
TUGboat) and, as far as I know, a Vim user.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Improve context syntax file

2013-09-26 Thread Paul Isambert
Marco wrote:
> On 2013–09–26 Nikolay Pavlov wrote:
> 
> > > Does someone have a solution for the remaining two problems?
> > 
> > I guess you need to alter iskeyword for the problem with
> > underscore.
> 
> But I can't add it permanently. The underscore is only part of a
> word in between the following blocks.
> 
>   \unprotect… \protect %% or
>   \starttexcode … \stoptexcode

Since there is little chance that an underscore will immediately follow a
control sequence anyway, I don't think defining it for the entire syntax file
will cause any problem.

However, you can do something along the following lines:

  sy match ControlSequence '\\[a-zA-Z]\+'
  sy match SpecialControlSequence '\\[a-zA-Z_]\+' contained
  sy region SpecialCode matchgroup=ControlSequence start='\\unprotect' 
end='\\protect' contains=SpecialControlSequence

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Something to wrap a selection

2013-09-24 Thread Paul Isambert
Hello Harry;

Harry Putnam  a écrit:
> Probably at risk of starting a vim/emacs tug of war. I hope not.

Do not be afraid. We have only compassion for our less fortunate
brothers and sisters.

> I have small bit of code using elisp that inserts a 'Keyword' entry
> around a selected region.  Now I want to replicate that ability using
> vim.

That is not very complicated except that...
[snip]

> It will look like this when done and I've removed the one comment
> to let the new rule work 
> 
>   # Keywords: Replace old rule with new experimental rule 
>   #[Keydate:130922_214226 0 - Sun Sep 22, 2013
>   # This is the default setting because blah blah blah
>   # more blah blah blah blah blah
>   # current rule in rc file
>   New rule replacing line above
>   # &&

... how is the “current rule in rc file” identified as an old code
line to be commented? Here I’ll assume it is the last but one line,
following your example, but I suppose it’s quite unlikely that it will
always be so. The “:MarkChange” command should be called while the
region to be processed is selected; it could be modified so it is
called on the old code (to be commented) and then find the limits of
the entire region by itself (e.g. with blank lines).

Also, the command can take an optional argument, the “keywords” line
to be inserted; if not given, the function will prompt for it.

" Put this in your .vimrc file.
function! s:markchange (kw) range
  " Retrieve the one-line comment string, hoping it exists (could be
  " defined otherwise, too).
  let comment = matchstr(&comments, '[[:alnum:]]\@,call s:markchange()
" End of code.

I hope it helps.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Advanced vimrc? question

2013-09-10 Thread Paul Isambert
> De: "Jonathan del Strother" 
> À: "vim use" 
> Envoyé: Mardi 10 Septembre 2013 10:14:15
> Objet: Re: Advanced vimrc? question
> 
> On 10 September 2013 09:08, Gabor Urban < urbang...@gmail.com >
> wrote:
> 
>> Hi
>> 
>> I have a problem which is not a top priority issue, but quite
>> annoying for me.
>> 
>> I use different indention depth with different types of sources. It
>> is rather time consuming to set it manually. Is there a possibility
>> to defined these values to file extensions?
> 
> Have you tried autocmds? eg
> autocmd FileType python setlocal shiftwidth=4
> autocmd FileType ruby setlocal shiftwidth=2

It's probably cleaner to add a vim file in your "indent" directory
(python.vim, ruby.vim, etc.) and let filetype detection load it automatically.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Copy matching line and following line to register

2013-07-20 Thread Paul Isambert
skeept  a écrit:
> Following some vim tip, I can copy all the lines matching TODO to a register 
> u with
> 
> quq -- clear register u
> :g/TODO/y U -- append of the lines matching TODO to register u
> 
> is there a similar way that I can append the line matching and the line 
> following the matching line, for each line that matches?

Why not simply “:g/TODO/y U 2”?

Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: using formatoptions +a autoflow

2013-07-18 Thread Paul Isambert
Eric Smith  a écrit:
> I like to use autoflow but wish to have it automatically switch
> off when editing structured paragraphs.
> 
> For example when editing emails, I do not want autoflow to
> reformat the headers or the signature.
> 
> How could I have it switch off when editing these paragraphs
> and on again with other text?

You could try something like this, which is quite hackish, though:

function s:checkformat ()
  let ln = line('.')
  let signature = 0
  while ln > 1
if getline(ln) == '--'
  let signature = 1
  break
end
let ln -= 1
  endwhile
  if signature
set formatoptions-=a
  else
set formatoptions+=a
  end
  echo &formatoptions
endfunction

augroup checkformat
  au!
  " Perhaps you'll want that more specific, e.g. *.eml
  au InsertEnter * call s:checkformat()
augroup END

This checks whether one of the lines above the current one is “--”,
and if so removes the “a” in “formatoptions”, because it means you’re
in the email signature. The checking occurs whenever you go from
normal to insert mode, so it won’t work when you move from the email’s
body to the signature without leaving and reentering insert mode. To
be sure you miss as few occasions as possible, you could add the
function to the “CursorMovedI” autocommand or even “InsertCharPre”,
but I don’t know how much it would affect performance. Technically you
could check the kind of paragraph you’re in each time the cursor is
moved.

I’ll let you find the rest of the function for header fields :)

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Indentation file for Specman E language

2013-07-17 Thread Paul Isambert
צביקה הרמתי  a écrit:
> Hi.
> 
> I've created a VIM indentation file for Specman E language.
> Please see it at:
> https://specman1.wordpress.com/2013/01/20/vim-specman-indentation/
> 
> I've been using it for 6 months, and while it's not perfect, it seems
> to generally do the job.
> 
> Feedbacks and suggestions are welcomed!
> 
> Someone commented on that page, and suggested using 'indentkeys'.
> However, I don't understand how using, or not using 'indentkeys',
> would affect editing experience.

The “indentexpr” function is executed when a new line is created, but
also when something matching a part of “indentkeys” is typed; for the
latter case, you should ask yourself  “what kind of things should
trigger a reeindentation of the current line?”

For instance, if you’re writing this code in Vimscript:

if whatever
  dosomething
  end

one you’ve typed “end” you’ll want that line to be unindented, so it
matches the first one (whereas for the moment it matches the second
one, as expected by default). That is done automatically because
“indentkeys” for Vim contains “=end” (just do “:echo &indentkeys” in a
Vim file), which means “reindent whenever ‘end’ is typed”.

Note that the default value of “indentkeys” might already (partially)
suit your needs (for instance, it reindents on braces). I don’t know
Specman, so I can’t help you any further.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: A small feature request for Vim 7.4

2013-07-16 Thread Paul Isambert
Aggelos Kolaitis  a écrit:
> On Monday, July 15, 2013 7:19:09 PM UTC+3, Nicolas Dermine wrote:
> > > On Mon, Jul 15, 2013 at 4:26 PM, Aggelos Kolaitis  
> > > wrote:
> > > 
> > > I'm using Vim version 7.3.
> > > 
> > > When in visual block mode, once I have chosen a one-line column, the last 
> > > char has not been highlighted. For example consider the following text:
> > > 
> > > |   first
> > > |   second
> > > |   third
> > > 
> > > I move the cursor the first 'f', enter visual block mode with 'Ctrl-V' 
> > > and do a '2j' to move to 't' of third.
> > > 
> > > This, however, will only highlight 'f' and 's' (the first characters from
> > > the first and second lines). This wasn't a problem when my terminal used a
> > > block for its cursor ( [] ), which was something that highlighted the 
> > > final
> > > line.
> > > 
> > > Recently I switched to and underline character ( _ ) for cursor, and now
> > > that makes me a little dizzy trying to figure out the portion selected. 
> > > Could
> > > it be the 7.4 version ( or a quick patch for 7.3 ) that would also 
> > > highlight
> > > the last character?? I hope the example was useful to understand the 
> > > 'issue'.
> > > 
> > > Thanks...
> > 
> > Hi,
> >
> > for what it's worth when I try and reproduce your steps on the same text 
> > (Ctrl+V 2j starting on 'f'), the letters 'f', 's' and 't' are highlighted.
> > I tried with colorscheme koehler and default, Vim 7.3 on windows 7.
> 
> 
> Nicolas
> Yeah, but what is your cursor's shape ??? If it is a ''block character''( [] 
> ), then everything is highlighted, (the cursor highlights the `t` in our 
> exaple. But with the underline character (_) as cursor, this does not happen.
> 
> The main issue is that vim, when highlighting a visual selection, it 
> highlights everything but the current cursor position. That is okay with some 
> cursors, since they take care of highlighting the current position, but not 
> for all (e.g. my example with the underline `_' character). 
> 
> So, is it possible to allow vim to highlight the current position too ? And 
> if it breaks some things ( e.g. cursor cannot be found because the blink is 
> not shown, at least have an option somewhere to switching this behaviour 
> on/off.

I use gVim (like Nicolas, I suppose, since he mentionned Windows), and
there the last character is properly highlighted. However, in console
Vim the last character is indeed left unhighlighted. I don’t know
which behavior is the right one, but it seems inconsistent and should
probably be fixed.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Strange motions.

2013-07-14 Thread Paul Isambert
Nikolay Pavlov  a écrit:
> On Jul 14, 2013 5:21 PM, "Tim Chase"  wrote:
> >
> > On 2013-07-14 15:00, Nikolay Pavlov wrote:
> > > vim-use is not a proper place to ask such question. I forwarded your
> > > message to vim-dev. Please discuss nothing here.
> >
> > This is a pretty harsh rebuke for something quite apropos of this
> > list.  It might have been a peculiar as-designed behavior, or it
> > might have been a bug.  It's also good for other members on the list
> > to be aware of such peculiar behaviors that exhibit themselves in the
> > running application (rather than issues in the source code itself).
> > If anything, based on the list's history, it's far better (or at
> > least more common) to dialog on vim-use@ until it's a confirmed bug,
> > at which point the under-the-hood discussion moves to vim-dev@
> >
> > I appreciate having the issue raised here initially.
> 
> Ok, I must apologize then. Just thought that a) there is no reason it
> should not be a bug and b) bugs should only go to vim-dev because Bram
> takes less attention to vim-use.

Nothing serious anyway; just note that I’m not subscribed to vim-dev
and do not intend to be (since most of what is posted there is way
above my head).

For those interested, Bram answered my message and the result is: “g$”
is buggy, at least in “dg$” (the visual version is less clear,
see below), and will be patched accordingly. As for “dd”,
that’s normal (apparently Vi-compatible) behavior.

Bram, about “vg$”: my “selection” is exclusive; if set to inclusive,
then in

abc
~ def
~ ghi

(where the tilde again indicates a wrapped line), “vg$” (from
“a”) properly includes the last character of the apparent line;
actually “v3g$” includes the end-of-line (I suppose), so that with “d”
for instance the next line is joined to the current one. I suppose
that’s normal.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Strange motions.

2013-07-14 Thread Paul Isambert
Nikolay Pavlov  a écrit:
> vim-use is not a proper place to ask such question. I forwarded your
> message to vim-dev. Please discuss nothing here.

The division of labour is not so airtight, Nikolay. I have posted on
this list, and will continue to post, about things that seem strange
to me, just as various bugs, possible improvements and other
“develish” things have been discussed here. If what I’ve found is
indeed a bug, I will report it as required; in the meanwhile, we’re
discussing Vim stuff and this is a very proper place indeed. Posting
to vim-dev only would make sense if my message had absolutely no
relevance to the average Vim user; being an average Vim user myself
(and consequently not subscribed to vim-dev), this here list is the
most natural choice.

Best,
Paul

> On Jul 14, 2013 2:12 PM, "Paul Isambert"  wrote:
> 
> > Hello all,
> >
> > Working on Leonardo’s question regarding “dd”, I stumbled on the
> > following: “g$” seems to be sometimes inclusive, sometimes exclusive,
> > in ways that elude me. I might be misunderstanding something, but if I
> > don’t it looks like a bug to me.
> >
> > Suppose you have the following two lines:
> >
> > abc
> > def
> >
> > You’re on “a” and type “dg$”; characters up to (and including) “c” are
> > deleted. On the other hand, if you type “d2g$”, then deletion goes to
> > “e”, leaving “f”. If you add “v” in both cases (“dvg$” and “dv2g$”)
> > then the pattern is reversed: in the first case “c” is not deleted, in
> > the second case “f” is deleted. So the first motion is inclusive by
> > default, and the second is exclusive; “v” reverses that (as it is
> > meant to do).
> >
> > Second oddity: if instead of deleting you’re moving in virtual mode,
> > then the motion is always inclusive: “vg$” includes “c”, “v2g$”
> > includes “f”.
> >
> > Third oddity: suppose you have one long, wrapped line instead of two
> > (the tilde is supposed to indicate wrapping):
> >
> > abc
> > ~ def
> >
> > Again, you’re on “a”. Deletion works as in the previous case: “c” is
> > included, “f” is not. But now visual mode excludes the last character:
> > “vg$” selects “ab”, not “abc”; “v2g$” excludes “f” unless it is the
> > last character of the (real) line, so in this case it would be
> > included, but not in the following:
> >
> > abc
> > ~ def
> > ~ ghi
> >
> > I’ve never really been comfortable with in-/exclusiveness of motion,
> > but here it definitely doesn’t make any sense to me.
> >
> > And now a second, unrelated question, since I’m at it: “Xdd”, where
> > “X” is a count, doesn’t do anything if you’re on the last line and X is
> > larger than 1; in other words, Vim doesn’t delete as many lines as
> > possible; instead, it deletes nothing. Now if you’re not on the last
> > line, Vim does delete as many lines as possible, even if X is larger
> > than the number of remaining lines; e.g. “5dd” deletes 2 lines when
> > you’re on the last but one line. Is there any rationale for this
> > difference in behavior?
> >
> > Best,
> > Paul
> >
> > --
> > --
> > You received this message from the "vim_use" maillist.
> > Do not top-post! Type your reply below the text you are replying to.
> > For more information, visit http://www.vim.org/maillist.php
> >
> > ---
> > You received this message because you are subscribed to the Google Groups
> > "vim_use" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to vim_use+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
> >
> 
> -- 
> -- 
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
> 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to vim_use+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 
> 

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Strange motions.

2013-07-14 Thread Paul Isambert
Hello all,

Working on Leonardo’s question regarding “dd”, I stumbled on the
following: “g$” seems to be sometimes inclusive, sometimes exclusive,
in ways that elude me. I might be misunderstanding something, but if I
don’t it looks like a bug to me.

Suppose you have the following two lines:

abc
def

You’re on “a” and type “dg$”; characters up to (and including) “c” are
deleted. On the other hand, if you type “d2g$”, then deletion goes to
“e”, leaving “f”. If you add “v” in both cases (“dvg$” and “dv2g$”)
then the pattern is reversed: in the first case “c” is not deleted, in
the second case “f” is deleted. So the first motion is inclusive by
default, and the second is exclusive; “v” reverses that (as it is
meant to do).

Second oddity: if instead of deleting you’re moving in virtual mode,
then the motion is always inclusive: “vg$” includes “c”, “v2g$”
includes “f”.

Third oddity: suppose you have one long, wrapped line instead of two
(the tilde is supposed to indicate wrapping):

abc
~ def

Again, you’re on “a”. Deletion works as in the previous case: “c” is
included, “f” is not. But now visual mode excludes the last character:
“vg$” selects “ab”, not “abc”; “v2g$” excludes “f” unless it is the
last character of the (real) line, so in this case it would be
included, but not in the following:

abc
~ def
~ ghi

I’ve never really been comfortable with in-/exclusiveness of motion,
but here it definitely doesn’t make any sense to me.

And now a second, unrelated question, since I’m at it: “Xdd”, where
“X” is a count, doesn’t do anything if you’re on the last line and X is
larger than 1; in other words, Vim doesn’t delete as many lines as
possible; instead, it deletes nothing. Now if you’re not on the last
line, Vim does delete as many lines as possible, even if X is larger
than the number of remaining lines; e.g. “5dd” deletes 2 lines when
you’re on the last but one line. Is there any rationale for this
difference in behavior?

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do i remap dd so that it becomes context-dependent?

2013-07-14 Thread Paul Isambert
Nikolay Pavlov  a écrit:
> On Jul 14, 2013 1:53 AM, "Leonardo Barbosa" 
> wrote:
> >
> > Thanks Nikolay. That did the job. I was wondering if i could pass an
> > argument to the map so that i can do something like : 2dd, 3dd, and so
> > on...
> 
> Count is accessible via v:count and v:count1. You will have to write
> function that handles it properly though in the case of lengthy lines.

This should work:

nnoremap   dd (virtcol('$') > winwidth(0)) ? 'g0d' . (v:count > 1 
? 'v' . v:count : '') . 'g$' : 'dd'

The conditional addition of “v” is explained (more or less) in my next message.

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: find and replace with sequential numbers

2013-07-12 Thread Paul Isambert
Chris Lott  a écrit:
> I have a document with the following kind of text:
> 
> ## 3. foo
> 
> various text here
> 
> ## 1. foo
> 
> more text here
> 
> What I would like to do is search for all the headers (## X. etc) and
> replace them with the proper sequential numbering. How do I approach
> this?

Something like this:

function! s:renumber ()
  let [a:count, a:lineno, a:last] = [0, 1, line('$')]
  while a:lineno <= a:last
let a:line = getline(a:lineno)
if a:line =~ '^##\s\+\d\+\.'
  let a:count += 1
  call setline(a:lineno, substitute(a:line, '^##\s\+\zs\d\+\ze\.', 
a:count, ''))
endif
let a:lineno += 1
  endwhile
endfunction
com! Renumber call s:renumber()

I’m sure some “vizard” can do the same without using a counter like
a:count (and, of course, with :substitute).

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Simplified logo concept

2013-07-10 Thread Paul Isambert
"Christian Brabandt"  a écrit:
> On Wed, July 10, 2013 06:22, James Beck wrote:
> >> What's wrong with it?
> >>
> >>
> >> Best regards,
> >> Tony.
> >
> > I have a few complaints about the original logo.
> >
> > 1. It's very busy (seven colors?!)
> > 2. It doesn't print well (seven colors, hairline borders, gradients)
> > 3. It's inconsistent (some parts are embossed, others not. Shading is done
> > in both blue and black.)
> > 4. The font styles ("V" and "im") are different (this makes my eyes
> > twitch)
> > 5. The "m" looks like someone melted it with fire. Inelegant and weird.
> > 6. As a general rule, when loud background texture (green diamond) cuts
> > through text, it makes me twitch (see the treatment of "im")
> 
> Good points. I don't really like the modern flat style of icons nowadays
> (perhaps I am just not used to it yet), but I would appreciate a new
> fresh look of the old logo.

I think the complaints are quite valid too, but I don’t really like
James’s proposal either:

- I think the logos would really fit a detergent. (I do appreciate the
  simplicity, though.)
- Why a slab serif, and why a *slanted* slab serif? For me, that
  contradicts the simplicity of the design; you’re whispering with
  colors and screaming with the font.
- Lowercase initial is trendy; but is that really Vim? I wonder
  whether all-uppercase wouldn’t be better.

As far as I’m concerned, I’d like a simple logo in a simple
yet stately font: a humanist serif or even Roman capitals like Trajan.
After all “Vim” is the accusative of “vis”, meaning “strength, power”,
and all those kinds of properties you associate with our favorite text
editors (and tyrants, too). If the green diamond must be kept in the
background, though, that really makes things hard.

Thank you James for launching the idea and submitting proposals (I
hope my criticism wasn’t too unpleasant).

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: append to non-blank lines in a selection

2013-06-21 Thread Paul Isambert
Chris Lott  a écrit:
> On Fri, Jun 21, 2013 at 6:55 AM, Ben Fritz  wrote:
> > Since you don't like regex (although you're right, you should learn)
> 
> It's not that I don't like regex, it's that I've found them hard to
> learn. Suggestions on good sites/books/etc to learn them would be much
> appreciated.

Perhaps you should start with some basic stuff (like “*” or “$” or
character classes) and then learn new things when you need them
(that’s how I got used to regex myself). For instance, Gary and Ben’s
solution might give unwanted results if blank lines contain space
characters. So your next step is “Could it be possible to match a line
that contain at least one non-space character?” and a quick look up
“:help pattern.txt” gives you “\S”:

:g/\S/s/$/word/

So my advice (I’m definitely no authority on that subject, mind you)
is to *use* regex and fill in the blanks stepwise; if you really don’t
know anything about regex (I doubt that is true, though), then perhaps
“:help user_27” might be a good starting point.

(And you definitely should use regex with Vim! Otherwise it’s like a
corded drill with the power off.)

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Dealing with empty strings in regexp.

2013-06-18 Thread Paul Isambert
LCD 47  a écrit:
> On 18 June 2013, Paul Isambert  wrote:
> > Hello all,
> > 
> > The following issue has been recently discussed on the Lua mailing list:
> > http://lua-users.org/lists/lua-l/2013-04/msg00812.html
> > 
> > (It has also been independantly raised on the LuaTeX list:
> > http://tug.org/pipermail/luatex/2013-June/004418.html)
> > 
> > If I understand correctly, any string can be represented with
> > interspersed empty substrings. E.g. “abc” is really “ϵaϵbϵcϵ”, where
> > “ϵ” is the empty string. Now, there seems to be two ways to deal with
> > those empty strings in regexps, especially regarding the “*” operator:
> 
> You're making up a metaphysics of empty substrings.  I humbly submit
> that there is no such thing in the programming languages you mention
> (don't know about Lua though).

As I’ve already said, the empty strings were just meant to capture the
differences between languages. I did not mean to imply that those
substrings have any kind of reality.

> > - The Perl way: “X*” matches as many “X” as possible, and does not
> > include the following empty string.
> 
> $ echo -n abc | perl -pe 's/[ac]*/($&)/g'
> (a)()b(c)()
> 
> The key to understanding this is to keep in mind that:
> 
> (1) "*" is greedy; and
> (2) "/g" is defined as "Global matching, and keep the Current position
> after failed matching."
> 
> Try something like this if you want the gory details:
> 
> $ echo -n abc | perl -Mre=debug -ne 's/[ac]*/($&)/g'
> 
> > - The Python (or sed) way: “X*” matches as many “X” as possible, and
> > includes the following empty string.
> > 
> > Starting empty strings are always included. So, the Perl way gives (I
> > use Ruby, since I can’t speak Perl):
> > 
> > puts 'abc'.gsub(/[ac]*/, '(\0)')
> > # returns “(a)()b(c)()”, really “(ϵa)(ϵ)b(ϵc)(ϵ)”
> 
> Same thing with Ruby: there's a current position pointer, keeping
> track of the current match.
> 
> > And the Python way:
> > 
> > import re
> > print re.sub(re.compile('(a*)'), '(\\1)', 'abc')
> > # returns “(a)b(c)”, really “(ϵaϵ)b(ϵcϵ)”
> 
> With Python, re.sub() "return[s] the string obtained by replacing
> the leftmost non-overlapping occurrences of pattern in string by the
> replacement repl".  It's the same thing, except for an optimisation:
> "empty matches are included in the result unless they touch the
> beginning of another match".
> 
> > (Note that adding “$” to the patterns doesn’t change anything.)
> > 
> > Now, VimL works in the Perl way, except that “*” includes the empty
> > string if it is the last one in the string:
> > 
> > echo substitute('abc', '[ac]*', '(\0)', 'g')
> > " returns “(a)()b(c)”, really “(ϵa)(ϵ)b(ϵcϵ)”
> 
> Again the same thing, except the optimisation above is applied only
> at the end of the string.

Yes. My question simply was: is it consistent to optimize only at the
end?

> > As far as I’m concerned, I find the Perl way quite counter-intuitive,
> > but what I’m interested in here is whether VimL is consistent or not.
> > I.e., shouldn’t it work clearly one way or the other?
> 
> You came up with the concept of "ϵ", you fix its limitations. :)

The “metaphysics of empty substrings”, the “concept of ϵ”... please, I
know I’m French, but that doesn’t mean I subscribe to French Theory! :)

> My conclusion to the above comparison is that Vim should apply the
> same optimisation in full, that is, kill the empty matches that touch
> the beginning of another match.  As far as I can tell, that would be
> safe for both the old and the new regexp engines.

I prefer it that way too. But I’d prefer no optimization rather than
conditional optimization, as is the case now.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Dealing with empty strings in regexp.

2013-06-18 Thread Paul Isambert
Erik Christiansen  a écrit:
> On 18.06.13 14:51, Paul Isambert wrote:
> > The “*” operator should be banned, then!
> 
> Does the problem with matching empty strings arise from using "*" when
> "+" should be used instead? You are presumably aware that¹:
> 
> * = 0 or more of the preceding atom.
> + = 1 or more of the preceding atom.
> 
> Thus "(a|b)+" means one or more a or b characters, and cannot match the
> empty string. Use "*" instead, and you've instructed it to also match "".

I’ve no problem with the empty string in itself. Rather, my original
question was to know where there was an empty string, and whether VimL
follows Perl or Python in that respect. Of course I use “+” when
necessary.

> There are many regex dialects - enough to fill a fat O'Reilly book, and
> enough to make anyone's head hurt. One way to minimise the confusion is
> to cultivate fluency in one dialect, and eschew the others.
> 
> Having long ago found posix BREs annoyingly full of superfluous
> backslashes, I've settled for the more concise and powerful posix EREs.
> Also, "man 7 regex" agrees that BREs are obsolete. (To get away from
> obsolete regexes in vim, prefix regexes with "\v". That is a good
> approximation of posix EREs, and so is consistent with many *nix
> utilities, so you can effortlessly switch from awk, bash, egrep,
> procmail, etc, etc, to vim with "\v".)

Mapping “/” to “/\v” (and, slightly more difficult, “:s/” to “:s/\v”)
is something I’ve thought abouth doing many times but have never done,
for some reason. I wish there were a “verymagic” option by default, I
would have turned it on a long time ago.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Dealing with empty strings in regexp.

2013-06-18 Thread Paul Isambert
John Little  a écrit:
> On Tuesday, June 18, 2013 11:19:43 PM UTC+12, Paul Isambert wrote:
> 
> > I.e., shouldn’t it work clearly one way or the other? 
> 
> I don't understand this "interspersed empty substrings" way of
> looking at regexes; I suspect that it doesn't make sense some of the
> time, and is not useful, but my suspicions may obviously stem from my
> incomprehension.

The empty substrings are only a means to account for the difference
between Perl-like and Python-like languages; it is interesting only
inasmuch as it achieves that, and shouldn’t be extended to understand
regexps any further. (Dirk Laurie formalizes that with open/closed
intervals here: http://lua-users.org/lists/lua-l/2013-04/msg00869.html.)

> A pattern like [ac]* on its own matches everywhere; so vim does the
> substitution everywhere.  Why is that not intuitive?  Anyway, as I see
> it, vim is consistent.

The issue is what “everywhere” means. Perl-like languages include
“just after a successful match”, hence “(a)()b(c)()”, Python-like
ones do not, hence “(a)b(c)”. The presumed inconsistency in VimL is
that it includes “just after a successful match”, unless we’re at the
end of the string, hence “(a)()b(c)”.

> Doing substitutions with a pattern that matches the empty string is
> not useful, in real editing tasks it's not what is wanted.  One is
> always trying to match *something*.

The “*” operator should be banned, then!

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Dealing with empty strings in regexp.

2013-06-18 Thread Paul Isambert
Sorry, this

> print re.sub(re.compile('(a*)'), '(\\1)', 'abc')

should be

print re.sub(re.compile('([ac]*)'), '(\\1)', 'abc')

Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Dealing with empty strings in regexp.

2013-06-18 Thread Paul Isambert
Hello all,

The following issue has been recently discussed on the Lua mailing list:
http://lua-users.org/lists/lua-l/2013-04/msg00812.html

(It has also been independantly raised on the LuaTeX list:
http://tug.org/pipermail/luatex/2013-June/004418.html)

If I understand correctly, any string can be represented with
interspersed empty substrings. E.g. “abc” is really “ϵaϵbϵcϵ”, where
“ϵ” is the empty string. Now, there seems to be two ways to deal with
those empty strings in regexps, especially regarding the “*” operator:

- The Perl way: “X*” matches as many “X” as possible, and does not
include the following empty string.
- The Python (or sed) way: “X*” matches as many “X” as possible, and
includes the following empty string.

Starting empty strings are always included. So, the Perl way gives (I
use Ruby, since I can’t speak Perl):

puts 'abc'.gsub(/[ac]*/, '(\0)')
# returns “(a)()b(c)()”, really “(ϵa)(ϵ)b(ϵc)(ϵ)”

And the Python way:

import re
print re.sub(re.compile('(a*)'), '(\\1)', 'abc')
# returns “(a)b(c)”, really “(ϵaϵ)b(ϵcϵ)”

(Note that adding “$” to the patterns doesn’t change anything.)

Now, VimL works in the Perl way, except that “*” includes the empty
string if it is the last one in the string:

echo substitute('abc', '[ac]*', '(\0)', 'g')
" returns “(a)()b(c)”, really “(ϵa)(ϵ)b(ϵcϵ)”

As far as I’m concerned, I find the Perl way quite counter-intuitive,
but what I’m interested in here is whether VimL is consistent or not.
I.e., shouldn’t it work clearly one way or the other?

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




  1   2   >