Re: once again - how to unsubscribe?
Ulrich Lauther wrote: On Wed, Aug 02, 2006 at 09:47:05AM +0200, Ulrich Lauther wrote: the automated mechanism for unsubsrcibing from this list still doesn't work. Actually it does! I just unsubscribed from my old address, and subscribed using my new email address. Just follow the instructions carefully. what instructions? The only one I see is on http://www.vim.org/maillist.php#vim-dev: To Unsubscribe email [EMAIL PROTECTED] Email to that address seems to go into a black hole. (unsubscribing from other lists works, so I don't assume that my comany's spam filter is the culprit). Kind regards, -ulrich lauther Don't assume anything. Check, double-check, try again while checking that you didn't swap any characters in the address, and if it still doesn't work, ask your company mail admin to look into his logs to see if any mail from you to vim-dev-unsubscribe or from vim-dev-help to you was stopped, rejected or bounced at any point of its travels. Best regards, Tony.
Forget the buf_T reference when processing a 'close' netbeans command
Bug description: === Vim version 7.0 When receiving a netbeans 'close' command, vim does delete the specified buffer, but the buffer's reference (buf_list[bufno].bufp called here 'this_memory_address') is still kept in buf_list[]. It may happen that this_memory_address is once again returned by malloc when allocating a new buffer later. In this case, the function nb_getbufno(this_memory_address) will return the closed netbeans buffer number instead of the newly allocated one since it is always before in the list. See the test case below. Issue: How can a netbeans IDE implementation recognize when it talks to a vim version where the bug is fixed (since 'close' can't be used when it is not fixed) ? With a new netbeans version number ? Proposed Fix: *** netbeans.c.orig 2006-06-17 18:49:19.0 +0200 --- netbeans.c 2006-08-03 23:25:04.0 +0200 *** *** 1986,1991 --- 1986,1993 if (buf-bufp != NULL) do_buffer(DOBUF_WIPE, DOBUF_FIRST, FORWARD, buf-bufp-b_fnum, TRUE); + buf-bufp = NULL; + buf-initDone = FALSE; doupdate = 1; /* =*/ } === Test case: = start 'clewn -d' open 2 files in vim: :e cltest_main.c :e cltest_callit.c from clewn, 'close' the first one (bufno 2 in the example below) with the clewn debug command: (gdb) @ 2 close open a third file in vim: :e cltest_callit_2.c hit key 'S' in this last buffer result: vim reports bufno 2, (the closed buffer), as the buffer where the key was pressed instead of bufno 4, (the last buffer) this is not always the case, but it is easy to reproduce on my linux box [EMAIL PROTECTED] clewn_test]$ clewn -d ... ... Clewn running GDB in level 3 mode ... `run' commands do input and output on the terminal /dev/pts/1 NetBeans listens on localhost:3219 The netbeans socket to Vim is not connected yet... GNU gdb 6.3 Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type show copying to see the conditions. There is absolutely no warranty for GDB. Type show warranty for details. This GDB was configured as i686-pc-linux-gnu. NetBeans connected to 127.0.0.1:34015 AUTH changeme 0:version=0 2.3 0:startupDone=0 0:setExitDelay!1 0 NBS_READY in conn_setup() 0:fileOpened=0 /home/xavier/tmp/clewn_test/cltest_main.c T F 2:putBufferNumber!2 /home/xavier/tmp/clewn_test/cltest_main.c 2:stopDocumentListen!3 2:defineAnnoType!4 1 1 = 0 15710005 2:version!5 Clewn version 1.1 . 0:fileOpened=0 /home/xavier/tmp/clewn_test/cltest_callit.c T F 3:putBufferNumber!6 /home/xavier/tmp/clewn_test/cltest_callit.c 3:stopDocumentListen!7 3:defineAnnoType!8 1 1 = 0 15710005 (gdb) @ 2 close - closing bufno 2 2:close!9 2:fileOpened=0 /home/xavier/tmp/clewn_test/cltest_callit_2.c T F 4:putBufferNumber!10 /home/xavier/tmp/clewn_test/cltest_callit_2.c 4:stopDocumentListen!11 4:defineAnnoType!12 1 1 = 0 15710005 2:newDotAndMark=12 89 89- hitting key 'S' in new buffer (bufno 4) 2:keyCommand=12 S 2:keyAtPos=12 S 89 10/0 (gdb) step The program is not being run. (gdb) -- http://clewn.sourceforge.net gdb support in Vim
Sorting columns in a file
Hi, I have file which contains hexadecimal numbers like below: 04F --- 05F --- 052 --- 188 --- 2D4 --- 173 --- 040 --- 18D 051 --- 040 --- 05F --- 1CA --- 2E8 --- 14F --- 040 --- 1E2 051 --- 040 --- 069 --- 1B9 --- 2D7 --- 15E --- 040 --- 1A6 051 --- 040 --- 06F --- 1ED --- 2EB --- 12E --- 040 --- 209 051 --- 040 --- 078 --- 1F9 --- 2E3 --- 122 --- 040 --- 220 051 --- 045 --- 063 --- 1C8 --- 2D1 --- 146 --- 040 --- 1F4 051 --- 046 --- 05A --- 1BB --- 2D7 --- 158 --- 040 --- 1D3 051 --- 052 --- 04F --- 1B6 --- 2E3 --- 154 --- 040 --- 1BB 052 --- 040 --- 045 --- 1BC --- 2D6 --- 146 --- 040 --- 1CE 052 --- 040 --- 04A --- 1BC --- 2DD --- 146 --- 040 --- 1D3 How can I sort the columns so that they are as the first column? Best regards, Eric _ FREE pop-up blocking with the new MSN Toolbar get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
syntax highlighting problem with vim7 for multiline macro in C
Hi, I am facing this syntax highlighting problem here for the following code segment. The problem is if we put this code in a file having .c extension. The same macro color is shown for the main() function also. Does anyone else faced this problem with vim7 ? regards, s ===somefile.c= #define GET_TAG_STRING(tagFeildPtr) { \ *feildEndP = 'a'; \ *feildEndP+1 = '\0'; \ } main() { }
RE: Vim and cscope
Could someone help me here; I tried what Dave suggested but with no success. Regards, Sibin -Original Message- From: Sibin P. Thomas [mailto:[EMAIL PROTECTED] Sent: Monday, July 31, 2006 6:25 AM ... I tried integrating Cscope 15.4 with Vim7.0 on WinXP (I have installed cygwin too); but whenever I try to use cscope in Vim I get the following error - E623: Could not spawn cscope process. Sounds like you are using the cscope from the open source project. You need a special version of cscope that is integrated with Vim. :h cscope-info Will point you to different downloads locations. Since you are on win32, you need to download it from: http://iamphet.nm.ru/cscope/index.html :h cscope-win32 HTH, Dave - Disclaimer - This message(including attachment if any)is confidential and may be privileged.Before opening attachments please check them for viruses and defects.MindTree Consulting Private Limited (MindTree)will not be responsible for any viruses or defects or any forwarded attachments emanating either from within MindTree or outside.If you have received this message by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change and MindTree shall not be liable for any improper, untimely or incomplete transmission. -
Re: Sorting columns in a file
Hi Eric, I am assuming you want to re-order the columns horizontally, in which case Visual Block Mode is what you want. Press CTRL+V to start selecting a column, use 'x' to delete it, and 'P' (upper-case P) to paste it (I find upper-case P is more logical for Visual Block paste). HTH, regards, Peter --- Eric Leenman [EMAIL PROTECTED] wrote: Hi, I have file which contains hexadecimal numbers like below: 04F --- 05F --- 052 --- 188 --- 2D4 --- 173 --- 040 --- 18D 051 --- 040 --- 05F --- 1CA --- 2E8 --- 14F --- 040 --- 1E2 051 --- 040 --- 069 --- 1B9 --- 2D7 --- 15E --- 040 --- 1A6 051 --- 040 --- 06F --- 1ED --- 2EB --- 12E --- 040 --- 209 051 --- 040 --- 078 --- 1F9 --- 2E3 --- 122 --- 040 --- 220 051 --- 045 --- 063 --- 1C8 --- 2D1 --- 146 --- 040 --- 1F4 051 --- 046 --- 05A --- 1BB --- 2D7 --- 158 --- 040 --- 1D3 051 --- 052 --- 04F --- 1B6 --- 2E3 --- 154 --- 040 --- 1BB 052 --- 040 --- 045 --- 1BC --- 2D6 --- 146 --- 040 --- 1CE 052 --- 040 --- 04A --- 1BC --- 2DD --- 146 --- 040 --- 1D3 How can I sort the columns so that they are as the first column? Best regards, Eric _ FREE pop-up blocking with the new MSN Toolbar get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/ Send instant messages to your online friends http://au.messenger.yahoo.com
Re: Sorting columns in a file
Hi Peter [snip] I am assuming you want to re-order the columns horizontally, in which case Sorry for not making my self clear. I want to re-order the columns vertical So column 1 is already OK, running from 04F ... ... 052 Column 2 should be 040 ... 040 045 046 052 05F ect. [snip] I have file which contains hexadecimal numbers like below: 04F --- 05F --- 052 --- 188 --- 2D4 --- 173 --- 040 --- 18D 051 --- 040 --- 05F --- 1CA --- 2E8 --- 14F --- 040 --- 1E2 051 --- 040 --- 069 --- 1B9 --- 2D7 --- 15E --- 040 --- 1A6 051 --- 040 --- 06F --- 1ED --- 2EB --- 12E --- 040 --- 209 051 --- 040 --- 078 --- 1F9 --- 2E3 --- 122 --- 040 --- 220 051 --- 045 --- 063 --- 1C8 --- 2D1 --- 146 --- 040 --- 1F4 051 --- 046 --- 05A --- 1BB --- 2D7 --- 158 --- 040 --- 1D3 051 --- 052 --- 04F --- 1B6 --- 2E3 --- 154 --- 040 --- 1BB 052 --- 040 --- 045 --- 1BC --- 2D6 --- 146 --- 040 --- 1CE 052 --- 040 --- 04A --- 1BC --- 2DD --- 146 --- 040 --- 1D3 How can I sort the columns so that they are as the first column? [snip] Rgds, Eric _ FREE pop-up blocking with the new MSN Toolbar get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
Chip's block substitution script
Sorry Chip, you are absolutely right, I obviously didn't test it thoroughly enough the last time, just tried it out again and of course it does as you said and reassembles the strings again when you are finished. Very nice little script. Thanks, Rob.
Re: Tab bar
On 8/3/06, Bart van Kuik [EMAIL PROTECTED] wrote: Can anyone tell me whether I can customize the tab bar in vim 7.0 (vim, not gvim). Colours, etc. :he hl-TabLine :he hl-TabLineFill :he hl-TabLineSel :he 'tabline' Yakov
Re: syntax highlighting problem with vim7 for multiline macro in C
On 8/3/06, Srinivas Rao. M [EMAIL PROTECTED] wrote: I am facing this syntax highlighting problem here for the following code segment. The problem is if we put this code in a file having .c extension. The same macro color is shown for the main() function also. Does anyone else faced this problem with vim7 ? regards, s ===somefile.c= #define GET_TAG_STRING(tagFeildPtr) { \ *feildEndP = 'a'; \ *feildEndP+1 = '\0'; \ } main() { } For me (vim7), main() is highlighted correctly. What is your vim version ? What is version of your $VIMRUNTIME/syntax/c.vim file ? Do you possibly have some custom additions in ~/.vim/after/syntax/c.vim ? And if you do, does highlighting changes when you temporarity rename your ~/.vim/after/syntax/c.vim file ? Yakov
Re: Can't find terminal library when compiling Vim7.0
Can someone please tell me what library I'm suppose to point to with --with-tlib. Did you install the ncurses-dev package? I also use Kubuntu 6.06, but didn't use the --with-tlib config option. Cheers Tom. I installed the ncurses-dev package and vim 7 compiled and runs beautifully! :D Regards Johnathan
Re: syntax highlighting problem with vim7 for multiline macro in C
On Thu, 2006-08-03 at 14:09, Yakov Lerner wrote: On 8/3/06, Srinivas Rao. M [EMAIL PROTECTED] wrote: I am facing this syntax highlighting problem here for the following code segment. The problem is if we put this code in a file having .c extension. The same macro color is shown for the main() function also. Does anyone else faced this problem with vim7 ? regards, s ===somefile.c= #define GET_TAG_STRING(tagFeildPtr) { \ *feildEndP = 'a'; \ *feildEndP+1 = '\0'; \ } main() { } For me (vim7), main() is highlighted correctly. What is your vim version ? What is version of your $VIMRUNTIME/syntax/c.vim file ? Hi Yakov, My vim version is : VIM - Vi IMproved 7.0 (2006 May 7, compiled May 23 2006 12:47:54) Compiled by [EMAIL PROTECTED] Big version with GTK2 GUI. Features included (+) or not (-): +arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +cryptv +cscope +cursorshape +dialog_con_gui +diff +digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path +folding -footer +fork() -gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap +menu +mksession +modify_fname +mouse +mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm +mouse_netterm +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype +path_extra -perl +postscript +printer -profile -python +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent -sniff +statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title +toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup +X11 -xfontset +xim +xsmp_interact +xterm_clipboard -xterm_save system vimrc file: $VIM/vimrc user vimrc file: $HOME/.vimrc user exrc file: $HOME/.exrc system gvimrc file: $VIM/gvimrc user gvimrc file: $HOME/.gvimrc system menu file: $VIMRUNTIME/menu.vim fall-back for $VIM: /usr/local/share/vim Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr/include/freetype2/config -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -g -O2 -I/usr/X11R6/include Linking: gcc -L/usr/X11R6/lib -L/usr/local/lib -o vim -Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lXt -lncurses -lacl -lgpm And my $VIMRUNTIME/syntax/c.vim 's file's header contains: Vim syntax file Language: C Maintainer: Bram Moolenaar [EMAIL PROTECTED] Last Change: 2006 May 01 Quit when a (custom) syntax file was already loaded if exists(b:current_syntax) finish endif Do you possibly have some custom additions in ~/.vim/after/syntax/c.vim ? And if you do, does highlighting changes when you temporarity rename your ~/.vim/after/syntax/c.vim file ? No I donot have custom c.vim syntax file. The version inforamtion on I tried by replacing completely the ~/.vim/ folder. But still it behaves like this. I am running on Fedora core 2 system with vim7 upgraded from vim6.3. thanks and regards, Srini..
How to scroll up and down without changing horizontal pos
Hi, I'm using page-up and page-down to scroll. Also ctrl-home and ctrl-end. This moves the cursor to the beginning of the line. How can this be avoided. I need to the cursor to stay where it is, as the lines are 1000+ characters long Rgds, Eric _ Is your PC infected? Get a FREE online computer virus scan from McAfee® Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
Re: How to scroll up and down without changing horizontal pos
[snip] nmap silentPageDown :exe norm .winheight(0).jcr nmap silentPageUp :exe norm .winheight(0).kcr nmap silentc-home :let x=col('.')bar1barexe norm .x.barcr nmap silentc-end:let x=col('.')bar$barexe norm .x.barcr [snip] This works great. I'm trying to map them also to visaul-mode but then I get the error: no range allowed Why is that? I have: vmap silentc-s-PageDown :exe norm .winheight(0).jcr vmap silentc-s-PageUp :exe norm .winheight(0).kcr vmap silentc-s-home :let x=col('.')bar1barexe norm .x.barcr vmap silentc-s-end:let x=col('.')bar$barexe norm .x.barcr Rgds, Eric _ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
Re: How to scroll up and down without changing horizontal pos
Eric Leenman wrote: [snip] nmap silentPageDown :exe norm .winheight(0).jcr nmap silentPageUp :exe norm .winheight(0).kcr nmap silentc-home :let x=col('.')bar1barexe norm .x.barcr nmap silentc-end:let x=col('.')bar$barexe norm .x.barcr [snip] This works great. I'm trying to map them also to visaul-mode but then I get the error: no range allowed Why is that? I have: vmap silentc-s-PageDown :exe norm .winheight(0).jcr vmap silentc-s-PageUp :exe norm .winheight(0).kcr vmap silentc-s-home :let x=col('.')bar1barexe norm .x.barcr vmap silentc-s-end:let x=col('.')bar$barexe norm .x.barcr Rgds, Eric Hitting the : key in Visual mode causes the visual highlight to disappear, and Vim adds a range as :',' which means from the first to the last line of the latest Visual highlight. In this case you will want to clear the range before the Ex-command (e.g. by means of C-U, see :help c_CTRL-U); but restoring the highlight after scrolling (with gv q.v.) will move the cursor back to one end of the visual area, possibly canceling the scroll... You might prefer to set 'nostartofline' and then use PageUp and PageDown Best regards, Tony.
Select prev visual block + 5 hor pos more
Hi, With gv you can re-select the previous visual block. Is it possible to give a horizontal shift with it? Like + or - 5? Best Regards, Eric _ On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
Re: Select prev visual block + 5 hor pos more
With gv you can re-select the previous visual block. Is it possible to give a horizontal shift with it? Like + or - 5? Natively? Not as far as I know. However, if you haven't already discovered the o command in block-wise-visual-mode, it does bounce you to the opposite corner of the block. Thus, you could do something like gv5lo5lo (that's gee vee five ell oh five ell oh) or change the ells to h instead to shift left rather than right. Just something to try. I don't know how easily one could map it to a command that would take a count in visual mode. But that's at least a starting ground. You can read more at :help v_o -tim
Re: Select prev visual block + 5 hor pos more
Eric Leenman wrote: Hi, With gv you can re-select the previous visual block. Is it possible to give a horizontal shift with it? Like + or - 5? Best Regards, Eric You can indent or unindent visually selected lines with or . However, IIUC this is a linewise (not blockwise) operation. Best regards, Tony.
vim@vim.org
Do you know of a way to do that in Windows? It's a bother trying to remember not to press CAPS when I'm using Windows. http://vankuik.nl/cgi/wiki.cgi/download/capslock_becomes_escape.reg
Re: Sorting columns in a file
Eric Leenman wrote: Hi, I have file which contains hexadecimal numbers like below: 04F --- 05F --- 052 --- 188 --- 2D4 --- 173 --- 040 --- 18D 051 --- 040 --- 05F --- 1CA --- 2E8 --- 14F --- 040 --- 1E2 051 --- 040 --- 069 --- 1B9 --- 2D7 --- 15E --- 040 --- 1A6 051 --- 040 --- 06F --- 1ED --- 2EB --- 12E --- 040 --- 209 051 --- 040 --- 078 --- 1F9 --- 2E3 --- 122 --- 040 --- 220 051 --- 045 --- 063 --- 1C8 --- 2D1 --- 146 --- 040 --- 1F4 051 --- 046 --- 05A --- 1BB --- 2D7 --- 158 --- 040 --- 1D3 051 --- 052 --- 04F --- 1B6 --- 2E3 --- 154 --- 040 --- 1BB 052 --- 040 --- 045 --- 1BC --- 2D6 --- 146 --- 040 --- 1CE 052 --- 040 --- 04A --- 1BC --- 2DD --- 146 --- 040 --- 1D3 How can I sort the columns so that they are as the first column? May I suggest looking at: http://vim.sourceforge.net/tips/tip.php?tip_id=588 : How to sort using visual blocks which discusses * how to sort visual-block selected columns (independently of surrounding text), and * how to sort lines based on the contents of a visual-block selected columns. Regards, Chip Campbell
Re: How to scroll up and down without changing horizontal pos
Eric Leenman wrote: I'm using page-up and page-down to scroll. Also ctrl-home and ctrl-end. This moves the cursor to the beginning of the line. How can this be avoided. I need to the cursor to stay where it is, as the lines are 1000+ characters long Hello! Perhaps:set ve=all nosol will get you the behavior you want. Regards, Chip Campbell
Search and Replace with a Regular Expression
Hello, all. I've been tasked with migrating a large MS Works database into the 21st century. The thing's original setup didn't enforce any sort of standardization in data entry, so there are nearly as many different formats and styles in the data as there have been people entering it. My best bet seems to be to hammer things into shape with a CSV version of the data before even thinking of trying to drop it into a new database app. Since it's plain text, Vim seems the perfect tool for the job. :) I could use some pointers on search and replace with regular expressions. I'm sure this will be painfully basic to most of you, but I can't seem ot get the hang of it for this particular job. Most of the problem is with dates, in that I have a mishmash of formats. Most of them are in dashed format, but there's not even much uniformity _there_: some are MM-DD-, some are M-D-YY, and so on. What I'd like to do is reformat them en masse as MM/DD/; preserving the original values, replacing dashes with slashes, putting zeroes in front of existing single digits, and expanding two-digit years into four digits by bolting on 20 at the front. For example, let's say I have some dates that look like this: 7-30-05 12-5-2006 10-2-06 What I'd like to end up with is this... 07/30/2005 12/05/2006 10/02/2006 ...without, of course, having to re-type every single one by hand. ;) Since I'm dealing with a finite range of digits before and after each dash, it seems to my woefully untrained eye that a single global search and replace with the proper regular expression should do the trick. I'm just having a heck of a time getting the expression right. Any and all guidance would be greatly appreciated; thanks very much in advance.
Re: My apologies to Chip Campbell
Tien Pham wrote: I am terribly sorry that I misspelled your name Chip. My apologies No problem! You should see what people do to my last name Chip Campbell
Re: syntax highlighting problem with vim7 for multiline macro in C
Srinivas Rao. M wrote: I am facing this syntax highlighting problem here for the following code segment. The problem is if we put this code in a file having .c extension. The same macro color is shown for the main() function also. Does anyone else faced this problem with vim7 ? regards, s ===somefile.c= #define GET_TAG_STRING(tagFeildPtr) { \ *feildEndP = 'a'; \ *feildEndP+1 = '\0'; \ } main() { } Hello! The code text looks fine to me. May I suggest trying nmap silent F10 :echo hi . synIDattr(synID(line(.),col(.),1),name) . ' trans' . synIDattr(synID(line(.),col(.),0),name) . lo . synIDattr(synIDtrans(synID(line(.),col(.),1)),name) . CR (that's all one line in case some mailer thinks its smarter than me) Put that into your .vimrc file (you *do* have one so that :echo cp shows 0, I hope), then when next editing your somefile.c, place the cursor atop the main and press the F10 key. You should get a message telling what highlighting is being used. Well, what syntax highlighting is being used. If you happened to have done a search for main and have hlsearch enabled, then main will be highlighted for reasons that bypass the syntax highlighting. Regards, Chip Campbell
Re: Select prev visual block + 5 hor pos more
Eric Leenman wrote: With gv you can re-select the previous visual block. Is it possible to give a horizontal shift with it? Like + or - 5? Do you mean to move a selected block horizontally, or to have the same visual block selection geometry shift? Regards, Chip Campbell
Re: Select prev visual block + 5 hor pos more
With gv you can re-select the previous visual block. Is it possible to give a horizontal shift with it? Like + or - 5? Could you cut away the finished block and paste to another place, and do gv again? Not quite reliable, but may work. Regards, Ben K. Developer http://benix.tamu.edu
Re: Search and Replace with a Regular Expression
Hi, Marv Boyes wrote: Hello, all. I've been tasked with migrating a large MS Works database into the 21st century. The thing's original setup didn't enforce any sort of standardization in data entry, so there are nearly as many different formats and styles in the data as there have been people entering it. My best bet seems to be to hammer things into shape with a CSV version of the data before even thinking of trying to drop it into a new database app. Since it's plain text, Vim seems the perfect tool for the job. :) I could use some pointers on search and replace with regular expressions. I'm sure this will be painfully basic to most of you, but I can't seem ot get the hang of it for this particular job. Most of the problem is with dates, in that I have a mishmash of formats. Most of them are in dashed format, but there's not even much uniformity _there_: some are MM-DD-, some are M-D-YY, and so on. What I'd like to do is reformat them en masse as MM/DD/; preserving the original values, replacing dashes with slashes, putting zeroes in front of existing single digits, and expanding two-digit years into four digits by bolting on 20 at the front. For example, let's say I have some dates that look like this: 7-30-05 12-5-2006 10-2-06 What I'd like to end up with is this... 07/30/2005 12/05/2006 10/02/2006 ...without, of course, having to re-type every single one by hand. ;) if you are sure that there are no dates from before 2000 the following command should do the job (all on one line): :%s,\\(\d\+\)[-/]\(\d\+\)[-/]\%(20\)\?\(\d\d\)\,\=(submatch(1) 10 ? '0' : '') . submatch(1) . '-' . (submatch(2) 10 ? '0' : '') . submatch(2) . '-' . '20' . submatch(3), I have used commas as separators so that there is no need to escape the slashes used between the parts for month, day, and year. The regex part is quite easy: we look for something word-like (\...\) which consists of one or more digits (\d\+), a dash or a slash ([-/]), some digits, a second dash or slash, and two or four digits; if the third number has four digits, the first two must be 20 (\%(20\)\?\(\d\d\)). I used VIM's non-capturing parentheses to make clear that the content of \%(20\) is not needed later. If this expression matches, the submatches 1, 2, and 3 contain month, day, and year, respectively. Generating the replacement is simple, too; the expression is only longer (therefore I have split it on three lines here): \=(submatch(1) 10 ? '0' : '') . submatch(1) . '-' . (submatch(2) 10 ? '0' : '') . submatch(2) . '-' . '20' . submatch(3) It uses the \= special register to evaluate an expression. submatch(1) contains the month. If it is less than 10 it has only one digit. In this case the month is prefixed with a zero. The same is true for the day in submatch(2). submatch(3) only contains the second to last digits of the year, because we used non-capturing parentheses. So we always have to prefix it with '20'. Those three strings are then concatenated with dashes between them. Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin)
Re: Search and Replace with a Regular Expression
I can't seem ot get the hang of it for this particular job. Well, even as a regexp wonk, it's a bit of a daunting task you have before you. :) Most of the problem is with dates, in that I have a mishmash of formats. Since you don't mention any other problematic sections, I guess I'll focus on just mending dates. However, if there are other sections of trouble, feel free to mention them too and perhaps some handy solution can be found. Most of them are in dashed format, but there's not even much uniformity _there_: some are MM-DD-, some are M-D-YY, and so on. What I'd like to do is reformat them en masse as MM/DD/; preserving the original values, replacing dashes with slashes, putting zeroes in front of existing single digits, and expanding two-digit years into four digits by bolting on 20 at the front. Well, my first pass at a regexp to *find* these buggers would be something like \\(\d\{1,2}\)[-/]\(\d\{1,2}\)[-/]\(\d\d\|\d\d\d\d\)\ If there are characters other than - and / used as separators, you can append them in those two sets. This regexp should now have the three pieces isolated, and referencable (is that a word?) via the usual method of \1, \2, and \3, or (as you need to massage them) via the submatch() function. That regexp is basically one or two digits, followed by a delimiter, followed by one or two digits, followed by a delimiter, followed by 2 or 4 digits. To do some magicomystico replacement on them, we then use the \= replacement as described in :help sub-replace-special The replacement will be something like this expression: substitute('0'.submatch(1), '.*\(..\)$', '\1', ''). '/'. substitute('0'.submatch(2), '.*\(..\)$', '\1', ''). '/'. (strlen(submatch(3)) == 4? submatch(3): (submatch(3)[0] == '0'? '20'.submatch(3): '19'.submatch(3) ) ) I broke it out into multiple lines to hopefully make more sense of it. The first two substitute() lines add a zero on the left of whatever they found, and then take whatever the rightmost two characters of the result are...effectively padding them with zeros on the left if needed. Ideally, Vim would provide a right() function where you could just do something like right('0'.submatch(1), 2) to zero-pad to 2 places. Alas, the substitute() trick is the easiest way I've found to simulate this. The third element monkeys with the date. If it's a 4-digit year (strlen() == 4) then we just use that. If it's not a 4-digit year, we check the first digit of what was there. If it's a zero, we prepend '20' on it. If it's not a zero, we presume it was sooo last century, and prepend '19' to it. However, Vim likes to have it all crammed on one line. Thus, the final product looks something like this one-liner (take a deep breath and a running start now...) :%s!\\(\d\{1,2}\)[-/]\(\d\{1,2}\)[-/]\(\d\d\d\d\|\d\d\)\!\=substitute('0'.submatch(1), '.*\(..\)$', '\1', ''). '/'.substitute('0'.submatch(2), '.*\(..\)$', '\1', ''). '/'.(strlen(submatch(3)) == 4?submatch(3):(submatch(3)[0] == '0'?'20'.submatch(3):'19'.submatch(3))) And you thought that would be hard. ;-) HTH, -tim
Re: Search and Replace with a Regular Expression
part of a good job is to choose the right tool. use perl for this kind of task. use vim to edit the perl script ;-) and search cpan before creating your own solutions! /martin begin:vcard fn:Martin Kraegeloh n:Kraegeloh;Martin adr:;;Am Alten Pfarrhof 24;Oberbergkirchen;;84564;Germany email;internet:[EMAIL PROTECTED] tel;work:+49 8637 985806 tel;cell:+49 160 98943453 x-mozilla-html:FALSE version:2.1 end:vcard smime.p7s Description: S/MIME Cryptographic Signature
Re: Search and Replace with a Regular Expression
Tim Chase wrote: [...] I broke it out into multiple lines to hopefully make more sense of it. The first two substitute() lines add a zero on the left of whatever they found, and then take whatever the rightmost two characters of the result are...effectively padding them with zeros on the left if needed. Ideally, Vim would provide a right() function where you could just do something like right('0'.submatch(1), 2) to zero-pad to 2 places. Alas, the substitute() trick is the easiest way I've found to simulate this. [...] (0 . submatch(1))[-2:] i.e. the last two characters of the string obtained by prepending a zero to submatch(1) see :help expr-[:] Best regards, Tony.
Re: Search and Replace with a Regular Expression
Marv Boyes wrote: For example, let's say I have some dates that look like this: 7-30-05 12-5-2006 10-2-06 What I'd like to end up with is this... 07/30/2005 12/05/2006 10/02/2006 ...without, of course, having to re-type every single one by hand. ;) The following will do the trick, albeit you do need vim 7.0 for it: %s/\(\d\{1,2}\)-\(\d\{1,2}\)-\(\d\{2,4}\)/\=printf('%02d\/%02d\/%4d',submatch(1),submatch(2),(submatch(3) 100)? (2000+submatch(3)) : submatch(3))/ Explanation: \d\{1,2} --- match 1 to 2 digits \(...\) save this matching subexpression for later \= execute the following expression submatch(...) use the subsexpression matched earlier Regards, Chip Campbell
Re: Search and Replace with a Regular Expression
martin kraegeloh wrote: part of a good job is to choose the right tool. use perl for this kind of task. use vim to edit the perl script ;-) and search cpan before creating your own solutions! Two problems with this approach: * Perl's regular expressions don't appear to be much more powerful than vim's. Perhaps not any more powerful any more. * Not everyone has or uses perl, especially Windoze users. Asking folks to learn perl isn't going to help -- few will bother. Regards, Chip Campbell
Checking if a variable exists in a given tab
I'm sure this is an easy one, I just can't find the answer anywhere. I'm writing my own tabline function (based heavily on the one by Tony Mechelynck, thanks!) and I want to be able to name a tab manually. The best way I can think to do this is to have a tab local variable, such as t:maxd_TabName. Only problem is that within the script I can only check if that variable exists within the CURRENT tab. So how can I get a tab local variable from a numbered tab? I've found gettabwinvar(), but I just can't make it work (echo gettabwinvar(i, 0, maxd_TabName) doesn't work). Thanks in advance! -- Max Dyckhoff AI Engineer Bungie Studios
using vim with GNUscreen
Hi, I am having problem using vim when i invoke it from GNUscreen. i have the following vimrc set nocompatible set showmatch set ruler set virtualedit=all set number set title set ls=2 set tabstop=4 set shiftwidth=4 syntax on set background=dark it works from from normal terminal. but when i start vim in GNUscreen, the color is always screwed up. :( regards, goonz
Re: Checking if a variable exists in a given tab
Max Dyckhoff wrote: I'm sure this is an easy one, I just can't find the answer anywhere. I'm writing my own tabline function (based heavily on the one by Tony Mechelynck, thanks!) and I want to be able to name a tab manually. The best way I can think to do this is to have a tab local variable, such as t:maxd_TabName. Only problem is that within the script I can only check if that variable exists within the CURRENT tab. So how can I get a tab local variable from a numbered tab? I've found gettabwinvar(), but I just can't make it work (echo gettabwinvar(i, 0, maxd_TabName) doesn't work). Thanks in advance! -- Max Dyckhoff AI Engineer Bungie Studios What about making the desired tab (temporarily) current while checking if the variable exists? Maybe manually naming the current tab is good enough (the user can change tabs manually too)? Or else, rather than a separate variable in each tab, use a global array (a List, if you will), with as many items as there are tabs? Best regards, Tony.
Re: using vim with GNUscreen
uber goonz wrote: Hi, I am having problem using vim when i invoke it from GNUscreen. i have the following vimrc set nocompatible set showmatch set ruler set virtualedit=all set number set title set ls=2 set tabstop=4 set shiftwidth=4 syntax on set background=dark it works from from normal terminal. but when i start vim in GNUscreen, the color is always screwed up. :( regards, goonz What kind of foul-up do you notice? Is it better or worse if you delete (or comment away) the last line so Vim can guess if the background is light or dark? Best regards, Tony.
Re: Search and Replace with a Regular Expression
right('0'.submatch(1), 2) to zero-pad to 2 places. Alas, the substitute() trick is the easiest way I've found to simulate this. [...] (0 . submatch(1))[-2:] Hmmm...a nifty new feature in vim7 that is here on my work machine, but unavailable on my hosting service (still running 6.3). Looks like a much-needed pilfering from Python's handy slicing syntax. :) I'll keep it filed away for future use. -tim
RE: Checking if a variable exists in a given tab
If by making the desired tab current you mean using :tabn {count} then it isn't allowed. I imagine changing tabs within the tabline function would be A Bad Thing, and would cause recursion. I hadn't thought about using a global array of names, although it would be a pain to maintain when one closes a tab (and I have better things to program than that right now! :) Anyone else know if you can get a tab local variable somehow? Max -Original Message- From: A.J.Mechelynck [mailto:[EMAIL PROTECTED] Sent: Thursday, August 03, 2006 10:32 AM To: Max Dyckhoff Cc: vim@vim.org Subject: Re: Checking if a variable exists in a given tab Max Dyckhoff wrote: I'm sure this is an easy one, I just can't find the answer anywhere. I'm writing my own tabline function (based heavily on the one by Tony Mechelynck, thanks!) and I want to be able to name a tab manually. The best way I can think to do this is to have a tab local variable, such as t:maxd_TabName. Only problem is that within the script I can only check if that variable exists within the CURRENT tab. So how can I get a tab local variable from a numbered tab? I've found gettabwinvar(), but I just can't make it work (echo gettabwinvar(i, 0, maxd_TabName) doesn't work). Thanks in advance! -- Max Dyckhoff AI Engineer Bungie Studios What about making the desired tab (temporarily) current while checking if the variable exists? Maybe manually naming the current tab is good enough (the user can change tabs manually too)? Or else, rather than a separate variable in each tab, use a global array (a List, if you will), with as many items as there are tabs? Best regards, Tony.
yank append to unnamed register (*quotequote* register)
Is it possible to Yank Append directly to the unnamed register? That is, without affecting any of the other named registers. I know that the unnamed register also holds the same text as was last yanked to a named register, but I wanted to Yank Append without affecting any of those. Yours, Noah
Re: Search and Replace with a Regular Expression
Tim Chase wrote: right('0'.submatch(1), 2) to zero-pad to 2 places. Alas, the substitute() trick is the easiest way I've found to simulate this. [...] (0 . submatch(1))[-2:] Hmmm...a nifty new feature in vim7 that is here on my work machine, but unavailable on my hosting service (still running 6.3). Looks like a much-needed pilfering from Python's handy slicing syntax. :) I'll keep it filed away for future use. -tim well, then, strpart(0 . submatch(1), strlen(submatch(1)) - 2) Best regards, Tony.
Re: Search and Replace with a Regular Expression
(0 . submatch(1))[-2:] Hmmm...a nifty new feature in vim7 that is here on my work machine, but unavailable on my hosting service (still running 6.3). Looks like a much-needed pilfering from Python's handy slicing syntax. :) well, then, strpart(0 . submatch(1), strlen(submatch(1)) - 2) Um...using s for the submatch in the example: let s='19' echo s.'-'.strpart('0'.s, strlen(s)-2) The echo yields 19-019 I think you meant the following: echo s.'-'.strpart('0'.s, strlen('0'.s)-2) which yields the correct results for 1 and 2-digit values of s: 19-19 3-03 but still chokes on crazy 3-character values of s: 123-123 instead of 123-23 Who would have thought the implementation of a right() would be such a complex problem :) Using subsitute(), I've shortened it by a couple characters: echo s.'-'.substitute('0'.s, '.*\ze..$', '', '') Thus, making a right() function look something like function! Right(s, length) let l:length = a:length let l:pad = '' while l:length let l:pad = l:pad.'0' let l:length -= 1 endwhile return substitute(l:pad.a:s, '^.*\ze.\{'.a:length.'}$', '', '') endfunc for pre-vim7 compatibility, all of which collapses nicely into vim7-ese as function! Right(s, length) return (repeat('0', a:length).a:s)[(-a:length):] endf I guess a true Right() function wouldn't zero-pad. But I guess then I should be referring to the desired effect in question as LeftPadWithZerosAndForceToAFixedWidth but that's a bit cumbersome. ;) -tim
can vim do this?
I recently started work at a company where the predominant text editor happens to be emacs. I've been using vim for a while now, though only recently started getting into the more advanced functionality beyond simple editing (highlighting, folding, tags etc...). Watching one of my co-workers with emacs is pretty fun, as he does things fairly quickly - I asked him what his most common emacs actions were, to see how I could do them in vim: * autocomplete - say that I've declared a constant variable in Perl named MY_CONSTANT, later, to have the editor fill it in, I type in MY_, and some other key-stroke, and CONSTANT gets typed in for you * goto when compiling - when compiling with make for example, and there is a problem in the code identified by a line, can vim somehow know to go to that line? this would be especially useful with 'make' * rectangular cut/pastes - if I have a column (multi-row) of text that I'd like to paste on several lines, can I do this without a regex? * ctags variable name references - assuming I'm using ctags, how can I replace the name of a variable throughout my code base? * regional undo - can I select a region, and perform an undo for all of the changes only in that region? * cvs/diff mode - what support does vim offer for these two apps, internal to the editor. I'll be glad to RTFM for all of these things, however I don't know where to look them up - any pointers would be appreciated! thanks, -lev
Re: yank append to unnamed register (*quotequote* register)
On 8/3/06, Noah Spurrier [EMAIL PROTECTED] wrote: Is it possible to Yank Append directly to the unnamed register? That is, without affecting any of the other named registers. I know that the unnamed register also holds the same text as was last yanked to a named register, but I wanted to Yank Append without affecting any of those. Yes, it must be possible using example of code like that described in :help g@ Here is skeleton (untested and unfinished): :nmap silent f5 :set opfunc=AppendUnnamedRegcrg@ :vmap silent f5 :C-Ucall AppendUnnamedReg(visualmode(), 1)CR function! AppendUnnamedReg(type,...) let old=@ old contents of unnamed register ... code to yank the selection depending on the mode ... ... into unnamed register ... let @ = old . @ append to unnamed register endfun Yakov
Re: can vim do this?
* autocomplete - say that I've declared a constant variable in Perl named MY_CONSTANT, later, to have the editor fill it in, I type in MY_, and some other key-stroke, and CONSTANT gets typed in for you Ctrl-N * goto when compiling - when compiling with make for example, and there is a problem in the code identified by a line, can vim somehow know to go to that line? this would be especially useful with 'make' :he makeprg :he quickfix :he :cn * rectangular cut/pastes - if I have a column (multi-row) of text that I'd like to paste on several lines, can I do this without a regex? :he ctrl-v (visual block select) * cvs/diff mode - what support does vim offer for these two apps, internal to the editor. :he vimdiff Search vim.sf.net for cvscommand.vim I'll be glad to RTFM for all of these things, however I don't know where to look them up - any pointers would be appreciated! :he :help Diwaker -- Web/Blog/Gallery: http://floatingsun.net/blog
Re: Help with unwanted shell character expansion
On 8/3/06, Bob Hiestand [EMAIL PROTECTED] wrote: As is too often the case, I didn't read enough documentation. I think this is not a well-known feature. On 7/31/06, Bob Hiestand [EMAIL PROTECTED] wrote: Question two: Is there a way to set the buffer name without the name being subject to shell metacharacter expansion? As far as I know, only :edit, :split, :new, :write, and :file allow setting the buffer name, and those all apply shell expansion. I know that characters can be escaped, but that involved knowledge of which characters are significant on each platform and again leads to unportable code (or highly complex code that attempts to be portable by taking each system into account). I would like a function to set the buffer name (potentially for a buffer specified by number) or for the '%' register to be writable. Yes, by using backtick notation along with the '=' expression prefix, non-expansion is possible. For example, :e `=unescapedFileName` Does this really work fo you ? First, many characters are interpreted specially inside `=...`, Those are (,),+,- and all vim operators (see val.txt). Second, if I try your examlpe, I get: :e `=unescapedFileName` E121: Undefined variable: unescapedFIleName `=unescapedFileName` [New File] And then filename is set to `=unescapedFileName` Note how filename includes backticks and equal sign. Or did you possibly mean :e `='unescapedFileName'` ? Yakov
Re: can vim do this?
* autocomplete - say that I've declared a constant variable in Perl named MY_CONSTANT, later, to have the editor fill it in, I type in MY_, and some other key-stroke, and CONSTANT gets typed in for you Well, I usually just use ^N and ^P in insert mode to cycle through available completion options. There are other features for autocompletion as well, but I've not needed to use them. Likely, others will address this. * goto when compiling - when compiling with make for example, and there is a problem in the code identified by a line, can vim somehow know to go to that line? this would be especially useful with 'make' :help make :help 'errorformat' * rectangular cut/pastes - if I have a column (multi-row) of text that I'd like to paste on several lines, can I do this without a regex? Usually just control+V (as v is characterwise selections and shift+v is line-wise selecting). However, if you've got mswin.vim being sourced, it might be remapped to control+Q * ctags variable name references - assuming I'm using ctags, how can I replace the name of a variable throughout my code base? Not sure on this one. One can add the files in question to the argument/buffer list and then use :argdo %s/foo/bar/g or :bufdo %s/foo/bar/g to change foo to bar across the files in question. Others may know more here. * regional undo - can I select a region, and perform an undo for all of the changes only in that region? Not as far as I know. * cvs/diff mode - what support does vim offer for these two apps, internal to the editor. Vim has an internal diff mode (or at least makes use of some sort of external diff tool): vimdiff file1.txt file2.txt or vim -d file1.txt file2.txt Alternatively, you can open the two files normally: vim file1.txt file2.txt and then use :diffthis :vert sn :diffthis or :vert sn :windo diffthis to open them both and configure them with diff settings. I'll be glad to RTFM for all of these things, however I don't know where to look them up - any pointers would be appreciated! Additionaly entry-points in the help would be :help complete :he complete-items :he compl-generic :he argdo :he windo :he bufdo :he blockwise-visual :he diff.txt :he diffthis :he diff :he :vert Hope this helps, -tim
Re: can vim do this?
On 8/3/06, Lev Lvovsky [EMAIL PROTECTED] wrote: I recently started work at a company where the predominant text editor happens to be emacs. I've been using vim for a while now, though only recently started getting into the more advanced functionality beyond simple editing (highlighting, folding, tags etc...). Watching one of my co-workers with emacs is pretty fun, as he does things fairly quickly - I asked him what his most common emacs actions were, to see how I could do them in vim: * autocomplete - say that I've declared a constant variable in Perl named MY_CONSTANT, later, to have the editor fill it in, I type in MY_, and some other key-stroke, and CONSTANT gets typed in for you :help ins-completion * goto when compiling - when compiling with make for example, and there is a problem in the code identified by a line, can vim somehow know to go to that line? this would be especially useful with 'make' :help quickfix * rectangular cut/pastes - if I have a column (multi-row) of text that I'd like to paste on several lines, can I do this without a regex? :help visual-use :help visual-block * ctags variable name references - assuming I'm using ctags, how can I replace the name of a variable throughout my code base? I don't know. However, :help tags can give you enough information to automate this to your taste. * regional undo - can I select a region, and perform an undo for all of the changes only in that region? I don't know. This is a neat idea, though. * cvs/diff mode - what support does vim offer for these two apps, internal to the editor. :help diff There are several available plugins that provide integration. In general, you can find plugins at http://vim.sf.net . (obnoxious plug: You can get my cvs integration plugin at http://vim.sourceforge.net/scripts/script.php?script_id=90 . Shortly you'll be able to get a new version for VIM 7 that includes subversion integration as well).
Re: Search and Replace with a Regular Expression
On Thu 3-Aug-06 9:49am -0600, Jürgen Krämer wrote: snipped Very nice explanation! Two minor cosmetic improvements are (1) to use Vim's line continuation to break up that very long line and (2) making the regex very magic (your use of comma eliminated 2 escapes, \v eliminates another 13 escapes. So: :%s,\\(\d\+\)[-/]\(\d\+\)[-/]\%(20\)\?\(\d\d\)\,\=(submatch(1) 10 ? '0' : '') . submatch(1) . '-' . (submatch(2) 10 ? '0' : '') . submatch(2) . '-' . '20' . submatch(3), becomes: :%s,\v(\d+)[-/](\d+)[-/]%(20)?(\d\d),\= \(submatch(1) 10 ? '0' : '') . submatch(1) . '-' . \(submatch(2) 10 ? '0' : '') . submatch(2) . '-' . \'20' . submatch(3) Also, I see Chip Campbell's interesting alternate suggestion using printf(): :%s/\(\d\{1,2}\)-\(\d\{1,2}\)-\(\d\{2,4}\)/\=printf('%02d\/%02d\/%4d',submatch(1),submatch(2),(submatch(3) 100)? (2000+submatch(3)) : submatch(3))/ Using semi-colon as a slash replacement in substitute (comma is used by the printf), extending to handle '-' or '/' in the date to be translated and permitting one digit years (as in today's 8/3/6): :%s;\v(\d{1,2})[-/](\d{1,2})[-/](\d{1,4}); \\=printf('%02d/%02d/%4d', \submatch(1), \submatch(2), \(submatch(3) 100) \? submatch(3) + 2000 \: submatch(3)) Finally, I see Tim Chase had another interesting alternative using substitute(): :%s!\\(\d\{1,2}\)[-/]\(\d\{1,2}\)[-/]\(\d\d\d\d\|\d\d\)\!\=substitute('0'.submatch(1), '.*\(..\)$', '\1', ''). '/'.substitute('0'.submatch(2), '.*\(..\)$', '\1', ''). '/'.(strlen(submatch(3)) == 4?submatch(3):(submatch(3)[0] == '0'?'20'.submatch(3):'19'.submatch(3))) Only changing the regex to make it very magic and adding line continuation (and eliminating one set of redundant parentheses): :%s!\v(\d{1,2})[-/](\d{1,2})[-/](\d\d\d\d|\d\d)!\= \substitute('0'.submatch(1), \'.*\(..\)$', '\1', '') . '/' . \substitute('0'.submatch(2), \ '.*\(..\)$', '\1', '') . '/' . \( \strlen(submatch(3)) == 4 \? submatch(3) \: submatch(3)[0] == '0' \? '20'.submatch(3) \:'19'.submatch(3) \) Not only does line continuation, IMO, make it easier to read in scripts, it is also much easier to read in mail. -- Best regards, Bill
Re: Search and Replace with a Regular Expression
For example, let's say I have some dates that look like this: 7-30-05 12-5-2006 10-2-06 What I'd like to end up with is this... 07/30/2005 12/05/2006 10/02/2006 Sorry this is a bit off topic: I just wanted to add that ms excel, or some databases, will recognize the data correctly, even if you supply them as is. You will not need to do any search and replace. At least, postgresql correctly recognizes the three examples you gave. Regards, Ben K. Developer http://benix.tamu.edu
Re: can vim do this?
On 2006-08-03, Tim Chase [EMAIL PROTECTED] wrote: * ctags variable name references - assuming I'm using ctags, how can I replace the name of a variable throughout my code base? Not sure on this one. One can add the files in question to the argument/buffer list and then use :argdo %s/foo/bar/g or :bufdo %s/foo/bar/g to change foo to bar across the files in question. Others may know more here. ctags identifies where symbols are defined, not where they're used, so I don't see how ctags could be used for this. cscope, on the other hand, collects much more information about symbols and could be used for this task. It integrates very well with vim. Did you mean ctags or cscope? I never do a global change like this without looking at what I'm doing, i.e., changing each instance one at a time. I use either :grep or :cscope find s to generate a quickfix list of all instances of the symbol, then traverse the quickfix list, changing the symbols as I go. (Actually, I use the quickfix list and :cnf to go from file to file and normal searching within files to find the symbols since :grep and :cscope return only line numbers, not column numbers.) HTH, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Wireless Division | Spokane, Washington, USA
Re: can vim do this?
On Thu, Aug 03, 2006 at 02:23:39PM -0700, Lev Lvovsky wrote: * regional undo - can I select a region, and perform an undo for all of the changes only in that region? This has been requested before, but it is not implemented and I do not expect that it will be added any time soon. The problem is how to define a region, when lines can be added, removed, or deleted at will. If you have a satisfactory answer to this question, you can fake a region-undo as follows. Delete the region to be changed; undo levels, or however many you choose; yank the same region; redo levels; paste. If you have a simple description of what constitutes a region, you could define a mapping or menu item to do this conveniently. I think all the other questions were answered by other posts on this thread. Let us know if you want more information on any of them. HTH --Benji Fisher
What is the information in the leftmost two columns and how do I turn it off?
I recently updated to vim 7.0 on a Gentoo Linux system. Since then, some, but not all, of my editing sessions start out normally. After a second or two, though, the file is shifted right two columns and numbers appear in the first column and signs in the second column. What does this mean? How can I turn it off?