Re: Multiple search highlights?
Ron Olson schrieb: Hi all- I just recently joined this list after using Vim for awhile, and vi since, gosh, 1990 on a Vax. I'm astounded how, over the years, vi (and now Vim) have served my needs pretty much perfectly; what other editor is available on everything, has every feature you could possibly want, and is fast. That said, there is a feature I do want, or maybe it's already there but I can't figure out how to do it: multiple highlights. What I mean by this is, typically I look for a string like "foo" in vim with /foo, and it highlights all occurrences in the file (standard behavior). What I need is to be able to search for something else (which I believe I could do by searching using a regex), but I would like that second thing to be in another color a la Google's search results (at least in dejanews). What I need, eventually, is an angry fruit salad of colors for all the search items I've entered. Is this currently doable, and if not, do you think it's possible to accomplish using a plugin? Thanks, :h :match :h :2match -- HTH, Andy
Re: Open all folds in the current fold?
Tim Chase schrieb: I'm trying to find/create a command that acts somewhat like zO/zR for within an existing fold. If I use zR, it opens all the folds in the whole document. If I use zO, it opens all the folds under the cursor. The behavior I'm looking for is that if I'm within an existing fold, it recursively opens all the folds within the current fold: --- line 1 | line 2 with cursor here |-- line 3 || line 4 ||+ line 5 (3 lines) || line 8 ||+ line 9 (5 lines) |+ line 10 (20 lines) |+ line 30 (15 lines) | more stuff after the fold + some other fold I don't want to touch With the cursor on line two, I'd like to recursively open all the folds in the containing fold (lines 1 through "more stuff"). Using zO does nothing because there's no currently closed fold under the cursor even though there are other folds within the currently containing fold. Using zR opens lines such as the "some other fold I don't want to touch" line which is more than I want to unfold. Any hints on this? I've toyed a little with :folddoclosed but it seems to be closer to zR than I want for my purposes. Thanks, -tim zO on visual area recursively opens all folds in it. mc[zV]zzO`c -- Regards, Andy
Re: copying text char-by-char from the line above line..
Ajay Gupta schrieb: Hi All, I saw one of my friends (once!) copying the text from the line right above. He was using some keycombo and it would appear like he was copying the characters one-by-one. So, if there are two lines like quick brown fox I see and on the 2nd line, after 'see', i wanted to copy 'brown fox' from the 1st line, I will just keep pressing that keycombo 9 times. I know how to copy the full line, text till some character, etc. But, I was just wondering how to do the above. Does anybody know how to do this? thanks... Ajay :h i_Ctrl-Y -- Regards, Andy
Re: A performance question
A.J.Mechelynck schrieb: Robert M Robinson wrote: First, thanks very much for creating VIM! I have been using it on Linux systems for years, and now use it via cygwin at home as well. I vastly prefer VIM to EMACS, especially at home. I learned vi on a VAX/VMS system long ago (a friend of mine had ported it), when our computer science department was loading so many people on the VAXen that EDT was rendered unusably slow. I still like VIM largely because I can do so much with so little effort in so little time. That brings me to my question. I have noticed that when editing large files (millions of lines), deleting a large number of lines (say, hundreds of thousands to millions) takes an unbelieveably long time in VIM--at least on my systems. This struck me as so odd, I looked you up (for the first time in all my years of use) so I could ask why! Seriously, going to line 1 million of a 2 million line file and typing the command ":.,$d" takes _minutes_ on my system (Red Hat Linux on a 2GHz Athlon processor (i686), 512kb cache, 3 Gb memory), far longer than searching the entire 2 million line file for a single word (":g/MyQueryName/p"). Doing it this way fits way better into my usual workflow than using "head -n 100", because of course I'm using a regular expression search to determine that I want to truncate my file at line 100 in the first place. I looked in the archive, and couldn't see that this issue had been raised before. Is there any chance it can get added to the list of performance enhancement requests? Thanks, Max Robinson, PhD I think this is just "part of how Vim behaves". When you edit a file, Vim holds the whole file in memory (IIUC). When you delete a million lines, Vim frees (i.e., releases to the OS) the memory those lines were using. That takes some time. Best regards, Tony. What about the numbered registers? :h "1 After freeing the lines, they are copied to "1 . And the content of "1 is shifted to "2 (before, of course) And so on, until register "9. To avoid the copies, the blackhole register can be used: :.,$d _ If there are copies, registeres can be cleared by hand: :let @1 = "" :let @2 = "" ... :let @9 = "" This also takes time, but frees the memory. -- Regards, Andy
Re: Go to start of visual selection
Andy Wokula schrieb: Tim Chase schrieb: How can I move the cursor the start of the visual selection? With the "o" command, yes. But how can I make sure the cursor is at the start while visual mode is on? The "`<" motion followed by "gv" sets the cursor back to the end if it was there. I think it sounds like you want something like the following: vnoremap gt `>:exec 'norm '.visualmode().'`' vnoremap gb `:exec 'norm '.visualmode().'`>' which gives you a "Go to the Top" and "Go to the Bottom" mapping within visual mode. It can be a little funky in blockwise visual-mode, if your '< and '> points are top-right and bottom-left (rather than top-left and bottom-right), as the "top" will go to the top-right, not the top-left. I haven't figured out a good way to do this without considerably more code in the mapping (save the column of '< and then "gvO" to go back to visual-mode but in the other corner and then compare the columns to see which you want, perhaps needing to switch back...it's ugly). However, it should work fine in character-wise and line-wise visual modes. HTH, -tim I don't understand why this works. There must be a difference between `>v`< and :normal `>v`< "v" defines a new visual area and overwrites the `<,`> markers. Why does "`<" after ":normal" move the cursor to the start of the _previously_ selected visual area? Thx, Andy Ah, with a later Vim7 there is no difference any more. Obviously this has been fixed with patch 125, dated August 2006. Ok, this took three months till I got it ... -- Regards, Andy
Re: comments after brackets with vim?
Simon Butler schrieb: hi, when i write this skill (cadence extension language) fragment in emacs i get the following: procedure( vscCheckpointHier( @key lib cell view message inclibs ) let(( ddCVs ) vscPrint0(sprintf( nil "Hierarchy for %s,%s,%s ..." lib cell view )) when( ddCVs = vscGetHierarchyDDs( ?lib lib ?cell cell ?view view ?inclibs inclibs ) vscPrint0(sprintf( nil " %d cellviews." length(ddCVs) )) vscCheckpoint( ddCVs ?message message) ); when ddCVs ); let ); procedure vscCheckpointHier Notice all the comments placed on the closing brackets. Is there a way to make vim do this? TIA Yep. I just felt the challenge, so I wrote the attached script. I don't know skill, but I think this comes close to what you want. Core elements: :imap ; ... searchpair() Hopefully, filetype "skill" is what you currently use for those kind of files. -- Regards, Andy EOM " Vim filetype plugin code snippet " Language: skill (cadence extension language) " File: skill_comment.vim " Date: 2007 Mai 14 " Author: Andy Wokula <[EMAIL PROTECTED]> " Description: " After inserting ");", insert the word located before the matching " opening paren; for some keywords also add their argument. To work " properly, all must be found on the same line. " " Installation: (suggestion) " 1. make sure filetype "skill" is detected " 2. copy this script to ~/.vim/ "(to the first entry of 'runtimepath') " 3. :edit " ~/.vim/after/ftplugin/skill.vim "add the following line: " runtime skill_comment.vim " " TODO: " - ignore ");" in comments " - ignore (possibly unbalanced) parens in comments " - extend s:keywords if v:version < 700 " sorry, Vim7 required finish endif " Mapping for ";" in Insert mode ino ; CloseKeyword() " search for arguments to these keywords: let s:keywords = ['procedure', 'when'] " (to be extended) function! CloseKeyword() if getline(".")[col(".")-2] != ')' " if char just before ";" is not ")" return ";" " (Note: first getline index is 0, first col is 1) endif " move cursor to closing paren (this is allowed) call cursor(".", col(".")-1) " get position of matching paren: let pomp = searchpairpos('(','',')','bW') " [line, column] if !pomp[0] return ";" endif " getline of matching paren let glineomp = getline(pomp[0]) " get matching keyword: let word = matchstr(glineomp[: pomp[1]-2], '\k\+\ze\s*$') if word == "" return ";" endif if match(s:keywords, '\<'.word.'\>') >= 0 " search for argument let kwarg = matchstr(glineomp, '\k\+', pomp[1]) " omit trailing space if no argument found return "; " . word . (kwarg!="" ? " ".kwarg : "") else return "; " . word endif endfunction
Re: vim 7.1 and cr/lf interpretation
Thomas Michael Engelke schrieb: :set fileformats? gives "fileformats=dos,unix", so both formats are available, yet the detection and switching does not seem to work. Are you sure _every_ line ends in "^M"? -- Regards, Andy EOM
Re: Vim and email quoting
Timothy Knox schrieb: I use vim to write my outgoing email, and for the most part, it rocks. Thanks to all the folks who have written modules and provided tips that make it the best thing for writing email since mailx . That said, there is one small annoyance I find: When replying to an email, I like to intersperse the original email with my commentary. When I am on the last line of a paragraph I wish to respond to, I hit "o" to open a new line. All well and good, save that something recognises the leading "> " of the previous paragraph, and adds one to my new line. Can somebody tell me how to make it stop? ;-) Many thanks to you all. :-) Add the following line to ~/.vim/after/ftplugin/mail.vim : setlocal fo-=o Create the path or file if it doesn't exist. -- Regards, Andy EOM
Re: autocomplete on the command line from words in buffers
Larson, David schrieb: Hello Dan, I suggest wrapping these functions into vim commands and then leverage the command completion feature. See: :help :command-completion HTH, David -Original Message- From: Dan Fabrizio [mailto:[EMAIL PROTECTED] Sent: Monday, May 07, 2007 5:27 AM To: vim@vim.org Subject: FW: autocomplete on the command line from words in buffers Hello All, I want to develop a plugin just using vim scripts for the verilog language. In the plugin I have functions that require arguments that are words used in the current open buffers. On the command line, I want to autocomplete these words that are arguments to functions. For example: :call function1("last_","first_") In open buffers, the words called last_buffer_value and first_buffer_value are used. So when I hit I want that word to be completed so the result would be :call function1("last_buffer_value","first_buffer_value") Is there a way to do this? Thanks in advance, Dan Fabrizio IMHO this will become difficult. In Insert mode, Ctrl-N/Ctrl-P scans through the buffers for words, but I think there is no way to make Vim provide a similar list of completions in the command-line. You have to (kind of) scan the buffers yourself ... Please correct me if I'm wrong -- Regards, Andy EOM
Re: Avoiding German Umlauts....
A.J.Mechelynck schrieb: Andy Wokula wrote: A.J.Mechelynck schrieb: [...] Note that the official transliteration of the eszett is not sz but ss: upcase("ß") is "SS" and, in de_CH locales, the eszett is not used (other than for "archaic" look, sometimes together with a Fraktur font); ss is used in its stead everywhere. IMHO "sz" is ugly, but unique. There is no upper "ß". Best regards, Tony. Strictly speaking, there is no _titlecase_ ß because that letter must always follow a vowel. There is an uppercase equivalent of ß, which is SS, as shown by the fact that, for instance (in modern German spelling, I'm not talking of 19-th century spelling), the uppercase counterpart of "schließen", for use in all-caps titles, is "SCHLIESSEN", not "SCHLIESZEN" or "SCHLIEßEN". (I've seen a German atlas printed between 1871 and 1918, where the name of Russia was spelled "RUSZLAND".) Also I'm not talking about the Vim ~ operation here (which is not normative) but about upcasing rules as decided by whoever decides that in German-language countries (it used to be Duden but IIUC it isn't anymore) and put down in the upcasing-downcasing rules which are (IIUC) included in the Unicode Standard. Interesting. I wasn't aware of that the rules of new german spelling dumped the "sz" completely. "there is no upper ß" should express that there is no non-ASCII uppercase equivalent of "ß" that can occur in a text and needs translation into "SS". "sz" is unique (i.e., reversible) but since the OP doesn't want an eszett in his text, how does reversibility concern him? "ss" is the official graphy in Switzerland as well as wherever an ß glyph is not available. It's true that there is no obvious "mechanical" rule (without a dictionary, I mean) to convert Fuss to Fuß but Fluss to Fluss. Using "ss", some words get a different meaning, e.g. "Maße" vs. "Masse". Although in most (if not all) cases context should make it clear which meaning applies. Best regards, Tony. -- Regards, Andy EOM
Re: Avoiding German Umlauts....
A.J.Mechelynck schrieb: [EMAIL PROTECTED] wrote: Hi, I want to write a macro, function or what else, which ensures, that no german umlauts (äöüÄÖÜ) or the "sz" (ß) will ever occure in any file written with vim. It does not matter, if these charactes will appear while typing but they should never and under no circumstances be saved to disk. Best solution however would be, if they were changed "on the fly" to their replacements: umlaut a ä -> ae umlaut o ö -> oe umlaut u ü -> ue umlaut A Ä -> Ae umlaut O Ö -> Oe umlaut U Ü -> Ue "sz" ß -> sz I did some experiments, which had worked under some circumstances and did not under others. But I need something, which does the replacements under any condition. Keep editing! mcc just another variant ... Method I: will remove all umlauts in all files, even preexisting ones (if any) at write-time. scriptenc latin1 function ConvertUmlauts() " range is whole file let udict = {'ä':'ae', 'ö':'oe', 'ü':'ue', \'Ä':'Ae', 'Ö':'Oe', 'Ü':'Ue', \'ß':'sz'} %s/[äöüÄÖÜß]/\=udict[submatch(0)]/ge endfunction autocmd BufWritePre * call ConvertUmlauts() Method II: will remove umlauts only as you type them. Anything preexisting will remain untouched. Method II a) use a keymap :h :lmap (keymaps use :lmap to define mappings) File ~/.vim/keymap/umlauts.vim " Vim Keymap scriptenc latin1 let b:keymap_name="de_uml" loadkeymap ä ae ö oe ü ue Ä Ae Ö Oe Ü Ue ß sz Argument of :scriptenc is at your taste/needs, I just suggest to not skip the command because of the non-ascii chars. Load the keymap: :set keymap=umlauts Toggle keymap on/off: :h i_Ctrl-^ From the help: ":lmap" defines a mapping that applies to: Insert mode, Command-line mode, when entering a search pattern, commands with a character argument (r, f) (won't probably work here), and for the input() line. These two solutions are not exclusive of each other: they can be applied together. Note that the official transliteration of the eszett is not sz but ss: upcase("ß") is "SS" and, in de_CH locales, the eszett is not used (other than for "archaic" look, sometimes together with a Fraktur font); ss is used in its stead everywhere. IMHO "sz" is ugly, but unique. There is no upper "ß". Best regards, Tony. -- Regards, Andy EOM
Re: strange commenting behaviour (text gets deleted)
Andy Wokula schrieb: Daniel Nogradi schrieb: [...] This function is a modified version of something I found in one of the tips or scripts of the vim website. For C I use of course Komment2('/* ', ' */') and this works perfectly well, I can select a block of lines, call the above function and every line will be commented out. It even works in a toggling way, so commented lines will be uncommented. So far so good, now comes the strange behaviour. If there is a line which only contains a { character and that line is commented out so it looks like /* { */ and then I call the above function to uncomment it, everything below this line will be deleted. It's probably unrelated It is very related ... but just in case I mention that I have the following syntax method set: syn region myFold start='{' end='}' transparent fold set foldmethod=syntax I just reproduced what happens: With the (syntax) fold opened, go to the first / of the comment /* { */ Then press "x" (or "3x" as the function does), this will remove the / and CLOSE THE FOLD (WHY??) The next "3x" will then remove the whole fold. While trying this out, I had ft=vim set. It obviously happens with filetype C too. It doesn't happen with some other filetypes. Currently, I have no idea what's going on ... IMHO there is nothing wrong, at least with Vim. In fact, it's all about how syntax folding works. In order to fold code, your additional syntax rule syn region myFold start='{' end='}' transparent fold set foldmethod=syntax must get a chance to match text. But as long as the '{' within /* { */ is hidden by the comment, your rule is not applied and therefore doesn't fold anything. Now if '/* ' is removed, resulting in { */ the Highlighter suddenly matches '{' with your rule and closes the fold (depending on foldlevel etc.) In a Vim script, the effect is the same, but for different reasons. The line /* { */ is matched by the vimSearch group, hiding the '{' in it, but the text { */ again allows a match for '{' at top-level. -- Regards, Andy EOM
Re: strange commenting behaviour (text gets deleted)
Daniel Nogradi schrieb: > Hi vimmers, > > I have a very strange problem and couldn't figure out what's going on. > I use the following function for commenting out a line or a block of > lines: > > > function! Komment2(commentLeader, commentTrailer) >if match( getline("."), "^\ *$" ) < 0 >let save_cpo = &cpoptions >let save_paste = &paste >set cpo&vim >set paste >let escCommentLeader = escape(a:commentLeader, '^[.*\~]$') >let escCommentTrailer = escape(a:commentTrailer, '^[.*\~]$') >if getline(".") =~ '^\s*' . escCommentLeader . '.*' . > escCommentTrailer . '$' >execute "normal ^" . strlen(a:commentLeader) . "x$" . _ ,--^ Workaround: insert "zv" between "x" and "$" to make sure the fold is open. :h zv > strlen(a:commentTrailer) > . "hl" . strlen(a:commentTrailer) . "x" >else >execute "normal I" . a:commentLeader . "\" . "A" . > a:commentTrailer . "\< > ESC>" >endif >let &cpo = save_cpo >let &paste = save_paste >endif >echo > endfunction > > > This function is a modified version of something I found in one of the > tips or scripts of the vim website. For C I use of course > > Komment2('/* ', ' */') > > and this works perfectly well, I can select a block of lines, call the > above function and every line will be commented out. It even works in > a toggling way, so commented lines will be uncommented. So far so > good, now comes the strange behaviour. > > If there is a line which only contains a { character and that line is > commented out so it looks like /* { */ and then I call the above > function to uncomment it, everything below this line will be deleted. > > It's probably unrelated It is very related ... > but just in case I mention that I have the > following syntax method set: > > syn region myFold start='{' end='}' transparent fold > set foldmethod=syntax I just reproduced what happens: With the (syntax) fold opened, go to the first / of the comment /* { */ Then press "x" (or "3x" as the function does), this will remove the / and CLOSE THE FOLD (WHY??) The next "3x" will then remove the whole fold. While trying this out, I had ft=vim set. It obviously happens with filetype C too. It doesn't happen with some other filetypes. Currently, I have no idea what's going on ... Thanks for the explanation, that's indeed what seems to be happening, but I still couldn't find a good way to circumvent it. How do other people deal with syntax folding and commenting? E.g. search on vim.org for "comment". I'd try to avoid Normal mode commands: function! Komment3(Leader, Trailer) let line = matchstr(getline("."), '\S.*') if line == '' return endif let indent = matchstr(getline("."), '^\s*') let pat = '^\V'.escape(a:Leader, '\') . '\(\.\*\)' let pat .= escape(a:Trailer, '\').'\$' if line =~ pat call setline(".", indent . substitute(line, pat, '\1', '')) else call setline(".", indent . a:Leader . line . a:Trailer) endif endfunction -- Regards, Andy EOM
Re: strange commenting behaviour (text gets deleted)
Daniel Nogradi schrieb: Hi vimmers, I have a very strange problem and couldn't figure out what's going on. I use the following function for commenting out a line or a block of lines: function! Komment2(commentLeader, commentTrailer) if match( getline("."), "^\ *$" ) < 0 let save_cpo = &cpoptions let save_paste = &paste set cpo&vim set paste let escCommentLeader = escape(a:commentLeader, '^[.*\~]$') let escCommentTrailer = escape(a:commentTrailer, '^[.*\~]$') if getline(".") =~ '^\s*' . escCommentLeader . '.*' . escCommentTrailer . '$' execute "normal ^" . strlen(a:commentLeader) . "x$" . strlen(a:commentTrailer) . "hl" . strlen(a:commentTrailer) . "x" else execute "normal I" . a:commentLeader . "\" . "A" . a:commentTrailer . "\< ESC>" endif let &cpo = save_cpo let &paste = save_paste endif echo endfunction This function is a modified version of something I found in one of the tips or scripts of the vim website. For C I use of course Komment2('/* ', ' */') and this works perfectly well, I can select a block of lines, call the above function and every line will be commented out. It even works in a toggling way, so commented lines will be uncommented. So far so good, now comes the strange behaviour. If there is a line which only contains a { character and that line is commented out so it looks like /* { */ and then I call the above function to uncomment it, everything below this line will be deleted. It's probably unrelated It is very related ... but just in case I mention that I have the following syntax method set: syn region myFold start='{' end='}' transparent fold set foldmethod=syntax I just reproduced what happens: With the (syntax) fold opened, go to the first / of the comment /* { */ Then press "x" (or "3x" as the function does), this will remove the / and CLOSE THE FOLD (WHY??) The next "3x" will then remove the whole fold. While trying this out, I had ft=vim set. It obviously happens with filetype C too. It doesn't happen with some other filetypes. Currently, I have no idea what's going on ... -- Regards, Andy EOM
Re: how to avoid deleting the auto-indent in a new empty line when i press
Gary Johnson schrieb: On 2007-04-16, fREW <[EMAIL PROTECTED]> wrote: On 4/16/07, Tom Whittock <[EMAIL PROTECTED]> wrote: What I need is to always keep the auto-indented spaces. So next time I can start to insert from the spaced cursor. Alternatively use cc to edit the ostensibly blank line. This will open the line using the correct auto indent. Get into this habit and it doesn't matter what state the line was in before - you always get the right indentation. Cheers. I tried cc and S and neither of them correctly reindented the line for me. What gives? It may depend on the indentation mechanism being used. That is, on whether you're using 'autoindent', 'cindent', 'indentexpr' or something else. For example, it works fine when I edit C code (with 'cindent' set) but not in this e-mail (with only 'autoindent' set). If I indent this paragraph, then try to add a line below the last line by typing S or cc on that empty line, the new line starts in column 1. I don't know why that is. Regards, Gary :h 'ai | Copy indent from current line when starting a new line (typing in | Insert mode or when using the "o" or "O" command). cc uses the indent of the current line. Thus if it is empty there is no indent. Try using :setl inde=indent(v:lnum-1) -- Regards, Andy EOM
Re: Troubles configuring vim (multi-questions)
OnionKnight schrieb: I think I understand the difference now and my function is pretty neat now. function! HomeKey () let c = col(".") if c == 1 normal ^ else normal ^ if col(".") >= c normal 0 endif endif endfunction quote= comes handy: :noremap @=col(".")==1?"^":"0" :imap Noremap because it also works for Visual mode. -- Regards, Andy EOM
Re: case of very slow regex search
Yakov Lerner schrieb: I use sometimes the regex that finds paragraphs containing given words w1,w2,... in any order ( I define "paragraph" as separated by lines, \n\n). I use the pattern like this: (two-word example, w1 and w2, but easily expandable for N words): /\c\(.\|.\n\)*\\&\(.\|.\n\)*\ (and I set :set maxmempattern=2 ) This works. But search time is unbelievably slow on big files. My question is; is there a rewrite of this regex that works faster. To see the testcase how of how slow this works: 1. wget http://www.vmunix.com/~gabor/c/draft.html # this is ~1.3 MB file. 2. vim draft.html 3. /\c\(.\|.\n\)*\\&\(.\|.\n\)*\ This search never finishes for me. How can I rewrite the regex to search faster ? Yakov Prepeding \n\n\zs helps ... -- Regards, Andy EOM
Re: Question about b:did_ftplugin
Thomas schrieb: Now, when I do set ft=X from the command line, it happens that the ftplugin X doesn't get loaded because it finishes when b:did_ftplugin is set. What I actually meant by this was: the ftplugin X doesn't get loaded when a filetype was already set before, i.e. when a filetype plugin already defined b:did_ftplugin. ftplugins should define b:undo_ftplugin . :h undo_ftplugin If this var exists and its commands get executed then (only then) also b:did_ftplugin will be unset. Executing b:undo_ftplugin is one of the first things :setf X tries to do. Thanks, in the meantime I already found this help page. But it doesn't seem to solve the problem. Here's what I do (vim is 7.0-204): in ~/.vim/ftplugin/test.vim if &cp || exists("b:did_ftplugin") echom 'b:did_ftplugin already set!' finish endif let b:did_ftplugin = 1 echom "Test ftplugin!" on the command line: gvim -u NONE in vim: :set nocompatible :syntax on :filetype plugin on :help :set ft=test Result: 'b:did_ftplugin already set!' is printed in the echo area. b:did_ftplugin obviously is set by the help ftplugin (b:undo_ftplugin is set to "setl fo< tw<") but is never unset. Ok. There has been an error in the earlier help ftplugin (from 2006-04-19). Are you sure your help ftplugin sets :let b:undo_ftplugin = "setl fo< tw<" and not :let b:undo_plugin = "setl fo< tw<" (?) In the latter case, update your runtime file(s) and try again. Is this really the intended behaviour? Is the user meant to manually unlet b:did_ftplugin in such a situation? Do I misunderstand here something quite fundamentally? Regards, Thomas. No, no, no :-) -- Regards, Andy EOM
Re: Question about b:did_ftplugin
Thomas schrieb: Hi, When I set a filetype for a buffer the variable b:did_ftplugin is set. The help says: If you are writing a filetype plugin to be used by many people, they need a chance to disable loading it. Put this at the top of the plugin: > " Only do this when not done yet for this buffer if exists("b:did_ftplugin") finish endif let b:did_ftplugin = 1 Now, when I do set ft=X from the command line, it happens that the ftplugin X doesn't get loaded because it finishes when b:did_ftplugin is set. When is b:did_ftplugin ever unset? What's the rationale of setting b:did_ftplugin and not b:did_ftplugin_X? Regards, Thomas. ftplugins should define b:undo_ftplugin . :h undo_ftplugin If this var exists and its commands get executed then (only then) also b:did_ftplugin will be unset. Executing b:undo_ftplugin is one of the first things :setf X tries to do. -- Regards, Andy EOM
Re: Vim Help for deleting alternate lines in text
Gary Johnson schrieb: Auro Ashish Saha wrote: Hello, Please help me to remove alternate lines from a text file. 00 0 123456 9 99 9 123445 9 I want to delete the line 1, 3, 5 and so on. What are the commands to be used. Thanks for help in advance. Method I: q"ddjjq @" where is equal to the number of lines still to be deleted This version will work: qqddjq @q Note that it uses the q register instead of the " register. Also, if you don't want to try to figure out what should be, and if you don't want to remove a huge number of lines, you can execute the recorded commands the first time after you record them with this command: @q and every subsequent time with this command: @@ That way, once you've recorded the command and executed it once from the q register, you can just hold your finger on the @ key and watch the lines disappear. As you get close to the bottom of your file, you can start slowing down and typing just two @'s at a time. Macros stop if an error (-> beep) occurs [EMAIL PROTECTED] will stop if end-of-file reached because "j" cannot go further. Method II (all on one line if typed on the Vim command-line): :let i=1 | while i <= line('$') | if (i % 2) | exe i . "delete" | endif | endwhile It looks as though Tony left out part of Method II: i is never incremented. I modified it as shown below (added "let i += 1 |")and verified that it works. :let i=1 | while i <= line('$') | if (i % 2) | exe i . "delete" | endif | let i += 1 | endwhile HTH, Gary Method III: :2,$-1g/^/+1d :1d -- Regards, Andy EOM
Re: two questions , map and scroll
shawn bright schrieb: lo there, i have two quick questions. first, is there a way i can scroll text under the cursor ( so that the cursor stays on the same place in the terminal, but the text scrolls anyway ) i just think that would be really cool. Without mappings: " keep cursor in same column :set nostartofline " global, also has influence on other commands " how many lines to scroll :set scroll=1 " local to window Then use Ctrl-D and Ctrl-U. A count changes the value of 'scroll'. Don't miss the help: :h 'sol :h 'scr -- Regards, Andy EOM
GVim Crash
GVim7 (Win32) crashes if I do the following: " clean startup :new :tabnew :call winnr("#") " happens with or without 219 patches included Andy -- EOM
Re: Selecting tag opens file in a new tab - how?
A.J.Mechelynck schrieb: Zarko Coklin wrote: I posted following question some time back: ~ Is it possible to have a setup in .vimrc so that every time I select tag either through "CTRL-]" or by holding CTRL and pressing left mouse click to open a new buffer in a new tab? and got following answer that works: :map :exe "tab stag" expand("") :map :exe "tab stag" expand("") ~ The trouble I am having at the moment is that this approach leads to a quick proliferation of open file tabs. Ideally, Vim should not open a new tab for the the file that already has a tab. Rather, it should simply reuse an existing tab and position itself within an open tab. Is there a way to get that done? Thanks in advance, Zarko I think it is possible, but not easy, and would require writing a custom function, especially if you want to still be able to have split windows. I'm not going to try. You may want to try for yourself, or change your behaviour. See, among others: :help tabpagenr() :help tabpagewinnr() :help tabpagebuflist() :help bufname() etc. Best regards, Tony. Another idea: Usage of 'switchbuf' :set switchbuf=useopen,usetab Problem: Works with buffer names only -> Get filename of tag and search it in the buffer list i.e. (first move cursor to tag) :exe "tab sbuf" taglist(expand(""))[0].filename HTH, Andy -- EOM ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: Count characters
Tim Chase schrieb: Is there some function or script to count characters (letters without whitespaces) in vim? For example Kile the Latex Editor has such a feature to control how long texts are. You can use :%s/\w/&/g which will report back "X substitutions on Y lines". "X" represents the number of characters of interest. Adjust the "\w" regexp for whatever constitutes your definiton of "characters" that you want to count. Thus, this might be :%s/\a/&/g "(only letters) :%s/\S/&/g"(non-whitespace) Or any other such combo. It does have the side effect of "modifying" your document (setting the "modified" flag). If this is a problem, you can "u"ndo it and it should revert. It also requires that the document not be readonly (or at least it will gripe if it is, warning you that you're changing a RO document). If you have fewer than 'report' characters, Vim won't report back: :help 'report' but you can set this to :set report=0 to always report any changes. There are ways to do it on non-modifiable buffers, but they require a bit more programatic logic, such as :let x=0 :g/^/let x+=strlen(substitute(getline('.'), '\W', '', 'g')) :echo x where the '\W' is the inverse-set of characters of interest. In this case, if you're interested in "\w" characters, the "\W" is the inverse. If you're interested in non-whitespace characters ("\s"), you would use "\S"; and if you're interested in counting vowels, you could use "[^aeiouAEIOU]". You might even notice that the second version uses a :g command that matches every line. With this, you have a lot of flexibility: :'<,'>g/^/let ... " counts characters in the linewise selection :g/foo/let ..." counts characters on lines containing "foo" and the like. All sorts of fun things at your disposal :) Hope this helps, -tim Therefore in Vim7 the 'n' flag was added to the substitute command: :%s/\S/&/gn just reports the number of matches. Works also for read-only files, because no text is changed. :h :s_flags Andy -- EOM ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: Vim Help for deleting text
Arnaud Bourree schrieb: Arnaud Bourree wrote on 20/03/2007 10:22: Tim Chase wrote on 19/03/2007 23:01: Or, if all your columns align, you can use visual-block mode with control+V to create a block across the characters in question, and then just hit "d" to delete. -tim Sorry, I'm begginer with VIM (Windows XP). When I want to select a block with my mouse, I can't select column block. How can I switch to line mode to column mode? I reply myself with help file content: Since CTRL-V is used to paste, you can't use it to start a blockwise Visual selection. You can use CTRL-Q instead. You can also use CTRL-Q in Insert mode and Command-line mode to get the old meaning of CTRL-V. But CTRL-Q doesn't work for terminals when it's used for control flow. If you're happy with the current setting of Ctrl-V, try the following: First select text characterwise with your mouse, then open context menu -> Select Blockwise or Press the Alt key while making your selection (e.g. place cursor, press and hold down Alt, click end of selection) or use a map like the following in your vimrc to make "v" toggle visual mode between characterwise and blockwise: :vno v :exe"norm!"visualmode()==#"v"?"gv\c-v>":"gvv" Andy -- EOM ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: Get date and filename as plain text
Wolfgang Schmidt schrieb: Hi, I don't know about the filename part, but you could insert a date with the following mapping: inoremap @date =strftime("%d.%m.%Y") Cheers, Wolfgang Eric Leenman wrote: Hi, Is it possible to make an inoremap that inserts the date as text and the filename as text? For example: inoremap @date {insert_date_as_text()} inoremap @filename {insert_filename_as_text()} Rgds, Eric " including path :inoremap @filename =expand("%:p") " without path: :inoremap @filename =expand("%:t") :h i_CTRL-R :h filename-modifiers :h expand() If there is still no filename, nothing is inserted. Andy -- EOM ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: clone a vim session into a new tab
Kamaraju S Kusumanchi schrieb: Andy Wokula wrote: Ok tabpages are included in the session per default. Try :set sessionoptions-=tabpages first. Awesome! Thanks a lot! :help 'sessionoptions' The help is a bit confusing. It says There is no option to include tab pages yet, only the current tab page is stored in the session. |tab-page| But in reality, it stores all the tab pages. Is this a bug in the documentation? or am I misreading something? raju Confuses me too. Looks like some forgotten beta version note. Andy -- EOM ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: clone a vim session into a new tab
Kamaraju S Kusumanchi schrieb: Andy Wokula wrote: Simple way (recommended or not, at least quick) with sessions: :mks " use ! to overwrite existing Session.vim :tabnew :so Session.vim Just guessed it might work and it works. Now I think sessions don't include tabpages. This works although I use tabe instead of tabn. But there is a small problem. If I have three already existing tabs, and if I want to clone only the second tab into a new tab then it does not work. Any other suggestions? thanks raju Ok tabpages are included in the session per default. Try :set sessionoptions-=tabpages first. :help 'sessionoptions' Then use again :mks " use ! to overwrite existing Session.vim :tabnew :so Session.vim Andy -- EOM ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: clone a vim session into a new tab
Kamaraju S Kusumanchi schrieb: Let's say I opened a 6 files in a 3X2 grid inside vim. Now I want to clone this and have all the files at the same position, same window sizes etc., and put it into a new tab under the same vim session. Is there a command to do this? commands like tabe etc., open only a single file. But I want to open about 6 files and have the correct window sizes etc., Any ideas? raju Simple way (recommended or not, at least quick) with sessions: :mks " use ! to overwrite existing Session.vim :tabnew :so Session.vim Just guessed it might work and it works. Now I think sessions don't include tabpages. Andy -- EOM ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: visual problem
Simon Jackson schrieb: I have a problem when i am in visual mode and i have text highlighted. Instead of being able to run a command, it just overwrites my selected text instead. im sure its because of something in my vimrc but i just cant pinpoint it, can anyone help? P.S.: If anyone sees some errors in my vimrc or maybe how something can be done more efficiently please let me know. filetype on " detect the type of file filetype plugin indent on" enable filetype plugin second line is enough set gdefault " Use 'g' flag by default with :s/foo/bar/ Can result in obscure errors with some badly written plugin, that does not reset 'gdefault' to the default. ! Looks like you're not happy with set selectmode=mouse,key,cmd au FileType helpfile set nonumber " no line numbers when viewing help au FileType helpfile nnoremap " Enter selects subject au FileType helpfile nnoremap " Backspace to go back Does this work for you? On helpfiles, :set ft? returns "help", not "helpfile". highlight Pmenu guibg=black gui=bold Works as long as you don't change colorschemes. Andy -- EOM ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: How to paste without replace the content in buffer
Peng Yu schrieb: Hi, Suppose I want to replace "string1" with "string2" in a file from vim. 1. Highlight "string1" (in visual mode) and then type "y". 2. Highlight "string2" (in visual mode) and then type "p". However, the problem with the above procedure is that "string2", instead of "string1", is in buffer. That is if I highlight "string3" and then type "p", "string3" will be replaced with "string2" instead of "string1". I'm wondering if there is any way to avoid change the content in the buffer? Thanks, Peng The Vim teacher already taught you ^^, so here is a hint _why_ this happens: :help put-Visual-mode | (Implementation detail: it actually works by first putting the | register after the selection and then deleting the selection.) Obviously, the selection is deleted into the unnamed register, changing it. Andy -- EOM ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: Insert new blank line in normal mode
A.J.Mechelynck schrieb: Alexey Vakhov wrote: Hi Dear community, Command o and O create new line and switch to insert mode. I want only insert blank line and stay in normal mode. I know this problem can be solved using simple mappting, but maybe in vim there are original commands for this tip? Thanks a lot IIUC there are no intrinsic commands for this; but you could use o O at the keyboard, or :put ='' :.-1put ='' For some reason :put_ :put!_ also work. Another odd detail, in fact nothing should be inserted (?) because the "black hole" register is always empty. in a script. Best regards, Tony. Andy -- EOF ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: Marking an undo-block before ^U in insert-mode
A.J.Mechelynck schrieb: Andy Wokula wrote: There is another strange detail about u In my vimrc I have (for gVim 6.4, gVim 7.0) :imap u Each "u" goes back one line of text in the undo history. Note the "imap" instead of "inoremap". This way abbreviations still work. For the strange part: This mapping does not result in an endless loop! I don't know why ... just found out by trial and error, could someone explain this? Andy see ":help recursive-mapping" Shortly put: A mapping never re-expands its {lhs} at the start of the {rhs} Best regards, Tony. Thanks for the hint :-) Regards, Andy -- EOF ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: Marking an undo-block before ^U in insert-mode
Yakov Lerner schrieb: On 2/20/07, Tim Chase <[EMAIL PROTECTED]> wrote: I'm trying to find a good way to remap control+U in insert-mode so that it begins an undo-block. There are times when type control+U in insert-mode and it doesn't do what I intend, or I want to undo it, only to find that an "u"ndo doesn't solve the problem. I know that transitioning out of insert-mode (via or ) will mark a point in the undo-stack. However, I don't really want to be in insert mode. I've tried the following: inoremap This does a funky beep/flash (depending on VB settings) and doesn't behave quite like I would have expected it to. inoremap This gives me a crazy "E486: Pattern not found: insert" which, I haven't searched for the word "insert" so this one makes me scratch my head. Bug perhaps? Vim-internals showing through? Have I overlooked some setting that I couldn't find in undo.txt? Or does anyone else have a good suggestion on how to tag a control+U in insert-mode so that it alone can be undone? Hello Tim, I am not sure I understand you right, but do you mean somthing like u in insert mode ? (:help i_CTRL-G_u): :imap u ? :help i_CTRL-G_u CTRL-G u>...break undo sequence, start new change>.. *i_CTRL-G_u* Yakov There is another strange detail about u In my vimrc I have (for gVim 6.4, gVim 7.0) :imap u Each "u" goes back one line of text in the undo history. Note the "imap" instead of "inoremap". This way abbreviations still work. For the strange part: This mapping does not result in an endless loop! I don't know why ... just found out by trial and error, could someone explain this? Andy -- EOF ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: Go to start of visual selection
Tim Chase schrieb: >> vnoremap gt `>:exec 'norm '.visualmode().'`' >> vnoremap gb `:exec 'norm '.visualmode().'`>' > > I don't understand why this works. > > There must be a difference between > `>v`< > and > :normal `>v`< > > "v" defines a new visual area and overwrites the `<,`> > markers. Why does "`<" after ":normal" move the cursor to > the start of the _previously_ selected visual area? Sorry it's taken me a while to get back on this...life got a little crazy. Buried away in the help just above :help :map-verbose and in the section :help map-listing one finds this little morsel of help: Note: When using mappings for Visual mode, you can use the "'<" mark, which is the start of the last selected Visual area in the current buffer |'<|. Thanks for the pointer! I couldn't find hints about this in the help. Interesting that "mappings for Visual mode" include commands given with :normal (emphasize on "mappings"). It's also possible to read the help at :help '< either way, as it refers to the "last selected visual area" which in visual-mode could mean either "the area selected before the the one I'm currently in", or "the current visual selection which is now the 'last selected visual area' because I'm now doing something other than selecting". It might help to have an extra sentence at this help to say something like If you are currently in visual mode, this refers to the beginning/end of the *previous* visual selection This phrase would be more comprehensible, indeed. Hope this helps shed light on your question rather than muddy the waters. -tim Most important: It turned out to be documented :-) Regards, Andy -- EOF ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: break option lines
[EMAIL PROTECTED] schrieb: Hello, is it possible in a vimrc for comma separated option strings like this one below to break: set dictionary=$VIM\SQLDict\BPMS_Stamm.txt,$VIM\SQLDict\BPMS_Mandant.txt,$VIM\SQL Dict\CBS_2005.txt,$VIM\SQLDict\ICCS_Net_Strommixer.txt,$VIM\SQLDict\DBS.txt,$ VIM\SQLDict\cbsbestenergy.txt,$VIM\SQLDict\iccs_2005.txt... many other files.. In the help: :help line-continuation :help cpo-C Andy -- EOF ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: Tips which are spam
John Beckett schrieb: Andy Wokula wrote: Currently there is much spam in recent comments: http://vim.sourceforge.net/tips/recent_notes.php Last time this was discussed I got the impression that there is a feeling that if no one reads the spam, then it is not a problem. But I think the situation is worse than that. The spammers don't care if anyone reads the tips. They want the optimisation to their search ranking in Google et al from having links to their site. Helping these leaches is no longer acceptable IMHO. Lots of places on the Internet have had to implement a simple logon or at least a captcha - anonymous posting can't be allowed. John E.g. posters must either login or solve simple math (or answer simple Vim questions, even better ;) next to the "Add Note" button. Should be fairly easy to add? Andy -- EOF ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: Tips which are spam
Currently there is much spam in recent comments: http://vim.sourceforge.net/tips/recent_notes.php Andy -- EOF ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: Go to start of visual selection
Tim Chase schrieb: How can I move the cursor the start of the visual selection? With the "o" command, yes. But how can I make sure the cursor is at the start while visual mode is on? The "`<" motion followed by "gv" sets the cursor back to the end if it was there. I think it sounds like you want something like the following: vnoremap gt `>:exec 'norm '.visualmode().'`' vnoremap gb `:exec 'norm '.visualmode().'`>' which gives you a "Go to the Top" and "Go to the Bottom" mapping within visual mode. It can be a little funky in blockwise visual-mode, if your '< and '> points are top-right and bottom-left (rather than top-left and bottom-right), as the "top" will go to the top-right, not the top-left. I haven't figured out a good way to do this without considerably more code in the mapping (save the column of '< and then "gvO" to go back to visual-mode but in the other corner and then compare the columns to see which you want, perhaps needing to switch back...it's ugly). However, it should work fine in character-wise and line-wise visual modes. HTH, -tim Works fine at least for character-wise visual mode, thanks! :-) IMHO, this little basic feature should be included in Vim. Regards, Andy -- EOF ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: Go to start of visual selection
Tim Chase schrieb: How can I move the cursor the start of the visual selection? With the "o" command, yes. But how can I make sure the cursor is at the start while visual mode is on? The "`<" motion followed by "gv" sets the cursor back to the end if it was there. I think it sounds like you want something like the following: vnoremap gt `>:exec 'norm '.visualmode().'`' vnoremap gb `:exec 'norm '.visualmode().'`>' which gives you a "Go to the Top" and "Go to the Bottom" mapping within visual mode. It can be a little funky in blockwise visual-mode, if your '< and '> points are top-right and bottom-left (rather than top-left and bottom-right), as the "top" will go to the top-right, not the top-left. I haven't figured out a good way to do this without considerably more code in the mapping (save the column of '< and then "gvO" to go back to visual-mode but in the other corner and then compare the columns to see which you want, perhaps needing to switch back...it's ugly). However, it should work fine in character-wise and line-wise visual modes. HTH, -tim I don't understand why this works. There must be a difference between `>v`< and :normal `>v`< "v" defines a new visual area and overwrites the `<,`> markers. Why does "`<" after ":normal" move the cursor to the start of the _previously_ selected visual area? Thx, Andy -- kühl, @vim.org ist wieder zurück EOF ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Go to start of visual selection
How can I move the cursor the start of the visual selection? With the "o" command, yes. But how can I make sure the cursor is at the start while visual mode is on? The "`<" motion followed by "gv" sets the cursor back to the end if it was there. Thx, Andy -- EOF ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: A doubt with "syntax region"
DervishD schrieb: Hi all :)) I'm trying to fully understand the syntax commands, and when doing tests a question popped up in my mind: let's say I have a region which starts with something like "\I\i*{" and ends with "}". For example, the example below will match: strange{contents} BUT, the below is valid for the filetype, too: morestrange{content with words and {}, surprise!} Of course, with something like this: syntax region SomeRegion start="\I\i*{" skip="{[^}]*}" end="}" I'm able to highlight the example above, without having "{}" end the region. The problem here comes when I want to highlight the part between the braces in a different color. I've tried this, to (by the moment) only highlight *braces* within those braces: syntax region SomeRegion start="\I\i*{" skip="{[^}]*}" end="}" \ contains=Inner syntax match Inner "{[^}]*}" contained But this performs the following highlighting: example{with some contents} ^^^ example{with another pair of braces {}} ^^^+++^ That is, the contained item is "swallowing" part of the "start" match!. I thought that when the match for "start" was performed, the matched test wasn't tried for any other match, including "contained" items. Obviously, I was wrong (or I misunderstood the entire issue), and I don't know if, just using regions, I can have a match like this: example{{weird} and some mor{}e text} ^ that is, that the first opening brace is not "swallowed" by the contained syntax item. As you can see, the contained item must be allowed to start with "{". Thanks a lot in advance and sorry for the weird question O:))) Raúl Núñez de Arenas Coronado :h :syn-matchgroup | In a start or end pattern that is highlighted with "matchgroup" the | contained items of the region are not used. This can be used to avoid e.g. syntax region SomeRegion matchgroup=SomeRegion start="\I\i*{" ... HTH, Andy -- EOF ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: change filenames before vim reads buffer
Tom Whittock schrieb: Hi. I'm running the vim under cygwin, and have set up my build process to execute via :make. This is great, but the build process reports filenames in DOS format, not the cygwin /cygdrive/* way. This means that when a quickfix command runs, vim will be asked to open "C:\dev\test.cpp", when I already have "/cygdrive/c/dev/test.cpp" open, and this causes issues for me. Is there any way I can insert my own handler in between the quickfix jump and buffer reading so that I can fix up the filename? Moreso, could I do this in general so that if I to "C:\dev\test.cpp", vim will interpret that in the cygwin manner? Thanks, Tom. :h quickfix-valid [...] | Filtering messages | | If you have a compiler that produces error messages that do not fit in | the format string, you could write a program that translates the error | messages into this format. You can use this program with the ":make" | command by changing the 'makeprg' option. For example: | :set mp=make\ \\\|&\ error_filter | The backslashes before the pipe character are required to avoid it to | be recognized as a command separator. The backslash before each space | is required for the set command. Just a try, Andy -- EOF ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: how to NOT save history
Luis A. Florit schrieb: Pals, How I avoid certain commands and/or substitutions NOT to be saved into the history list? For example, I have a sequence of VIM commands that executes on every email quote to properly format it, and I don't want these to appear in the registries and history. Thanks! L. Think I completely misunderstood you (because of the subject), in case please forget my previous post. Commands: A :SomeCommand will not be added to the history, if you map it to a normal mode key (including the ), for example: :map :Command1:Command2Command3 Registers: You could write data into variables to not touch registers. You will need some knowledge about vim script. :h eval Search history: The search history is always overwritten, although you can backup and restore the last search pattern: :let sav_search = @/ /some search/ :let @/ = sav_search :unlet sav_search " no need within :function ... Do you use filetype plugins? ... Wonder if this has more to do with what you had in mind. Andy -- EOF ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: how to NOT save history
Luis A. Florit schrieb: Pals, How I avoid certain commands and/or substitutions NOT to be saved into the history list? For example, I have a sequence of VIM commands that executes on every email quote to properly format it, and I don't want these to appear in the registries and history. Thanks! L. One idea is: - backup (i.e. write) the viminfo file (:help :wv) - do some secret commands - read the viminfo file back in (:help :rv), overwriting the history In theory I thought this would work: :echo "public command" :wviminfo! :echo "secret command one" :echo "secret command two" :rviminfo! But it doesn't (because of my unpatched Vim7?), so I tried: :set history? history=1000 :echo "public command" :wviminfo! :set history=0 :echo "secret command one" :echo "secret command two" :set history=1000 :rviminfo! My 'viminfo' settings (just info :o): :set viminfo? viminfo=!,'30,"50,h,rA:,rB: I think the only chars you should be aware of are ':' and '/' (not present here). HTH Andy -- EOF ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: enclosing a visual block with quotes
Bram Kuijper schrieb: Hi, I tried to use the following tip on enclosing a visual block with quotes in vim: http://schlitt.info/applications/blog/index.php?/archives/331-Comfortable-PHP-editing-with-VIM-3.html "Sometimes you want to include text you already typed text into braces or (more likely) into quotes. Using this feature you can simply mark the text (go into visual mode using v/-v/-v/... in command mode) and type the char you want to wrap around the text (like ( for (), ' for '',...) and it will be enclosed." For me that doesn't seem to work. I do start visual mode, e.g. -v on the beginning of a word, use e to block the whole word and then press any quoting character, like ' Then I press Obviously, I get the following error message: E78: Unknown mark anybody a solution to easily enclose parts of text using visual mode? cheers, Bram I guess it is a feature of that .vimrc provided on that web site (link is dead). In Vim the feature you described is not included. The "unknown mark" you mentioned is , because ' would be a motion command (also in visual mode) and there is no mark defined in Vim. I guess 2ndly the author has defined mappings like :vmap ' c'"' :vmap " c""" :vmap ( c(") These ones may help you on the first run. Hint: There is no need to press Enter afterwards. Andy -- EOF ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: C++ Syntax highlighting for Identifier, Statement
Matt England schrieb: I'm trying to get function names, class names, objects, variables and similar things to appear as non-white text with 'syntax on'. Had the same question after editing with Visual Studio. This is difficult, I haven't seen that before in any syntax file. I think there are no means to do that in an easy way. The file (and included files) needs to be parsed to collect all the user defined names. I think with some energy it should be possible, because syntax definitions can be added and removed at any time. Hopefully some of the gurus will answer? Andy -- EOF ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: syntax for vcard/vcf files
Friedrich Strohmaier schrieb: Hello everybody, A happy new year to all vimmers. :o) I am looking for a syntax highlighting file for vcard/vcf files. Nor $searchengine nor vim.org could give me advice. Does somebody know about syntax highlighting for vcard/vcf files? Friedrich But there is a syntax file ... Google Search on Vim pages |vcard_| [Google Search] (*) Search www.vim.org http://www.vim.org/scripts/script.php?script_id=1455 Die Bewertung ist allerdings nicht besonders gut. Andy -- ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Undo bug
Think I found a bug in the undo-branches behaviour, which cuts undo-states. Try this out: In a new buffer, insert `one' (or some other text), then in normal mode type `g-g-u', now insert `two' and type `g-g-u' again (ignore quotes `'). From now on it is not possible to get back the text states `one' or `two' using `g-' and `g+'. I know, in both cases `g-g-u' would not be very useful to type, but sometimes it happens by accident. Some more examples: insert `one' undo insert `two' type `g-g-g-u' insert `three' result: `g-' can reach `two', but not `one' Or is this a feature? But then what about: insert `one' undo insert `two' type `g-g-g-u' (just like above, but without inserting `three') result: even `two' cannot be reached (only redo gets it back) In the following case everything seems ok: insert `one' insert `two' undo insert `three' type `g-g-g-g-u' In short: - create a branch-off at the root level of the undo tree - type `g-' until the message `Already at oldest change' occurs - type `u' result: damaged undo tree `:undolist' may still show the branches, but `:u {N}', `g-', `g+' cannot restore the text. I'm still using an unpatched Vim7 binary for Win32 (`:ver' says `compiled May 7 2006'), but searching the patches-README for `undo' didn't give me a hint about fixes. Andy ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: locked window
Brecht Machiels schrieb: Hi, You can clear the 'modifiable' option to disable unintended modifications to a buffer. setlocal nomodifiable Is is possible to prevent, for example, the project plugin from opening another file (other than the current) in a window? The nomodifiable option only applies to the buffer. The window should be locked to the buffer instead. Regards, Brecht :help :sandbox may help (vim7 only I think). Andy ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: combining two mapping into one
A.J.Mechelynck schrieb: > Kamaraju Kusumanchi wrote: >> On Friday 06 October 2006 08:24, Andy Wokula wrote: >>> Kamaraju Kusumanchi schrieb: >>>> I use two mappings for my Fortran (.f90) files >>>> >>>> map v%zf >>>> map zDv%zf >>>> >>>> The idea is to create folds for code blocks which are of the form >>>> >>>> subroutine some_name_here >>>>statements_here >>>> end subroutine some_name_here >>>> >>>> Here F5 folds the subroutine block irrespective of whether there are >>>> any >>>> folds within it. F6 folds the subroutine block after deleting the >>>> existing folds. >>>> >>>> However, if there are no folds and if I press F6, I get an error saying >>>> that >>>> >>>> E490: No fold found >>>> >>>> Is it possible to combine these two maps into a single map such that >>>> 1) If there are no existing folds, create a fold (i.e. perform ) >>>> 2) If there are already some folds defined, then delete them and >>>> define a >>>> new fold (i.e. perform ) >>>> >>>> Any ideas? >>>> >>>> thanks >>>> raju >>> Some time ago I saw this: >>> http://vim.sourceforge.net/tips/tip.php?tip_id=1330 >>> >>> Andy >> >> Thanks for the pointer. I tried >> nnoremap @=((foldclosed(line('.')) < 0) ? 'v%zfjj' : >> 'zDv%zfjj') >> >> but it did not work due to . Dont know how to escape it >> properly. Any ideas? For now I am using >> >> nnoremap @=((foldclosed(line('.')) < 0) ? '1\|v%zfjj' : '1\| >> zDv%zfjj') >> >> but would like to use instead of 1\| since that would make the >> map more readable. >> >> thanks >> raju >> > > To use the key in an expression (as here), use a double-quoted > string and a backslash-escape: "\" > > See the last item under ":help expr-quote". > > > Best regards, > Tony. Seems to be theory in this case, a mapping like :nn @="\" results in an error: =""\ E15: Invalid expression: ""\ Nevertheless :let home = "\" :nn @=home works. Same for both GVim 6.4 and GVim 7.0 (no latest patches) on Win32. Looks like a bug?! Andy ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: combining two mapping into one
Kamaraju Kusumanchi schrieb: > I use two mappings for my Fortran (.f90) files > > map v%zf > map zDv%zf > > The idea is to create folds for code blocks which are of the form > > subroutine some_name_here >statements_here > end subroutine some_name_here > > Here F5 folds the subroutine block irrespective of whether there are any > folds > within it. F6 folds the subroutine block after deleting the existing folds. > > However, if there are no folds and if I press F6, I get an error saying that > > E490: No fold found > > Is it possible to combine these two maps into a single map such that > 1) If there are no existing folds, create a fold (i.e. perform ) > 2) If there are already some folds defined, then delete them and define a new > fold (i.e. perform ) > > Any ideas? > > thanks > raju Some time ago I saw this: http://vim.sourceforge.net/tips/tip.php?tip_id=1330 Andy ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: Mapping of keysequences...
Meino Christian Cramer schrieb: > Thanks for all, Tony!!! :O) > > I think Bram should add > > :he Tony > > -support in vim which prints your email address... > or may be it is not what you really want, isn't ir ;O) > > (just kidding) > > Keep hacking! > mcc Add it yourself :e ~/.vim/doc/tony.txt :i *tony.txt* Tony's mail address *Tony* "A.J.Mechelynck" vim:tw=78:ts=8:ft=help:norl: . :w :helptags ~/.vim/doc :he Tony :-) Andy ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: glued Cursor trick anyone ?
Tim Chase schrieb: > Generally, folks would get fired for writing stunts like the following, > so read with caution... > > Archived here: > http://permalink.gmane.org/gmane.editors.vim/38930 > > you'll find these two lines from my post: > > nnoremap / :exec('cnoremap <'.'cr> <'.'cr>:exec("cunmap > <"."cr>")<'.'cr>:call HighlightCurrentSearch()<'.'cr>')/ > > nnoremap ? :exec('cnoremap <'.'cr> <'.'cr>:exec("cunmap > <"."cr>")<'.'cr>:call HighlightCurrentSearch()<'.'cr>')? > > They are hideous monstrosities, that don't quite do all that I > described in my previous post. The basic gist is that you want to > remap the "/" and "?" keys so that when you press them, you > create a cnoremap mapping that maps the (and, unimplemented > in this example, also and ) to perform the action > "cunmap the mapping, and then do my custom action". > > In this case, the custom action was to call the > HighlightCurrentSearch() function defined in the post, as desired > by the OP. In your case, you'd want to tweak it to do a "zz" > instead. > > Caveat Vimtor...if it breaks, you get to keep both pieces. If it > kicks your dog, drinks your beer, steals your girlfriend, wrecks your > pickup-truck, or any other tragedy found in country-music, I take no > responsibility...it's an ugly hack. YMMV. > > -tim A version using "": :nnoremap / :cno cr> cr>zz:cun lt>cr>cr>/ Hints: The mapping defined within the above RHS is :cno zz:cun cr> And there is one more level of nesting :cun Andy ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: Two """problems"""
Pete Johns schrieb: > " For all lines longer than 72 characters, reformat the > " paragraph from that line.. > 1,$g/.\{73,}/normal v}gq or just :set tw=72 " if set otherwise :g/./normal gqq Andy ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: Deleting question
> why not > > :1;/Citations: /-1d > > of course, this is linewise, what's before "Citations: " in the same > line is not deleted. > > Andy oops, just overlooked Yakov's answer, sorry. Andy ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: Deleting question
Nikolaos A. Patsopoulos schrieb: > Hi, > > I'm trying to delete several lines from the beginning of file till the > appearance of a specific pattern, without deleting the pattern. I have > used the following command: > > :1,/Citations: /d/e-10 > > but the offset doesn't work. > > Thanks in advance, > > Nikos why not :1;/Citations: /-1d of course, this is linewise, what's before "Citations: " in the same line is not deleted. Andy ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: Smarter Indent (an odd problem)
> Let me take this opportunity to try once again to drum up support > for an idea that I have proposed before. IMO it is too restrictive to > make options (such as syntax highlighting, 'textwidth', and > indent-related options) apply to a whole file. There should be a > convenient, consistent way to tell vim to treat different sections of a > file as having different file types. Examples: > > * code snippets in an e-mail > * PHP in an HTML file (or vice-versa) > * perl/python/ruby inside a vim script > * comments, text, and math inside LaTeX/plain TeX/conTeXt > > --Benji Fisher Something like Textmate's scope selectors? http://macromates.com/textmate/manual/scope_selectors I'm not a Mac user, just read about it. Andy ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: Contextual highlighting problem
Yongwei Wu schrieb: > I am trying to implement the COMMENT directive in the MASM syntax file: > > Treats all text between or on the same line as the delimiters as a comment. > > COMMENT delimiter [[text]] > [[text]] > [[text]] delimiter [[text]] > > The current way I deal with it is: > > syn match masmComment"COMMENT\s*\(\W\)\_.\{-}\1.*" > > However, when the first line (containing `COMMENT') is not visible, > refreshing the page will immediately render the highlighting wrong: > the lines are no longer regarded as comments. > > I tried using region, but 1) I do not know how to let `end' find > exactly the same delimiter as `start'; 2) refreshing the display still > make the highlighting fail. > > I find that the multi-line C comments do not exhibit this problem. But > I am not able to figure out the magic. Any help? > > Best regards, > > Yongwei :help :syn-ext-match HTH Andy ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Re: language menu
Cesar Romani schrieb: > Normally the language of my vim's menu is Italian. > How can I change it to English? > Many thanks in advance, > > Cesar :set langmenu=none works for me. Put it early in your .vimrc, :help 'langmenu' says: "This option must be set before loading menus, switching on filetype detection or syntax highlighting." Andy ___ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Re: Remapping - how to get the count
Yakov Lerner schrieb: > On 7/8/06, Andy Wokula <[EMAIL PROTECTED]> wrote: >> I want to remap Ctrl-A (normal mode) to do something similar with other >> data, e.g. >> >> :nmap ciw=IncRoman(@-) >> >> Now if a count is provided this will mess up the text, e.g. >> 10 does 10ciw... >> >> What is a good way to catch the count and make it available to the >> function call? > > :help v:count > > Yakov Vim überrascht einen doch immer wieder, ich hab nicht mal versucht, nach "count" zu suchen ... Thanks for the tip, now I'm quite happy with :nmap :let c=v:count1ciw=IncRoman(@-,c) :nmap :let c=v:count1ciw=DecRoman(@-,c) The only thing I don't like is the use of a variable. Thanks for the other replies as well (still have to look at the solution with ). Andy ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Remapping - how to get the count
I want to remap Ctrl-A (normal mode) to do something similar with other data, e.g. :nmap ciw=IncRoman(@-) Now if a count is provided this will mess up the text, e.g. 10 does 10ciw... What is a good way to catch the count and make it available to the function call? TIA Andy ___ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de