sorting based on numercial value
I have a text file with a number of lines in it. Each line has the same format, say something like below. I want to sort this file based on the numerical value of the field. How can I do this in vim? Thanks. -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
Re: arithmetic expressions in search
On Apr 27, 3:36 am, "John Beckett" wrote: > googler wrote: > > I have a file where I have words like X1, X2, ..., X16, X17, X18, > > I want to find out occurences of words containing a number > > greater than, say, 17. So basically, I want to find X18, X19, > > X20, etc. How can I do this in vim? In other words, can we > > use arithmetic expressions in search? If yes, how? > > I believe there is no way to search for a number depending on an > expression. You would have to do it manually, something like > this simple effort: > > /X1[89]\|X[2-9][0-9] > > John Thanks for the reply. But it may not always be simple like you showed above. For example, if I wanted to only search for those numbers that are divisible by 7. If such a feature is currently not available in vim, it maybe a good idea to add it? Just a suggestion.. -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
arithmetic expressions in search
Hello, I have a file where I have words like X1, X2, ..., X16, X17, X18, I want to find out occurences of words containing a number greater than, say, 17. So basically, I want to find X18, X19, X20, etc. How can I do this in vim? In other words, can we use arithmetic expressions in search? If yes, how? Thanks. -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
Re: incrementing number in each line
On Apr 18, 9:50 pm, "John Beckett" wrote: > googler wrote: > > This is what I actually used after posting the question. But > > I was wondering if there is a better way. > > Use Tim's approach but modify the replacement using: > > http://vim.wikia.com/wiki/Substitute_with_incrementing_numbers > > John Thanks for the link. It certainly solves my problem. However, I have one question related to the solution given there. :let i=1 | g/foo/s//\="blah_".i/ | let i=i+1 When I run the above, I see that it replaces 'foo' (the first occuerence in a line) with blah_1, blah_2, etc., as the tip claims to do. But I am not very clear on the three separate steps in the process. On first looking at the above command, my understanding was that first we are assigning 1 to i, then running the substitution command over the entire file and then incrementing i -- which is not correct because then the file will have all 'foo' replaced only by 'blah_1' and i incremented only once at the end. So looks like the middle step (substituation) is not an atomic step and rather an (implicit) iterative step. Can someone explain this behavior of the :g and :s command in slightly greater detail or point to some explanation on the same? -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
Re: incrementing number in each line
On Apr 18, 8:23 pm, Tim Chase wrote: > On 04/18/2011 09:50 PM, googler wrote: > > > I have a few lines as below. Most of the lines below correspond to a > > number (starting from 001 and counting upward). I want to change the > > part "-new_cell_name ${eco_prefix}_001 " in each line to its > > corresponding number without having to go to each line and type it > > > insert_buffer -new_net_name ${eco_prefix}_net_001 -new_cell_name $ > > {eco_prefix}_001 ... > > insert_buffer -new_net_name ${eco_prefix}_net_002 -new_cell_name $ > > {eco_prefix}_001 ... > > I'd just do a substitute across the lines so that you snag the > first number and replace it as the second number. Something like > > :%s/${eco_prefix}_net_\(\d\d\d\) -new_cell_name > ${eco_prefix}_\zs\d\d\d/\1 > > The "\zs" makes the replacement start at that point, and the > "\(...\)" captures the first portion to be used in the > replacement "\1". > > -tim This is what I actually used after posting the question. But I was wondering if there is a better way. In this case, I had already changed the first numbers manually, so I could use that to replace the second number in the same line. But is there a way where even if I had not changed the first number, I could change both the first and second numbers in a line to the same value (which is one more than the number used in the line above)? Thanks. -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
incrementing number in each line
Hi, I have a few lines as below. Most of the lines below correspond to a number (starting from 001 and counting upward). I want to change the part "-new_cell_name ${eco_prefix}_001 " in each line to its corresponding number without having to go to each line and type it (which I did for "-new_net_name ${eco_prefix}_net_xxx"). I know about the increment operation (CTRL-A) in vim but not sure to use it in this context. Any idea how this can be done easily (using CTRL-A or otherwise)? I am sure there are different ways of doing this, so all suggestions (not just the best or shortest one) are very welcome as they might help me understand several different features of vim through one example. Thanks! insert_buffer -new_net_name ${eco_prefix}_net_001 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_002 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_003 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_004 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_005 -new_cell_name $ {eco_prefix}_001 ... ## rx_clk32 insert_buffer -new_net_name ${eco_prefix}_net_006 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_007 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_008 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_009 -new_cell_name $ {eco_prefix}_001 ... ## tx_clk32 insert_buffer -new_net_name ${eco_prefix}_net_010 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_011 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_012 -new_cell_name $ {eco_prefix}_001 ... ## txck312 insert_buffer -new_net_name ${eco_prefix}_net_013 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_014 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_015 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_016 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_017 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_018 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_019 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_020 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_021 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_022 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_023 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_024 -new_cell_name $ {eco_prefix}_001 ... insert_buffer -new_net_name ${eco_prefix}_net_025 -new_cell_name $ {eco_prefix}_001 ... -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
question on search
How do I search for the words containing the string CKINV, but which do not start with G8S_ ? For example, I would be interested in the string xyz_CKINVX8 but not G8S_CKINVX3. Thanks. -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
opening a split window at the bottom
When I use the (horizontal) split feature to open a new window in vim, this new window opens up at the top and whatever I had earlier goes under this new window. Is there a way to change this? I have to do a R to change the position every time. Is there some option in vim that would enable me to open the new window at the very bottom? If not, is there any auto command or something that can have the same effect? Thanks. -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
Editing verilog file in vim
I am trying to use (g)vim to edit verilog files. I see proper syntax highlighting, but keyword matching (for example, 'begin' is supposed to match with 'end') is not working. I read up some of the earlier posts in this group regarding usage of vim for verilog, but can't seem to find the solution. Can someone please help me get vim working for verilog files? I am using vim version 7.2. I do see the file verilog.vim in ftplugin directory. This is what my .vimrc file looks like. set nocompatible filetype indent plugin on syntax on set hidden set wildmenu set showcmd set hlsearch set ignorecase set smartcase set backspace=indent,eol,start set autoindent set nostartofline set ruler set laststatus=2 set confirm set visualbell set t_vb= set mouse=a set cmdheight=2 set number set notimeout ttimeout ttimeoutlen=200 set pastetoggle= set shiftwidth=2 set softtabstop=2 set expandtab map Y y$ nnoremap :nohl Also, from a more general standpoint, when we are trying to use a new filetype/language in vim (like verilog), what are the different features/plugins that we need to make sure are available? For example, it should have syntax highlighting, keyword matching, etc.. and what else? And where are the plugins for these features usually located? Thanks! -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
Re: Undoing changes after saving file
On Nov 14, 7:46 am, Tim Chase wrote: > > Sometimes even after I save my changes to a file using :w, I > > can undo these changes (using u). But sometimes I cannot undo > > after I have saved the file with :w. In both cases, I don't > > close the file or exit vim. > > - something (possibly a plugin) is reloading the buffer after > it's been saved which would make vim treat it as a "new" file > with no undo history. I'm not quite so sure how to check if this > is happening, other than to scan through scripts (check the > output of ":scriptnames" > I think this is it. I didn't know that if we reload the buffer say using :e, it loses all undo history. Sometimes I might do a :e! to abandon all the latest changes and revert back to the last saved copy of the file, and then when I go back to that last saved copy, I realize that I still need to do a few more undos. But now undo doesn't work since I have already reloaded the buffer using :e!. Is it possible to keep the undo history across several loads of the same file (especially when I'm not explicitly closing the buffer with a :q like in this case)? Thanks. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Undoing changes after saving file
Sometimes even after I save my changes to a file using :w, I can undo these changes (using u). But sometimes I cannot undo after I have saved the file with :w. In both cases, I don't close the file or exit vim. Why does vim act differently in two cases? I have observed this happen, but cannot provide the exact sequence of operations right now. Today a co-worker complained about the same (she was not able to undo after saving the file, but she usually can) and I couldn't help her. Any explanation or solution? Thanks! --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: substitutions in a very large file
On Aug 17, 9:25 am, Charles Campbell wrote: > The LargeFile.vim script that Tim mentions turns several of these time > consumers off for "large" files, the definition for which you may > customize by setting the "g:LargeFile" variable. > > I don't think LargeFile is switching off paren matching -- that's probably > a good idea (thanks, Tim!) for me to add (a blindspot of mine as I > have paren matching turned off by default, anyway). Thanks, this will be a useful tool, although I didn't get a chance to perform the same operation as earlier as the large files do not exist any more. I was wondering perhaps it will be a good idea to have some way to let the user know if the file is currently in LargeFile mode or not. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: substitutions in a very large file
> Did this file have syntax highlighting on? If so, turn it off. > > Dare you provide an example of what the file looks like? As there's > every chance your substitution was wrong to begin with. Syntax highlighting is not on. It's a plain text file with a .txt extension. I already said what it looks like. The substitution is correct. It works on smaller files of same format. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
substitutions in a very large file
I have a text file that is very large. It has only one line which is of the form like below. itemA itemB itemC .. Basically itemA, itemB etc are character strings of some arbitrary length and they are separated by a space. I wanted to modify the file so that each line will have only one item. The next item after a certain item will be placed in the next line. So this is fairly easy with a ":s/ /\r/g" command. The problem is when I have about a million of such items, this takes very long. It was going on for about two hours and then I killed the vim session. Then I tried to achieve the same result writing a small perl script (using split), and I was surprised that it took less than 10 seconds to finish. Why such a huge difference in the time taken by two methods? Any comments? Any way I could have made things faster in the vim method? Thanks. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
executing a recording for an unknown number of times
I have a defined a recording, say using qa. Now I want to execute this recording using @a. But I don't know how many times to call it for all the changes to take effect, so I can't do something like 1...@a. I just want to execute it so that it will run through the entire file making the necessary changes. Is there a way to do this? Thanks. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: underscores in command names.
On Aug 8, 11:46 pm, meino.cra...@gmx.de wrote: > > But it is not always easy / possible especiialy for beginners > to find what one search for. One example : > > How to know the difference between > > :h command-line > > and > > :h commandline > > without knowing the contents in beforehand? If you type :h command and then press ctrl-D, it will show the list of all tags with the word 'command' in it. Then you can choose the ones that look related to what you are looking for. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: User defined command with no range
On Aug 4, 2:21 pm, googler wrote: > I want to define a command using ":command" and want to specify range > as part of the command. For example, if my command is called MyCmd, I > can run something like this - :100,150 MyCmd. Now, I see that there > are some options regarding the default range vim chooses in the case I > do not specify one. It can be the current line or the entire file. > However, my requirement is a little different. In some cases, the user > may not specify a range with this command. In those cases, I want the > called function to know that no range has been passed and it will work > a little differently in those cases (for example, it will choose the > last highlighted region as the range). Can this be done? Thanks. I didn't get any reply to this, so I just wanted to follow up in case it wasn't noticed earlier. Thanks :) --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: underscores in command names.
On Aug 8, 6:31 pm, Edward Peschko wrote: > This seems to be due to the underscore. Are underscores not allowed in > command names? And if so, why? I'd like to have multiple 'modules', > commands that all have the same prefix, followed by underscore, > followed by command name. What characters are legal? > And shouldn't underscore be one of them? > > Thanks, > > Ed Try :help user-commands. It will answer all the above questions. Vim help is very comprehensive, so make the most of it. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: disabling hit return in programming grep.
> > Check :help silent > > Not sure if this is really what I'm after - :help silent goes into a section > about microsoft visual studio..I'm looking for a way to avoid the error > message and the need for the return in a unix environment using unix > processes. I think he meant :help :map-silent, but I'm not sure if that will do what you are asking. If you use the silent option to define a map, it will not echo the command on execution. But that may not avoid hitting return. Also, do you have to hit return in the existing window or the new window? --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
User defined command with no range
I want to define a command using ":command" and want to specify range as part of the command. For example, if my command is called MyCmd, I can run something like this - :100,150 MyCmd. Now, I see that there are some options regarding the default range vim chooses in the case I do not specify one. It can be the current line or the entire file. However, my requirement is a little different. In some cases, the user may not specify a range with this command. In those cases, I want the called function to know that no range has been passed and it will work a little differently in those cases (for example, it will choose the last highlighted region as the range). Can this be done? Thanks. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Pls help with writing this plugin
> > But in this case, my line and column numbers are stored in > > variables. So how do I use these in the match command? Is > > there a way? > > See ":help :execute" and you might find some clues in some of > the tips, but I don't think any highlight between two positions. > Thank you. This is what I needed. The execute command seems to be pretty common as I found it in many other scripts too. It will be helpful in the future. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Pls help with writing this plugin
Hi all, I'm trying to write a vim script (plugin) that will do the following. When I visually select a part of the text and press the key F2, it will highlight this text. Now I may go to other parts of the file and highlight other sections using the same mechanism. After a while I return to my previously highlighted section and with the cursor on it, I press F2 again. This will remove the highlight from this section. I have been trying to code this up but haven't been successful so far. I don't have any experience with vim scripting before. This is what I'm trying to do. I select the part visually. So the marks '< and '> will have information on start and end of the selected text. Now I call getpos() on each of these marks to get their line number and column number and store these in variables (so that they can be used when I want to remove highlighting). In order to highlight the text from (line=10,col=7) to (line=24,col=33), I do :match ErrorMsg /\%10l\ %7c\_.*\%24l\%33c . But in this case, my line and column numbers are stored in variables. So how do I use these in the match command? Is there a way? A related question is, is it possible to create marks not by going to a certain position and doing a ma (for example), but just by specifying the line and column numbers? Also, is it possible to copy a mark a to another mark b? Thanks. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Possible bug in ":match" when using marks?
Let me describe two scenarios. First scenario: I have made a visual selection of a text part and pressed 'Esc'. Now I want to highlight this selection. So I do :match ErrorMsg /\%'<\_.*\%'>/ This will highlight the text I had selected earlier. So far so good. Now I make another visual selection in the same window. I see that this new selection gets highlighted (which it should), but the previously highlighted section is still highlighted. I would assume that it would not be highlighted any more after I made another visual selection, because the marks '< and '> have got redefined. Second scenario: I define two marks a and b in my text using ma and mb. Now I want to highlight the text between these marks. So I do :match ErrorMsg /\%'a\_.*\%'b/ This has the desired effect as the text between the marks a and b gets highlighted. Now, I redefine these marks a and b to point to a different part of the text. I see that the section highlighted earlier is not highlighted any more (which is as I had expected), but the section of the text between the new definition of marks a and b is not highlighted either (I had expected that it would get highlighted). However, if I do "echo getmatches()", the match command that I had entered earlier still shows up. So clearly, the behavior is different with the two types of marks. Is this a bug? --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: highlighting text between marks
On Aug 1, 6:46 am, Teemu Likonen wrote: > On 2009-08-01 00:25 (-0700), googler wrote: > > > I have two marks, say a and b. I want to highlight the text between > > (and including) a and b. I tried to use the match command like this > > :'a,'b match MyGrp /.*/ > > Try this first: > > :help /\%'m > > For example: > > :match ErrorMsg /\%'a\_.*\%'b/ Hi, thanks for the reply. It did answer my question, but on second thoughts, I would actually like to use the line number and column number corresponding to each mark inside the ':match' command. So my question is, given a mark (say `a, '<, etc), is it possible to get its line number and column number? I have to do this because the marks I use to define a match earlier might get redefined, in which case those highlights will be gone. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: highlighting text between marks
On Aug 1, 12:56 pm, KKde wrote: > > Try this first: > > > :help /\%'m > > > For example: > > > :match ErrorMsg /\%'a\_.*\%'b/ > > Cool. I never know this is possible. But what is the purpose of this > feature? Matching between sections can be achieved by line numbers > What do you mean by "Matching between sections can be achieved by line numbers"? I guess even for matching using line numbers, a similar syntax is to be used. For example, :match ErrorMsg /\%10l\_.*\%17l/ (to highlight lines 10 to 17). But this will highlight entire lines and not a part of the beginning or end lines. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
highlighting text between marks
I have two marks, say a and b. I want to highlight the text between (and including) a and b. I tried to use the match command like this :'a,'b match MyGrp /.*/ I know accessing marks with ' (instead of `) will not be accurate to the resolution of the exact characters, but I was hoping to get at least the lines highlighted. But it doesn't work. How do I do this? It is best if it highlights only the portion of text bounded by the marks and not the entire line. BTW, does any plugin exist where I can select a part of text in visual mode (say using the mouse) and pressing some specific key will highlight this text? Thanks. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Changing the title of an open gvim session
On Jul 31, 12:40 am, KKde wrote: > Hi Googler > > You can change the title to whatever you want by using this option > > :se titlestring= Hi\ Googler > > This setting is global i.e this title will be applied to all buffers > in the current window. Don't worry It can be changed for every buffer > using the autocmd > for more infromation see > :he titlestring > > Thanks, > Sarath > Exactly what I was looking for. Thank you. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: need some help on writing a script
On Jul 31, 12:27 am, KKde wrote: > > Also, how do I get the name of the buffers and their attributes (like > > active/hidden, etc)? Which variables are these stored in? > > you can get the buffers list and their attributes by this way in > script > > exe "buffers" > > Thanks, > Sarath Where will the output of an exe command go? I need to capture the information and extract the name and attribute of each file/buffer. Will I be able to do that using exe "buffers"? Thanks. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: need some help on writing a script
On Jul 30, 1:04 am, Christian Brabandt wrote: > Hi googler! > > On Mi, 29 Jul 2009, googler wrote: > > > I'm thinking to solve it this way. > > 1. I have a list of all the files that are listed on the left window > > (with their full path name) ==> is there a way to get such a list? > > Tricky. I do not use netrw a lot, so there might be easier ways. Dr. > Chip may correct me, if I am saying something wrong. > I think the directory displayed is always in NETRW_HISTDIR_0. So I > would do basically something like this: > > If the filetype is netrw, Read in the whole buffer into a list. Then > filter all rows by lines that start with ^" and at last prepend > NETRW_HISTDIR_0 to each row, excep maybe ../ > > (see help getline(), filter(), help map(), etc.) Hi! Thanks for your suggestions. But I don't see anything called NETRW_HISTDIR_0 in :help. If such a variable is available, that will be very helpful in this case. > > Does this sound good? Or is there a better approach? Also, how do I > > qualify the left and right split windows? For example, if I want the > > name of the file in the right window, the file name is stored in %, > > but how do I tell vim which window? > > Not sure. Look at the window and buffer functions (see :h > function-list) > Also take a look at :h eval.txt. All the stuff for writing scripts is > in there. > This info will be useful given that I have zero experience in writing vim scripts. > Mit freundlichen Grüßen > Christian > -- > Achtung nutzt sich ab wie Liebe. > -- Luc de Clapiers Vauvenargues (Reflexionen und Maximen) --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: need some help on writing a script
Thanks for the reply. I still have some questions. Suppose I have the directory structure as below and this is the way it is displayed in vim. ../ island_ccu_pmu/ | hacks/ | | library_setup_boerne.tcl* | outputs/ | gen_db.tcl | island_ccu_pmu.magma-no-pg.v* | island_ccu_pmu.magma_output.sdc | pt_shell.log | setup_design* > Unfortunately, since netrw long predates vim's introduction of Lists, > its use of them isn't as prevalent as I'd wish -- and there isn't such a > list to be passed along. However, especially for local listings, the > b:netrw_curdir variable holds the current directory. You can use > vim's glob() function with that. > I'm not sure if b:netrw_curdir will help in all cases. It just gives the current directory, which may not be the top most (that is, base) directory shown in the tree. For example, when I go to the line for the 'hacks' directory and press 'enter', this directory gets expanded (as shown above) and b:netrw_curdir gets set to this directory. Is there a variable that gives the name and full path of the base directory? If I have the full base directory name, then I can construct the full path of the other files and directories shown below it by correctly parsing the file. BTW, I don't get anything when I do ":help b:netrw_curdir". Is there any explanation for this and similar variables somewhere? > However, you could just construct a list of filenames from the buffers' > names, using redir @a, ls!, redir END , and manipulate the resulting > text into a match/match2/match3 type of command. Use windo and > execute that command in all windows having filetype netrw. > Yes, that's what I'm thinking too. But in order to compare each filename from the buffer list to the files listed in netrw window, I need to construct the complete path for each filename displayed on the netrw window. And to get the complete path, I have to parse the netrw directory listing and also have to know the base directory (full path) under which these are listed. Hence my earlier question on how to get the full path for the base dir. Also, how do I get the name of the buffers and their attributes (like active/hidden, etc)? Which variables are these stored in? Thanks much. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Changing the title of an open gvim session
On Jul 30, 2:20 pm, scott wrote: > On Thursday 30 July 2009 13:47:05 googler wrote: > > > I have an open gvim session/window (the term window is used in > > the context of desktop and not in the context of vim buffers). > > It displays the name of the currently active/open file as the > > title of the window at the very top. Is there a way to change > > this title to something else I want? Thanks! > > i'm not sure what you're using -- for me, the konsole provided by > kde4.2 supports a key-chord S which throws up a dialog > with which i can name the window anything i want > > sc I'm using gnome and the S does not work there. I was rather hoping that there would be some handle in vim that could help in changing the title of the window. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Changing the title of an open gvim session
I have an open gvim session/window (the term window is used in the context of desktop and not in the context of vim buffers). It displays the name of the currently active/open file as the title of the window at the very top. Is there a way to change this title to something else I want? Thanks! --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Directory listing in (g)vim
On Jul 29, 9:08 am, Charles Campbell wrote: > googler wrote: > > Perhaps you misunderstood my problem. The left window is directory > > listing and the right window is an open file. The left window is > > active. Now I click somewhere on the _right_ window wishing to make it > > the active window. This makes the directory listing disappear on the > > left window and a new file opens up in its place. Assuming the line I > > clicked on the right window has "abcdefgh wxyz", the name of the file > > that just opened up will be "abcdefgh wxyz". > > > Actually I'm not very sure with the click -- whether it's going as a > > single click or a double click on my computer. You can try double > > clicking if you want and see if you get the same thing. > > > I'm using gvim 7.2, although I'm not sure about the netrw version. > > With that request, I'm now using the following in a file called > "simple.vimrc": > > set nocp > filetype plugin indent on > run netrwPlugin.vim > let g:netrw_browse_split = 4 > let g:netrw_preview = 1 > let g:netrw_liststyle = 3 > > and gvim -u simple.vimrc -U NONE . > > I click on a file, then h (ie. move back to the directory > window, > move down a bit, and then leftmouse click on the right window). The right > window becomes selected; no change in the directory listing window. > Double-clicking doesn't affect this. > > Again, I did this with netrw v136k. When you get a directory listing, > on the > second line of the banner at the far right appears (netrw v136k). > > Regards, > Chip Campbell Hello Dr. Chip, I have some more information on this problem. I do not see this problem when I run gvim on windows. The problem I was telling about earlier was on Linux. The netrw version in both cases is v132, so I don't understand why it appears only in one case and not the other. Can you tell me of some variables that I can check to find more about this? Thanks. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
need some help on writing a script
I want to write a vim script that involves netrw and buffers. Unfortunately, I do not have any experience in writing vim scripts, so I need a bit of help to get started. I have a vim session, where the left split window is the directory listing and the right window has an open file (opened by clicking on a file name on the left window or through some other way, like :e). The right window may have multiple buffers (files) loaded (but displaying only one). What I want the script to do --- whenever I have an active buffer on the right window that is listed in the left window, I want that file name to be highlighted on the left window. I'm thinking to solve it this way. 1. I have a list of all the files that are listed on the left window (with their full path name) ==> is there a way to get such a list? 2. I have the variable that has the file name for the active buffer on the right window ==> this should be %, correct? 3. I check if file in (2) is part of the list in (1). If it is, then I highlight the corresponding line in the left window. 4. This script/function will be called as part of an auto command, whenever we click (or press 'enter') on the left window or refresh it by . Does this sound good? Or is there a better approach? Also, how do I qualify the left and right split windows? For example, if I want the name of the file in the right window, the file name is stored in %, but how do I tell vim which window? I was reading the chapters on netrw and buffers on vim help. They do not list the kind of variables that I'm looking for. Can someone provide me with pointers on where to look? I'm not asking for you to write the script, but just some hints and pointers. Thanks. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Directory listing in (g)vim
On Jul 29, 2:19 pm, scott wrote: > On Wednesday 29 July 2009 14:13:43 Charles Campbell wrote: > > > > > The banner is of variable length depending on a few options > > (hiding/showing/normal), whether > > or not a target directory has been set for copying, etc. I've > > added yet-another-option > > (g:netrw_banner) which can be used to suppress banner display > > (v136l). I hope its obvious > > that I haven't had time to test all the side effects of this > > change. > > for yet another option i find myself hollering yet another round > of thanx! -- this one's very cool -- i've tested it all of one > time and it works great! > > sc Is this new version v136I already available? In an earlier post, Dr Chip said that currently there is no option of suppressing the banner, but now he says there is an option g:netrw_banner. I'm confused. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Directory listing in (g)vim
On Jul 29, 12:15 pm, Charles Campbell wrote: > googler wrote: > > I'm using netrw v132, maybe that is causing the problem? > > That version is getting old; I suggest getting v136k: > > http://mysite.verizon.net/astronaut/vim/index.html#NETRW > > > Thanks for your help on this. It's pretty cool using vim like this, so > > I can simultaneously see the directory listing and open any file > > easily. I'm thinking of writing some script that will enable > > highlighting the name of the file on the directory listing if that > > file is currently the active buffer. Planning to start soon whenever I > > get some free time. I've never really written any vim script before, > > but hoping that this will be interesting. > > Probably should use the match command in the netrw buffer. Glad you > like netrw!> Btw, is it possible to ask vim to not show the header in a > directory > > listing? By header I mean the lines starting with " at the top of the > > directory listing. > > Currently the banner cannot be suppressed. > > Regards, > Chip Campbell Hello, if I have opened directory listing using :Explore and have the default liststyle set (that is I haven't set g:netrw_liststyle to 3 yet), and then do ":let g:netrw_liststyle=3", it does not change to hierarchical listing. Until now I had been pressing the i key, so I didn't notice this. Is this a bug in netrw v132. Do you see this with v136? I think it will be nice to have an option to hide the banner. It will be nice to have it implemented in future version of netrw (are you the author of this plugin?). Thanks. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Directory listing in (g)vim
On Jul 29, 9:08 am, Charles Campbell wrote: > I click on a file, then h (ie. move back to the directory > window, > move down a bit, and then leftmouse click on the right window). The right > window becomes selected; no change in the directory listing window. > Double-clicking doesn't affect this. > I see.. although I'm consistently observing the behavior that I mentioned earlier. > Again, I did this with netrw v136k. When you get a directory listing, > on the > second line of the banner at the far right appears (netrw v136k). > I'm using netrw v132, maybe that is causing the problem? Thanks for your help on this. It's pretty cool using vim like this, so I can simultaneously see the directory listing and open any file easily. I'm thinking of writing some script that will enable highlighting the name of the file on the directory listing if that file is currently the active buffer. Planning to start soon whenever I get some free time. I've never really written any vim script before, but hoping that this will be interesting. Btw, is it possible to ask vim to not show the header in a directory listing? By header I mean the lines starting with " at the top of the directory listing. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Directory listing in (g)vim
On Jul 28, 2:20 am, Charles E Campbell Jr wrote: > googler wrote: > > > I have been using gvim in certain cases as you had suggested. I have a > > gvim session up. The left window is a directory listing and the right > > window is an open file (opened by pressing 'enter' on one of the file > > names on the left window). I pressed the key i a few times for the > > left window to get a hierarchical listing. Also, I have set > > g:netrw_browse_split to 4. So things are good, except for one annoying > > problem. When the cursor is on the left window and I click on the > > right window to make it the active window, that does not happen. > > Instead what I get is that the directory listing disappears from the > > left window and in its place it opens a new file for editing. The name > > of this file is the same as the line on which I had clicked on the > > right window. Clearly, this is not what I wanted and I have to bring > > back the directory listing by doing a :Explore. Usually (while not > > listing directory contents), I can click on a window to make it the > > active window and it works fine there. Why is it not working in this > > case then? How do I avoid this problem? Thanks! > > Hello! > > I'm afraid that I'm not seeing this behavior. For one thing: > > gvim . > :let g:netrw_browse_split= 4 > click on a file with leftmouse button > > yields a window with the file contents atop the directory window, not > side by side as you've suggested above. Perhaps you have more options > set? Yes, if I have g:netrw_browse_split set to 4 and no file is open yet, by default vim creates a horizontal split window to open a file. To avoid this, I had already created a vertical split window by :vsp and after that I'm opening other files on that window. This is actually one question I had in mind - is it possible to open in vertical split mode instead of the default horizontal split? > I did this with the following "simple.vimrc": > > set nocp > filetype plugin indent on > let g:netrw_browse_split = 4 > let g:netrw_liststyle = 3 > > and using gvim -u simple.vimrc . Anyway, clicking on the directory > window just made it the active one; it didn't select&open a file for > editing. I'm using netrw v136k . What version of netrw are you > using? If its not v136k, may I suggest that you try it out. Perhaps you misunderstood my problem. The left window is directory listing and the right window is an open file. The left window is active. Now I click somewhere on the _right_ window wishing to make it the active window. This makes the directory listing disappear on the left window and a new file opens up in its place. Assuming the line I clicked on the right window has "abcdefgh wxyz", the name of the file that just opened up will be "abcdefgh wxyz". Actually I'm not very sure with the click -- whether it's going as a single click or a double click on my computer. You can try double clicking if you want and see if you get the same thing. I'm using gvim 7.2, although I'm not sure about the netrw version. Thanks. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Directory listing in (g)vim
On Jul 21, 11:41 pm, Charles E Campbell Jr wrote: > googler wrote: > > Hi, > > I am using the directory listing features of gvim (for example using > > the Explore command). I am wondering if there is a way to display the > > directory contents in a tree structure, like in Windows Explorer for > > example. Currently when I click on a directory name, it will open a > > new page and show the contents of this directory. I don't want this -- > > what I want is, it will just expand the subtree under that directory. > > Is such a thing possible in gvim? May be I'm asking for too much, but > > it will be nice if this is possible. > > In case the above is possible, a great use (or next step) will be to > > have a file open in a split window when its name is clicked on the > > other window. > > Any suggestions? Thanks. > > * When looking at a directory, press the "i" key several times until > you get the tree listing style. If you always want that style, put > > let g:netrw_liststyle= 3 > > into your .vimrc . > > * let g:netrw_retmap = 1 lets a double-left click return to the > directory menu (you didn't ask, but I thought it of interest) > > * let g:netrw_browse_split= 2 > > Regards, > Chip Campbell I have been using gvim in certain cases as you had suggested. I have a gvim session up. The left window is a directory listing and the right window is an open file (opened by pressing 'enter' on one of the file names on the left window). I pressed the key i a few times for the left window to get a hierarchical listing. Also, I have set g:netrw_browse_split to 4. So things are good, except for one annoying problem. When the cursor is on the left window and I click on the right window to make it the active window, that does not happen. Instead what I get is that the directory listing disappears from the left window and in its place it opens a new file for editing. The name of this file is the same as the line on which I had clicked on the right window. Clearly, this is not what I wanted and I have to bring back the directory listing by doing a :Explore. Usually (while not listing directory contents), I can click on a window to make it the active window and it works fine there. Why is it not working in this case then? How do I avoid this problem? Thanks! --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Directory listing in (g)vim
On Jul 21, 11:41 pm, Charles E Campbell Jr wrote: > googler wrote: > > Hi, > > I am using the directory listing features of gvim (for example using > > the Explore command). [snip] > > Any suggestions? Thanks. > > * When looking at a directory, press the "i" key several times until > you get the tree listing style. If you always want that style, put > > let g:netrw_liststyle= 3 > > into your .vimrc . > > * let g:netrw_retmap = 1 lets a double-left click return to the > directory menu (you didn't ask, but I thought it of interest) > > * let g:netrw_browse_split= 2 > > Regards, > Chip Campbell Wow, this is great! This is why I love vim :) --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Directory listing in (g)vim
Hi, I am using the directory listing features of gvim (for example using the Explore command). I am wondering if there is a way to display the directory contents in a tree structure, like in Windows Explorer for example. Currently when I click on a directory name, it will open a new page and show the contents of this directory. I don't want this -- what I want is, it will just expand the subtree under that directory. Is such a thing possible in gvim? May be I'm asking for too much, but it will be nice if this is possible. In case the above is possible, a great use (or next step) will be to have a file open in a split window when its name is clicked on the other window. Any suggestions? Thanks. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
:Explore and single click in gvim
I have been using the Explore command in gvim these days and finding it very useful in moving around directories. However, there is one feature that's causing me problem sometimes. When gvim is listing the contents of a directory and I click on any file or directory, it opens that file or directory. This can be a useful feature for some people but for me it's causing problem sometimes, when I accidentally click somewhere in the gvim window or click to make it the active window. Today I was even trying to highlight the contents (for copying) and it worked like a single click and opened the file. Is there a way I can stop the file or directory from opening on a single click? Maybe a double click would be better. Hitting should also work, as it does now. Thanks. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Anyshortcut for going back to previous searches?
On Jul 1, 2:21 pm, _sc_ wrote: > On Wednesday 01 July 2009 11:52 am, googler wrote: > > > > > Suppose I am editing/viewing a file and searching for different > > regular expressions in the file, for example, issuing commands "/ > > abcd", "/efgh", "/ijkl" and "/mnop". Since my last search was for > > "mnop", that's what I have highlighted currently. Now if I want to go > > back to the previous search or the one (or two) before that, what is > > the easiest way to do that? I do not want to type the whole search > > string again. Is there a shortcut? If not, does there exist any script > > that I can use to get this functionality? > > yet another method that everyone's been ignoring is to hit '/' > followed by ctrl-F to open the search history window > > can't have too many choices now, can we > > sc Hi everybody, thanks for your replies. All this information will definitely be helpful. However, when I posted this question, what I was thinking was if there is a keystroke or two that will take me to the previous search or the one before that. Something like pressing CTRL key or a function key. Seems like there is no such shortcut. So was thinking if one can create such a mapping. Say I'm only interested in the last two searches - pressing F4 will take me to the previous search and F5 to the one before that. How can I create such a mapping? I checked a little bit and saw that vim saves only the last search string in a register ("/) and not the ones before. So when I perform a new search through / or ? , I should save my "/ content in another register to be used by F4 and F5. Is that how it should be done? --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Anyshortcut for going back to previous searches?
Suppose I am editing/viewing a file and searching for different regular expressions in the file, for example, issuing commands "/ abcd", "/efgh", "/ijkl" and "/mnop". Since my last search was for "mnop", that's what I have highlighted currently. Now if I want to go back to the previous search or the one (or two) before that, what is the easiest way to do that? I do not want to type the whole search string again. Is there a shortcut? If not, does there exist any script that I can use to get this functionality? Thanks for any response on this. --~--~-~--~~~---~--~~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---