enhancing hlsearch
Is it possible to display (highlight) matches for /Word simultaneously in 3 different colors: 1. Word .. hlsearch 2. \Word\ .. hlsearchword 3. (?i)word .. hlsearchicase how hard would it be? I don't want to use script to it. thanks, mohsin.
Re: enhancing hlsearch
Mohsin wrote: Is it possible to display (highlight) matches for /Word simultaneously in 3 different colors: 1. Word .. hlsearch 2. \Word\ .. hlsearchword 3. (?i)word .. hlsearchicase how hard would it be? I don't want to use script to it. thanks, mohsin. Maybe you can do the following (untested): :map Bslash/ :match DiffAdd /BslashltC-R/Bslashgt/CR :map Bslash? :2match DiffChange /BslashcC-R//CR - Search normally for case 1. - Hit \/ to highlight the latest search in DiffAdd colours (by default in gvim: black on pale cyan) but only when present as a full word (case 2). - Hit \? to highlight the latest search in DiffChange highlight (black on pale magenta) regardless of case (case 3). - Hit \/ or \? again to update the highlights. Type :match none or :2match none to clear them. - Change the highlight group names if you want different colours. If, to you, this is already script, then you would need to hack the C source to get the desired result without script; but I wouldn't recommend it for something this trivial, which can be accomplished by a couple of mappings or (in a less obvious way) by using self-modifying mappings (map / to change the way we search and, in the mapping, cmap CR to both finalize the first mapping and unmap the second one...). Best regards, Tony.
Re: enhancing hlsearch
Mohsin wrote: Mechelynck, It has to be done with one mapping, the reason being *simultaneous* display, since sometimes the same word is with wrong case, should be immediately visible without having to make a mental switch to find it. I will try using with the syntax/highlight mappings. thanks, mohsin. Well, I won't give you an answer, because I'm too liable to stumble while writing it, but here is how it can be done: - Make a permanent mapping for / and ?. Each of them should, as part of the {rhs}, issue a cmap for CR (see below), and map the start of the search command, until but not including the start of the search pattern. - The cmap should not only finalize the search command but also issue :match and :2match with the variable part represented by C-R/ (Ctrl-R slash), and finally it should also unmap itself (and the next mapping) so the next use of Enter (or Esc) in command mode should not invoke these special cmaps. - If you want completeness, the maps for / and ? should also create a temporary cmap for Esc to cancel the search, and also unmap itself and the cmap for CR. I think it is doable, but it's not my province really. Some other Vim old-timers are much more versed than I in the creation of that kind of self-undoing mappings. Best regards, Tony.
Re: enhancing hlsearch
On 12/6/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: I think it is doable, but it's not my province really. Some other Vim old-timers are much more versed than I in the creation of that kind of self-undoing mappings. It can probably be simplified by mapping CR in command mode and check if getcmdtype() is '/' or '?' and, if so, call :match as appropriate. However, there's no good way of doing this type of highlighting while in 'incsearch' mode (i.e., while typing the pattern). Anyway, here's something I cooked up for you 'incsearch' users that actually thought this was sort of a neat idea, i.e., being able to quickly toggle between the word anywhere in the buffer, the complete word, and the case insensitive word. It definitely needs work to deal with anything but trivial patterns, e.g., only wrap the word under the cursor, but you probably only want to do this for simple, word-type patterns. cmap C-I C-\eSIDtoggle_word_style()CR let s:word_types = [ \ [ '^\\\|\\$', , 'g', '\c', ], \ [ '^\\c', , , , ], \ [ '^', , , '\', '\' ] \ ] function! s:toggle_word_style() let line = getcmdline() let type = getcmdtype() if type != '/' type != '?' return line endif for word_type in s:word_types if line =~ word_type[0] let line = word_type[3] . \ substitute(line, word_type[0], word_type[1], word_type[2]) . \ word_type[4] call setcmdpos(len(line) + 1) return line endif endfor return line endfunction Actually sort of neat, although it's not what Mohsin wants. nikolai
^ vs 0 vs Home vs |
Hello Vim Developers, Here's what the docs say: === *^* ^ To the first non-blank character of the line. |exclusive| motion. *0* 0 To the first character of the line. |exclusive| motion. When moving up or down, stay in same screen column (if possible). *Home* *kHome* Home To the first character of the line. |exclusive| motion. When moving up or down, stay in same text column (if possible). Works like 1|, which differs from 0 when the line starts with a Tab. {not in Vi} *bar* | To screen column [count] in the current line. |exclusive| motion. === (1) The sentence starting with When moving (in the help for both '0' and 'Home' appears to also belong with the help for '^'. (2) The sentence starting with Works like (in the help for 'Home') does not appear to be correct. 'Home' appears to work like '0'. The movement is just like '1|' (which is equivalent to '|') except for the behavior of moving up or down. (3) '0' and 'Home' appear to be identical. Does anyone see a difference? -- Best regards, Bill
Re: enhancing hlsearch
On 12/7/06, Nikolai Weibull [EMAIL PROTECTED] wrote: On 12/6/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: I think it is doable, but it's not my province really. Some other Vim old-timers are much more versed than I in the creation of that kind of self-undoing mappings. It can probably be simplified by mapping CR in command mode and check if getcmdtype() is '/' or '?' and, if so, call :match as appropriate. Hm, you of course need to know how you got /into/ search mode, so that you only do this at the appropriate times. Setting a variable and checking for it would work, but you have to make sure to unset it if the command line is abandoned as well. We need CmdLineEnter/CmdLineLeave and v:cmdexecuted or some such, so that we can tell if the line was executed or not. Or perhaps even better: CmdLineEnter/CmdLineLeave/CmdLineExecutePre/CmdLineExecutePost. With the *Pre autocmd one can perhaps change the command line in some way before executing it. With *Post one can do stuff after it, like :matching. *Leave would be called when it is abandoned, although perhaps the name suggests other cases as well? Anyway, good night. nikolai
Two minor requests for the TODO list
Hello All, I've found two tasks that are done in vim scripts routinely and it would be nice to streamline them: Here's the first one: If some variable isn't set yet, then set it to a default value. The code always looks something like this: if !exists(g:MyScriptSetting) let g:MyScriptSetting = default_value endif To make this easier, I would love to see is the vim 7.0 get() function expanded to handle regular variables. The get() function is currently defined this way: get({list}, {idx} [, {default}]) Get item {idx} from List {list}. When this item is not available return {default}. Return zero when {default} is omitted. get({dict}, {key} [, {default}]) Get item with key {key} from Dictionary {dict}. When this item is not available return {default}. Return zero when {default} is omitted. How about adding this: get({string} [, {default}]) Get value from variable {string}. When this variable does not exist, return {default}. Return zero when {default} is omitted. The second one is: Make these vim settings during this function call only, so save the current values first, set them to what I want, then restore them before leaving. There is an item on the TODO list to make this easier: :with option=value | command: temporarily set an option value and restore it after the command has executed. The problem is that this could get ugly if many options need to be changed, and those settings have to be made *every time* the routine is called. Typically, the function only works correctly when those settings are set. It would be nice to see something like the current setlocal command instead: :sett[emp] ... Like :set but set only the value local to the current function. The value is restored to the value set before the current function was called when the function ends. Not valid outside of a function. What do you think? David
Re: ^ vs 0 vs Home vs |
Bill McCarthy wrote: Hello Vim Developers, Here's what the docs say: === *^* ^ To the first non-blank character of the line. |exclusive| motion. *0* 0 To the first character of the line. |exclusive| motion. When moving up or down, stay in same screen column (if possible). *Home* *kHome* Home To the first character of the line. |exclusive| motion. When moving up or down, stay in same text column (if possible). Works like 1|, which differs from 0 when the line starts with a Tab. {not in Vi} *bar* | To screen column [count] in the current line. |exclusive| motion. === (1) The sentence starting with When moving (in the help for both '0' and 'Home' appears to also belong with the help for '^'. (2) The sentence starting with Works like (in the help for 'Home') does not appear to be correct. 'Home' appears to work like '0'. The movement is just like '1|' (which is equivalent to '|') except for the behavior of moving up or down. (3) '0' and 'Home' appear to be identical. Does anyone see a difference? (1) After ^ followed by j or k I see the cursor staying (as far as possible) in the same _screen_ column regardless of preceding hard tabs. When this would place the cursor halfway a tab, the cursor will shift temporarily, and come back if you go on hitting j or k. This is normal behaviour when moving up or down, so it doesn't need to be mentioned. (2) Here, Home works like 1| (not like 0), see below. (3) Yes I do. Notice the one mentions the same _text_ column and the other the same _screen_ column. Hit 0 on a line starting with a hard tab, then j : Vim will try to keep the cursor in column 8 (except, of course, on lines shorter than 1 tab or 8 other characters). After Home or 1| it would try to keep the cursor in column 1 (if possible: when the first character on a line is a hard tab the cursor will move temporarily to column 8). I have *motion.txt*For Vim version 7.0. Last change: 2006 Jun 18 [...] (next line is #170) *0* 0 To the first character of the line. |exclusive| motion. When moving up or down, stay in same screen column (if possible). *Home* *kHome* HomeTo the first character of the line. |exclusive| motion. When moving up or down, stay in same text column (if possible). Works like 1|, which differs from 0 when the line starts with a Tab. {not in Vi} *^* ^ To the first non-blank character of the line. |exclusive| motion. [...] (next line is #235) *bar* | To screen column [count] in the current line. |exclusive| motion. and VIM - Vi IMproved 7.0 (2006 May 7, compiled Dec 5 2006 22:18:11) Included patches: 1-178 Compiled by [EMAIL PROTECTED] Huge version with GTK2-GNOME GUI. Features included (+) or not (-): [etc.] Best regards, Tony.
Re: Two minor requests for the TODO list
Hello, * On Wed, Dec 06, 2006 at 04:11:24PM -0800, Eggum, DavidX S [EMAIL PROTECTED] wrote: I've found two tasks that are done in vim scripts routinely and it would be nice to streamline them: Here's the first one: If some variable isn't set yet, then set it to a default value. The code always looks something like this: if !exists(g:MyScriptSetting) let g:MyScriptSetting = default_value endif How about adding this: [...] get({string} [, {default}]) value from variable {string}. When this variable does not exist, return {default}. Return zero when {default} is omitted. Well, I've started to refactor my plugins to isolate a similar similar function in an autoload plugin. My function also takes another argument: a list of scopes in which the variable can be defined. Function: lh#option#Get({name}, {default} [, {scope}]) @return b:{name} if it exists, of g:{name} if it exists, or {default} otherwise The order of the variables checked can be specified through the optional argument {scope} Then, in my script, I systematically call this function, and never directly use a variable. Indeed, I have no way of knowing if the variable is b:goo, g:foo, w:foo or even s:foo. The support of non global options is very important to me as I mainly maintain ftplugins, and work on the files from various projects that don't share the same configuration (like different targets used in the makefiles). A typical use is: let l:foo = lh#option#Get('foo', s:foo_default, 'wbg') Which will return the value of the first variable found among w:foo, b:foo and g:foo. Or s:foo_default otherwise. So far, {default} is not optional as I have both integer and string variables, and I can't easily tell the exact type of the variable. Having such function as builtin would be nice. I can easily cope without it. But still, it would be nice. -- Luc Hermitte http://hermitte.free.fr/vim/
Re: ^ vs 0 vs Home vs |
On Wed 6-Dec-06 6:24pm -0600, A.J.Mechelynck wrote: Bill McCarthy wrote: (3) '0' and 'Home' appear to be identical. Does anyone see a difference? (3) Yes I do. Notice the one mentions the same _text_ column and the other the same _screen_ column. Hit 0 on a line starting with a hard tab, then j : Vim will try to keep the cursor in column 8 (except, of course, on lines shorter than 1 tab or 8 other characters). After Home or 1| it would try to keep the cursor in column 1 (if possible: when the first character on a line is a hard tab the cursor will move temporarily to column 8). Thanks Tony, that clears it up nicely. Somehow I just wasn't seeing the difference - I certainly see it now! -- Best regards, Bill
Re: Do a grep -r without match .svn directory ?
KLEIN Stéphane wrote: Hi, In vim, I would like do a :grep -r but don't match .svn directory. Grep or vim have this feature ? You may, possibly, be interested in 'ack': http://petdance.com/ack/ ack is a replacement for grep, aimed at programmers with large trees of heterogeneous source code. Top 10 reasons to use ack instead of grep. 1. Searches recursively through directories by default, while ignoring .svn, CVS and other VCS directories. * Which would you rather type? $ grep pattern $(find . | grep -v .svn) $ ack pattern 2. ack ignores most of the crap you don't want to search * VCS directories * blib, the Perl build directory * backup files like foo~ * binary files 3. Lets you specify file types to search, as in --perl or --nohtml. * Which would you rather type? $ grep pattern $(find . -name '*.pl' -or -name '*.pm' -or -name '*.pod' | grep -v .svn) $ ack --perl pattern -- John O'Shea Wordbank Limited 33 Charlotte Street, London W1T 1RR Direct line: +44 (0) 20 7903 8829 Fax: +44 (0) 20 7903 http://www.wordbank.com/
Re: using the convert 2 html utility without opening the file
Thanks for the scripts.. I tried running it on AIX and got the following error message.. vim2html3.pl C++/*.cpp Don't know (yet) how to fetch variables from Vim! at VimDetect.pm line 388. --- Luc Hermitte [EMAIL PROTECTED] wrote: Hello, * On Sat, Dec 02, 2006 at 02:43:54AM -0800, Muddassirali Mirzani [EMAIL PROTECTED] wrote: i'd like to know how can use the vim convert to html utility without opening the file.. I have a bunch of files i need in html format with the syntax highlighted and would like to write a script to do it. There is a perl script that does that. Sometimes ago, I forked it to fix a few things, and suit my needs. - http://hermitte.free.fr/vim/ressources/tools +- vim2html3.pl (the main script) +- VimDetect.pm (perl module the script depends on) HTH, -- Luc Hermitte http://hermitte.free.fr/vim/ Need a quick answer? Get one in minutes from people who know. Ask your question on www.Answers.yahoo.com
Re: sourcing
On Tue 5-Dec-06 1:19pm -0600, C.G.Senthilkumar. wrote: On Tue, 5 Dec 2006, Alan G Isaac wrote: On Mon, 4 Dec 2006, Bill McCarthy apparently wrote: Instead of using an autocmd, you could place those maps in a file called tex.vim in your local ftplugin directory. Place this single line in such a file: map buffer c-a :echo 'It worked!'CR I did this. It worked. I didn't have a problem. One thing I meant to mention in a recent post is that you should use your local after/ftplugin/ instead of your local ftplugin/. In is possible for a map from $VIMRUNTIME to overwrite your maps in local ftplugin/. -- Best regards, Bill
How to replace cp1252 characters
Hi, I would like to know how I can replace cp1252 characters with other strings. If I open a file in vim some charcters are displayed like 96. The file which contains these characters is encoded with cp1252. Any ideas? Iconv fails with illegal input sequence at position 33152487. The file I am trying to convert is a MySQL dump. Cheers, Andreas -- Seit 31958000 Sekunden. Since 31958000 seconds. Fingerprint: C657 2759 FD22 7612 3238 99C1 1BEB 20D4 7574 A959
Re: How to replace cp1252 characters
On Wed, Dec 06, 2006 at 12:54:23PM +0100, Andreas Otto wrote: I would like to know how I can replace cp1252 characters with other strings. If I open a file in vim some charcters are displayed like 96. The file which contains these characters is encoded with cp1252. Iconv fails with illegal input sequence at position 33152487. Well, if iconv fails, then it means that those characters are not from CP1252. Or maybe you've provided wrong options to iconv :) -- Minds, like parachutes, function best when open
Re: How to replace cp1252 characters
Hi Andrei, On Wednesday, 6. December 2006 13:37, Andrei A. Voropaev wrote: Well, if iconv fails, then it means that those characters are not from CP1252. Or maybe you've provided wrong options to iconv :) The iconv command used is: iconv -f CP1252 -t UTF-8 latin1.sql utf8.sql It looks like there are character sequenzes in the database which iconv cannot deal with for conversion. Since iconv does not help here I thought it might be possible to replace the characters which are displayed with the marker hex, e. g. 96 which is a dash symbol. However searching in vim for /96 doesn't find the pattern, which makes me think that what I see in the terminal might be something different inside vim. I just don't know what to look for. Cheers, Andreas -- Seit 31962195 Sekunden. Since 31962195 seconds. Fingerprint: C657 2759 FD22 7612 3238 99C1 1BEB 20D4 7574 A959
Re: Do a grep -r without match .svn directory ?
On 12/4/06, KLEIN Stéphane [EMAIL PROTECTED] wrote: Hi, In vim, I would like do a :grep -r but don't match .svn directory. Grep or vim have this feature ? Have a look at http://www.pixelbeat.org/scripts/findrepo Pádraig.
Re: soft line breaks + limited width display?
Karsten Gerloff wrote: Hi, I'm currently writing a lot of text in vim that will later need to transfer to a word processor (OpenOffice 2.0 in this case). Since it makes reading easier, I want to make lines wrap at 66 chars; this has long worked fine with set textwidth=66 But this inserts hard line breaks (EOL), which I don't want to show up later in the word processor. No luck at vim.org. So I tried the vim FAQ at http://vimdoc.sourceforge.net/vimfaq.html and it told me to put the following into my .vimrc: :set wrap :set linebreak :set textwidth=0 :set showbreak= which works nicely as far as the EOLs are concerned. But the lines still run over the whole width of the screen. Setting textwidth=66 re-introduces the unwanted EOLs. Any hints? (yes, I know that this is wanting to have my cake and eat it too -- but that's why I started using vim in the first place :-) Thanks, Karsten In gvim, and in some but not all console terminals, you can use :set wrap linebreak textwidth=0 columns=66 in order to place the right margin of the screen where you want the lines to break. Best regards, Tony.
Re: soft line breaks + limited width display?
On 06/12/06, Karsten Gerloff [EMAIL PROTECTED] wrote: Hi, I'm currently writing a lot of text in vim that will later need to transfer to a word processor (OpenOffice 2.0 in this case). Since it makes reading easier, I want to make lines wrap at 66 chars; this has long worked fine with set textwidth=66 But this inserts hard line breaks (EOL), which I don't want to show up later in the word processor. No luck at vim.org. So I tried the vim FAQ at http://vimdoc.sourceforge.net/vimfaq.html and it told me to put the following into my .vimrc: :set wrap :set linebreak :set textwidth=0 :set showbreak= which works nicely as far as the EOLs are concerned. But the lines still run over the whole width of the screen. Setting textwidth=66 re-introduces the unwanted EOLs. Any hints? I find that the easiest way is to set tw to whatever you want it to be, write the text and then (just before pasting into OpenOffice): :set tw=1 gggqG gg+G To reformat the text with long lines. Assuming formatoptions is set to something sensible, this works a treat. Hope that helps, Al
Re: Caps lock with keymap
Anatoli Sakhnik wrote: Hi, vim users! Some regular alphabet letters of many languages are placed on punctuation signs of the English keyboard. Let's suppose I use the keymap command to design desired keyboard layout. But then a little annoying oddity appears. When the caps lock is on, mapped letters on [;'\,./ ...] don't appear in upper case, as I expected. Obviously, this is due to that fact, that the caps lock doesn't influence on those keys in English layout. So, the question is, if there's a possibility to map keys with explicit caps lock value, say :loadkeymap ; ж caps_off CYRILLIC SMALL LETTER ZHE ; Ж caps_on CYRILLIC CAPITAL LETTER ZHE Thank you in advance! -- Anatoli Sakhnik. The functioning of the Caps Lock key is totally transparent to Vim, because vim uses cooked keyboard input. Vim doesn't get the Caps Lock keypress separately, it gets whatever character is assigned by your keyboard driver to whatever it was that you pressed. I use a different Russian keymap, based on the phonetic values of my letter keys, as follows: A Char-1040 CYRILLIC CAPITAL LETTER AH B Char-1041 CYRILLIC CAPITAL LETTER BEH V Char-1042 CYRILLIC CAPITAL LETTER VEH G Char-1043 CYRILLIC CAPITAL LETTER GHEH D Char-1044 CYRILLIC CAPITAL LETTER DEH E Char-1045 CYRILLIC CAPITAL LETTER YEH %O Char-1025 CYRILLIC CAPITAL LETTER YO %Z Char-1046 CYRILLIC CAPITAL LETTER ZHEH Z Char-1047 CYRILLIC CAPITAL LETTER ZEH I Char-1048 CYRILLIC CAPITAL LETTER I J Char-1049 CYRILLIC CAPITAL LETTER I KRATKOYEH [...] a Char-1072 CYRILLIC SMALL LETTER AH b Char-1073 CYRILLIC SMALL LETTER BEH v Char-1074 CYRILLIC SMALL LETTER VEH g Char-1075 CYRILLIC SMALL LETTER GHEH d Char-1076 CYRILLIC SMALL LETTER DEH e Char-1077 CYRILLIC SMALL LETTER YEH %o Char-1105 CYRILLIC SMALL LETTER YO %z Char-1078 CYRILLIC SMALL LETTER ZHEH z Char-1079 CYRILLIC SMALL LETTER ZEH i Char-1080 CYRILLIC SMALL LETTER I j Char-1081 CYRILLIC SMALL LETTER I KRATKOYEH [...] I seldom use Caps Lock, but since e.g. B and b are mapped respectively to Б and б, while most punctuation characters (except % and = ) are not remapped, it doesn't give me any problems. Всего хорошего, Тоня.
Re: Caps lock with keymap
Well, I see. The proposed solution is quite simple and reliable, but there's a little disadvantage. Using standard keyboard layout means that you can use 'ten-finger blind typing method'. So do I, that is why remapping keys one more time to customize layout is a game that isn't worth the candle (игра не стоит свеч). It's simpler either not to use the caps lock at all, nor to accommodate to press the shift key every time I need to type capital letters Б, Ю, Ж, Є, Ґ, Х, Ї. Actually the latter manner also harms generic typing skills. You'll admit that in the ideal word a human wouldn't have to tune to the pitch of a machine, won't you? -- Anatoli Sakhnik. On 06/12/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: Anatoli Sakhnik wrote: The functioning of the Caps Lock key is totally transparent to Vim, because vim uses cooked keyboard input. Vim doesn't get the Caps Lock keypress separately, it gets whatever character is assigned by your keyboard driver to whatever it was that you pressed. I use a different Russian keymap, based on the phonetic values of my letter keys, as follows: [...] I seldom use Caps Lock, but since e.g. B and b are mapped respectively to Б and б, while most punctuation characters (except % and = ) are not remapped, it doesn't give me any problems. Всего хорошего, Тоня.
Re: How to replace cp1252 characters
Andreas Otto wrote: Hi Andrei, On Wednesday, 6. December 2006 13:37, Andrei A. Voropaev wrote: Well, if iconv fails, then it means that those characters are not from CP1252. Or maybe you've provided wrong options to iconv :) The iconv command used is: iconv -f CP1252 -t UTF-8 latin1.sql utf8.sql It looks like there are character sequenzes in the database which iconv cannot deal with for conversion. Since iconv does not help here I thought it might be possible to replace the characters which are displayed with the marker hex, e. g. 96 which is a dash symbol. However searching in vim for /96 doesn't find the pattern, which makes me think that what I see in the terminal might be something different inside vim. I just don't know what to look for. Cheers, Andreas When Vim displays 96 in blue, it isn't less-than, nine, six, greater-than (4 bytes) but 0x96 (one byte). You can search for it by hitting (in Normal mode) slash, Ctrl-V, x-for-X-Ray, nine, six, Enter. What you'll see on the command-line may be one of /96 /~V or something else but it should find your 96 bytes. See :help i_CTRL-V_digit which applies in both Insert/Replace and Command-line modes. Best regards, Tony.
Re[2]: Bug? (Re: local map and vmap not cleared when buffer deleted)
On Wed, 6 Dec 2006, Bill McCarthy apparently wrote: I repeated this starting with a file name file: gvim -u NONE -i NONE -N file Here I see what appears to be a cosmetic bug. I am seeing: i @ buffer v @ I am using Vim 7.0. Starting with gvim -u NONE -i NONE -N file I see that maps and vmaps that are local to the buffer are not cleared when the buffer is deleted (:bd). Peter is also reporting this behavior. Are you saying you see something else? If so, what is your version? Thank you, Alan Isaac
Re: soft line breaks + limited width display?
On Wed, 6 Dec 2006, Karsten Gerloff apparently wrote: I'm currently writing a lot of text in vim that will later need to transfer to a word processor (OpenOffice 2.0 in this case). OT: If you use reStructuredText you can use rst2html and have OpenOffice open the HTML document. (Alternatively, there is also an OpenOffice writer in the docutils sandbox, but I have not used it.) Cheers, Alan Isaac
Strange O-behaviour
Hello, I'm using vim excessively for developing in Progress 4GL. Sometimes, I stumble upon an odd behaviour and don't know if it's due to a setting in the syntax file (progress.vim) or due to a problem in vim itself. Finally, I have a reproducable for one of those oddities. In the attached file, I have the cursor on line 52. I use O from the command mode to insert a new line below. The cursor stands in column 37. I would have expected it to stand in column 5, like the beginning of the line before. For proper reproduction, use the Progress syntax file included in vim. I am using gvim 7 for Windows 32 (7th of May 2006). Any ideas? Thanks, Thomas -- GPG-Key: tengelke.de/thomas_michael_engelke.asc te-kor84965.p Description: Binary data
Re: Caps lock with keymap
Anatoli Sakhnik wrote: Well, I see. The proposed solution is quite simple and reliable, but there's a little disadvantage. Using standard keyboard layout means that you can use 'ten-finger blind typing method'. So do I, that is You can, maybe. I never learnt whatever keyboard layout is standard in Russia. In fact, my own keyboard has a Belgian AZERTY layout. why remapping keys one more time to customize layout is a game that isn't worth the candle (игра не стоит свеч). It's simpler either not We use that same phrase in French too: le jeu n'en vaut pas la chandelle. to use the caps lock at all, nor to accommodate to press the shift key every time I need to type capital letters Б, Ю, Ж, Є, Ґ, Х, Ї. Actually the latter manner also harms generic typing skills. If you can afford never to use Caps Lock, that should do it. I don't know why someone decided someday that Caps Lock should apply to letters but not to other keys: on typewriters, of course, Caps Lock applies to everything. You'll admit that in the ideal word a human wouldn't have to tune to the pitch of a machine, won't you? -- Anatoli Sakhnik. We don't live in an ideal world, so we have to cope with whatever tools we got. Best regards, Tony.
Wron Block-Insert (p)
Hello, I have found an oddity in vim which I'm not sure is a bug and/or known. I have yanked a visual block of some lines of code and try to put it in somewhere else. There a strange effect happens: depending on if there is either a character or a beginning of line left besides the cursor, paste via p works different. When I have a BOL or a char to the left, it gets pasted and uses the cursor position as upper left corner. When there's no char/BOL, it uses the char right beside the cursor position as upper left corner. It's easily reproducable by just moving the cursor one position to the right and paste the block again. Anybody that can reproduce the problem and/or shed some light on it? Note: Shift+P works as a workaround. Regards, Thomas -- GPG-Key: tengelke.de/thomas_michael_engelke.asc
Re: Strange O-behaviour
On 2006-12-06, Thomas Michael Engelke [EMAIL PROTECTED] wrote: Hello, I'm using vim excessively for developing in Progress 4GL. Sometimes, I stumble upon an odd behaviour and don't know if it's due to a setting in the syntax file (progress.vim) or due to a problem in vim itself. Finally, I have a reproducable for one of those oddities. In the attached file, I have the cursor on line 52. I use O from the command mode to insert a new line below. The cursor stands in column 37. I would have expected it to stand in column 5, like the beginning of the line before. O will insert a new line _above_ the current line; o will insert a new line below. For proper reproduction, use the Progress syntax file included in vim. I am using gvim 7 for Windows 32 (7th of May 2006). Any ideas? You have 'cindent' set. There is no ftplugin/progress.vim or indent/progress.vim in the standard vim distribution, and syntax/progress.vim doesn't set 'cindent', so you must have set it in your _vimrc. You can see where it was set by executing :verbose set cindent? Just make sure you have 'nocindent' set when you edit progress files. Since you seem to have filetype detection set, I would just delete the (assumed) set cindent command from your _vimrc and let vim automatically set 'cindent' as needed. HTH, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Wireless Division | Spokane, Washington, USA
Re: Wron Block-Insert (p)
Thomas Michael Engelke wrote: Hello, I have found an oddity in vim which I'm not sure is a bug and/or known. I have yanked a visual block of some lines of code and try to put it in somewhere else. There a strange effect happens: depending on if there is either a character or a beginning of line left besides the cursor, paste via p works different. When I have a BOL or a char to the left, it gets pasted and uses the cursor position as upper left corner. When there's no char/BOL, it uses the char right beside the cursor position as upper left corner. It's easily reproducable by just moving the cursor one position to the right and paste the block again. Anybody that can reproduce the problem and/or shed some light on it? Note: Shift+P works as a workaround. Regards, Thomas I don't understand what you mean. p means put after cursor; P (shift-p) is put before. Depending on whether the selection to be pasted is characterwise, linewise or blockwise, the result will be different. Now let's assume it's blockwise, and that 'virtualedit' is off (e.g. empty). Using p inserts the selection after the cursor character, and after the character in the same column on successive lines. If some of the lines are shorter, spaces are inserted so that the block will be inserted as a rectangle. The exception is when the cursor is on an empty line: in that case there is no character at the cursor, and the block gets pasted after character zero, i.e., at the start of the current line and of successive lines after that. I don't see any problem. What is it that you don't understand? Best regards, Tony.
Re: Wron Block-Insert (p)
2006/12/6, A.J.Mechelynck [EMAIL PROTECTED]: Thomas Michael Engelke wrote: Hello, I have found an oddity in vim which I'm not sure is a bug and/or known. I have yanked a visual block of some lines of code and try to put it in somewhere else. There a strange effect happens: depending on if there is either a character or a beginning of line left besides the cursor, paste via p works different. When I have a BOL or a char to the left, it gets pasted and uses the cursor position as upper left corner. When there's no char/BOL, it uses the char right beside the cursor position as upper left corner. It's easily reproducable by just moving the cursor one position to the right and paste the block again. Anybody that can reproduce the problem and/or shed some light on it? Note: Shift+P works as a workaround. Regards, Thomas I don't understand what you mean. p means put after cursor; P (shift-p) is put before. Depending on whether the selection to be pasted is characterwise, linewise or blockwise, the result will be different. Now let's assume it's blockwise, and that 'virtualedit' is off (e.g. empty). Using p inserts the selection after the cursor character, and after the character in the same column on successive lines. If some of the lines are shorter, spaces are inserted so that the block will be inserted as a rectangle. The exception is when the cursor is on an empty line: in that case there is no character at the cursor, and the block gets pasted after character zero, i.e., at the start of the current line and of successive lines after that. I don't see any problem. What is it that you don't understand? Hello, I'll try to elaborate here. Sometimes, I have to align statements in a large assign-statement like this: assign var1 = var2 = . I block-yank a block containing, left-upper, v of var1, right-lower 2 of var2, to insert both variable names after the equal-signs. So my cursor stands in the spot behind the equals on the first row. I press p. This is what I get: assign var1 =var1 var2 =var2 . I think: Oh, it gets pasted from exactly where my cursor is. I must be standing wrong. I undo the change, go 1 spot to the right and press p again. I end up with this: assign var1 = var1 var2 = var2 . Note that there are 2 spaces after each equal-sign. that is what I do not understand. Doing the same action, modified by 1 column to the right, should paste the same, but all one spot to the right. Is that assumption wrong? Assuming that what you said hits the spot, p at the described spot should insert the block with only 1 space between the equal-sign and the first column of the block. Hope this clears it up. Regards, Thomas -- GPG-Key: tengelke.de/thomas_michael_engelke.asc
Re: Wron Block-Insert (p)
Thomas Michael Engelke wrote: 2006/12/6, A.J.Mechelynck [EMAIL PROTECTED]: Thomas Michael Engelke wrote: Hello, I have found an oddity in vim which I'm not sure is a bug and/or known. I have yanked a visual block of some lines of code and try to put it in somewhere else. There a strange effect happens: depending on if there is either a character or a beginning of line left besides the cursor, paste via p works different. When I have a BOL or a char to the left, it gets pasted and uses the cursor position as upper left corner. When there's no char/BOL, it uses the char right beside the cursor position as upper left corner. It's easily reproducable by just moving the cursor one position to the right and paste the block again. Anybody that can reproduce the problem and/or shed some light on it? Note: Shift+P works as a workaround. Regards, Thomas I don't understand what you mean. p means put after cursor; P (shift-p) is put before. Depending on whether the selection to be pasted is characterwise, linewise or blockwise, the result will be different. Now let's assume it's blockwise, and that 'virtualedit' is off (e.g. empty). Using p inserts the selection after the cursor character, and after the character in the same column on successive lines. If some of the lines are shorter, spaces are inserted so that the block will be inserted as a rectangle. The exception is when the cursor is on an empty line: in that case there is no character at the cursor, and the block gets pasted after character zero, i.e., at the start of the current line and of successive lines after that. I don't see any problem. What is it that you don't understand? Hello, I'll try to elaborate here. Sometimes, I have to align statements in a large assign-statement like this: assign var1 = var2 = . I block-yank a block containing, left-upper, v of var1, right-lower 2 of var2, to insert both variable names after the equal-signs. So my cursor stands in the spot behind the equals on the first row. I press p. This is what I get: assign var1 =var1 var2 =var2 . I think: Oh, it gets pasted from exactly where my cursor is. I must be standing wrong. I undo the change, go 1 spot to the right and press p again. I end up with this: assign var1 = var1 var2 = var2 . Note that there are 2 spaces after each equal-sign. that is what I do not understand. Doing the same action, modified by 1 column to the right, should paste the same, but all one spot to the right. Is that assumption wrong? Assuming that what you said hits the spot, p at the described spot should insert the block with only 1 space between the equal-sign and the first column of the block. Hope this clears it up. Regards, Thomas I don't see what you describe. Which version and patchlevel are you using? (as shown by the first 4 lines of the output of :version; see :help :redir about how to capture that output) I'm using: VIM - Vi IMproved 7.0 (2006 May 7, compiled Dec 5 2006 22:18:11) Included patches: 1-178 Compiled by [EMAIL PROTECTED] Huge version with GTK2-GNOME GUI. Features included (+) or not (-): [...] (The purpose of the 178 patches so far is summarized at http://ftp.vim.org/pub/vim/patches/7.0/README ) When I hit p with the cursor at the end of a line, the first line of the block is appended to the current line. If I undo, move the cursor one character left, and hit p again, then the last character of the current line (and only the last one) ends up after the block. Note that the cursor ends up on the first character of the pasted block, i.e., not where it was before the paste. Undo moves it back. The fact that the character at the cursor (before the paste) is or isn't a space changes nothing. Best regards, Tony.
Re: Bug? (Re: local map and vmap not cleared when buffer deleted)
On Wed 6-Dec-06 9:17am -0600, Alan G Isaac wrote: On Wed, 6 Dec 2006, Bill McCarthy apparently wrote: I repeated this starting with a file name file: gvim -u NONE -i NONE -N file Here I see what appears to be a cosmetic bug. I am seeing: i @ buffer v @ I am using Vim 7.0. Starting with gvim -u NONE -i NONE -N file I see that maps and vmaps that are local to the buffer are not cleared when the buffer is deleted (:bd). Peter is also reporting this behavior. Are you saying you see something else? If so, what is your version? I sure tried to say that :-) I'm running version 7.0 patch level 178. -- Best regards, Bill
Patched VIM 7.0 reboots Windows 2000 on forced write to read-only file (?)
Is anyone else seeing this problem? My Windows 2000 system reboots when I issue :w! to overwrite a read-only file. (I normally do this when I forget to mark a file writeable. I force the write and then mark it writeable with a function key mapped to :!attribspace-rspaceC-R%CR ) I am using VIM 7.0, compiled on Nov 7, 2006, with patches 1-161. I obtained this version of VIM from here: http://sourceforge.net/project/showfiles.php?group_id=43866package_id=39721 I was trying to install a non-Cream version of VIM with the latest patches. I followed the link from the Cream page, which points to non-Cream VIM installers: http://cream.sourceforge.net/download.html
Re: Patched VIM 7.0 reboots Windows 2000 on forced write to read-only file (?)
Further clarification -- I went to the Cream web page because the VIM Downloads page links there as a way of getting a fully patched version of VIM for the PC: http://www.vim.org/download.php#pc For the latest version with all patches included see Cream below. These versions are unofficial, but the number of downloads is high and the number of complaints is nil. On 12/6/06, Paul Stone [EMAIL PROTECTED] wrote: Is anyone else seeing this problem? My Windows 2000 system reboots when I issue :w! to overwrite a read-only file. (I normally do this when I forget to mark a file writeable. I force the write and then mark it writeable with a function key mapped to :!attribspace-rspaceC-R%CR ) I am using VIM 7.0, compiled on Nov 7, 2006, with patches 1-161. I obtained this version of VIM from here: http://sourceforge.net/project/showfiles.php?group_id=43866package_id=39721 I was trying to install a non-Cream version of VIM with the latest patches. I followed the link from the Cream page, which points to non-Cream VIM installers: http://cream.sourceforge.net/download.html
regular expression search and replace in normal mode
in command line mode i can run a search and replace which extracts part of a pattern and uses it in the output. is there any way to do this in normal mode? here is an example: command line search and replace: :s/\[\([0-9]*\)\]/a href=#n\1\/a[\1]/ of course, in normal mode i can search for /\[[0-9]*\] repeatedly with N, and examine each stop to see if the change should be done, but how do i suck out the guts of the target so as to stick them into the replacement? Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com
Re: Patched VIM 7.0 reboots Windows 2000 on forced write to read-only file (?)
On Wed, 6 Dec 2006, Paul Stone wrote: I went to the Cream web page because the VIM Downloads page links there as a way of getting a fully patched version of VIM for the PC Can this be installed over the previous Vim 7, or do I need to uninstall first? (Windows.) Thank you, Alan Isaac
Re: Patched VIM 7.0 reboots Windows 2000 on forced write to read-only file (?)
Paul Stone wrote: Further clarification -- I went to the Cream web page because the VIM Downloads page links there as a way of getting a fully patched version of VIM for the PC: http://www.vim.org/download.php#pc For the latest version with all patches included see Cream below. These versions are unofficial, but the number of downloads is high and the number of complaints is nil. Yes, AFAIK these are unofficial distributions of the official runtime files, packaged with executables compiled from the official patched sources, and an installer, different from the one Bram uses for his patchlevel-zero distributions for Windows but doing the same things to your Vim installation directory (C:\Program Files\vim/vim70 or similar), your registry, etc. The unofficial character of these (Steve Hall's) distributions results mainly IIUC from the fact that Bram has no (enforcement) control over how they are generated. What happens when you clear the readonly flag by using ATTRIB in a CMD.EXE Dos Box? The result ought to be the same as when you issue the :!attrib command in Vim. Best regards, Tony.
Re: Patched VIM 7.0 reboots Windows 2000 on forced write to read-only file (?)
Alan Isaac wrote: On Wed, 6 Dec 2006, Paul Stone wrote: I went to the Cream web page because the VIM Downloads page links there as a way of getting a fully patched version of VIM for the PC Can this be installed over the previous Vim 7, or do I need to uninstall first? (Windows.) Thank you, Alan Isaac I think the installer uninstalls a previous patchlevel if it finds one. When I was on Windows, I used to install every patchlevel on top of the previous one. In the rare case that a runtime file name becomes obsolete (as happened when plugin/netrw.vim was replaced by plugin/netrwPlugin.vim plus other netrw*.vim scripts in other subdirectories of $VIMRUNTIME) you may need to make sure that the obsolete file is deleted. Best regards, Tony.
Re: regular expression search and replace in normal mode
in command line mode i can run a search and replace which extracts part of a pattern and uses it in the output. is there any way to do this in normal mode? here is an example: command line search and replace: :s/\[\([0-9]*\)\]/a href=#n\1\/a[\1]/ of course, in normal mode i can search for /\[[0-9]*\] repeatedly with N, and examine each stop to see if the change should be done, but how do i suck out the guts of the target so as to stick them into the replacement? It sounds like you want to do search and replace with confirmation: :%s/foo/bar/gc which will visit each foo match in your file and prompt you regarding whether you want to replace it with bar. If the cursor is hard to spot, you can set :set scrolloff= which will keep the cursor centered in the screen. As an alternative, you can use macros (x in this case): qxci[a href=#n^R/a[^R]^[x2F[x (where ^R is control+R and ^[ is escape) and then @x the first time and use @@ subsequent times. Just a few ideas, -tim
Re: Patched VIM 7.0 reboots Windows 2000 on forced write to read-only file (?)
On 12/6/06, A.J.Mechelynck [EMAIL PROTECTED] wrote: Paul Stone wrote: Further clarification -- I went to the Cream web page because the VIM Downloads page links there as a way of getting a fully patched version of VIM for the PC: http://www.vim.org/download.php#pc For the latest version with all patches included see Cream below. These versions are unofficial, but the number of downloads is high and the number of complaints is nil. Yes, AFAIK these are unofficial distributions of the official runtime files, packaged with executables compiled from the official patched sources, and an installer, different from the one Bram uses for his patchlevel-zero distributions for Windows but doing the same things to your Vim installation directory (C:\Program Files\vim/vim70 or similar), your registry, etc. The unofficial character of these (Steve Hall's) distributions results mainly IIUC from the fact that Bram has no (enforcement) control over how they are generated. What happens when you clear the readonly flag by using ATTRIB in a CMD.EXE Dos Box? The result ought to be the same as when you issue the :!attrib command in Vim. Best regards, Tony. Hi Tony, :!attrib works fine for me. :w! causes the reboot (with read-only file). Normally, :w! should overwrite a read-only file. Paul Stone
Re: your best vim scripting tip
On Tue 5-Dec-06 10:29pm -0600, Sibin P. Thomas wrote: While we are at the subject of tips for budding Vim scripters - I had created this mapping -- nmap com ^:if search('\/\*.*\*\/','c',line(.))!=0CR :.s/\/\*\(.*\)\*\//\1/gCR :elseCR :.s/\(\s*\)\(.*\)\(\s*\)/\1\/\*\2\*\/\3/gCR :endifCR :nohCR this command basically toggles C-style commenting on a line i.e. if the line wasn't commented it comments out the entire line and vice-versa. I spent an intense hour of exploring the help pages and plenty of effort in trial and error before I could reach the 'Eureka' moment. The first thing I would do is ask myself whether the approach is adequate. For example, how does it handle common lines of code such as: /**/ a = b; /* comment */ /**/ a = b; a = b; /* comment */ It converts them to: */ a = b; /* comment a = b; a = b; comment Is that intended? Also, will the user only want to work with one line at a time or will a typical use be for a block of code? Two other solutions would be to use (1) the preprocessor '#if 0' start and '#endif' end, or (2) use the c99 '//' (perhaps with a following character to identify code your map has commented out. What I wanted to know is could the same functionality have been achieved by a better sequence of commands? Can an experienced 'vimmer' do better? Without changing functionality of the provided code, you could preserve both the command line (with silent and :silent) and the '/' register (which also prevents the visible flashing). You don't need to escape '/' in the first arg of search() and can avoid escaping them in the :substitute commands if you use another separator. The 'g' flag doesn't appear to do anything in this context (for both :substitute commands). Finally, you code is apparently intended to be on one long line. Using continuation allows you to keep lines no longer than 80 characters. Here's a quick rewrite: nmap silent com ^:let com_hold=@/ \\|if search('/\*.*\*/','c',line(.))!=0 \\|silent s#/\*\(.*\)\*/#\1# \\|else \\|silent s#\v(\s*)(.*)(\s*)#\1/\*\2\*/\3# \\|endif \\|let @/=com_hold\|unlet com_holdCR -- Best regards, Bill
Re: Patched VIM 7.0 reboots Windows 2000 on forced write to read-only file (?)
Paul Stone wrote: [...] :!attrib works fine for me. :w! causes the reboot (with read-only file). Normally, :w! should overwrite a read-only file. Paul Stone Strange... Do you have the W flag in 'cpoptions' ? Best regards, Tony.
Re: Patched VIM 7.0 reboots Windows 2000 on forced write to read-only file (?)
On Wed, 2006-12-06 at 23:14 +0100, A.J.Mechelynck wrote: Alan Isaac wrote: On Wed, 6 Dec 2006, Paul Stone wrote: I went to the Cream web page because the VIM Downloads page links there as a way of getting a fully patched version of VIM for the PC Can this be installed over the previous Vim 7, or do I need to uninstall first? (Windows.) I think the installer uninstalls a previous patchlevel if it finds one. No, the Cream project's Windows installers do not uninstall a previous one if found. (Can't say about the official Vim Windows installer.) When I was on Windows, I used to install every patchlevel on top of the previous one. Yes, this is the way we do it... In the rare case that a runtime file name becomes obsolete (as happened when plugin/netrw.vim was replaced by plugin/netrwPlugin.vim plus other netrw*.vim scripts in other subdirectories of $VIMRUNTIME) you may need to make sure that the obsolete file is deleted. Exactly, from time to time, it's probably a good idea to delete/rename your Vim directory prior to installing a new version. Both these situations could probably be remedied pretty easily, I've just never found time to write it into the installer and the side effects have been negligible to date (in 3-4 years?). Patches welcome. :) -- Steve Hall [ digitect dancingpaper com ]
Vim Online Error ?
Hello all, When I visit the link http://www.vim.org/scripts/script.php?script_id=273 , I see the following error : script:Can't open file: 'vs_scripts.MYI' (errno: 145) , is anybody else facing the same issue? Thanks!
Re: Vim Online Error ?
Swaroop C H wrote: Hello all, When I visit the link http://www.vim.org/scripts/script.php?script_id=273 , I see the following error : script:Can't open file: 'vs_scripts.MYI' (errno: 145) , is anybody else facing the same issue? Thanks! Yes, and both at www.vim.org and at vim.sourceforge.net -- there seems to be something wrong with vim-online at the moment. Best regards, Tony.