On 1/5/09, fritzophrenic wrote: > > On Jan 5, 10:19 am, "Gowtham M" wrote: > > Normally '/' in normal mode starts to search for the pattern horizontally > > (line after line, left to right). Is it possible to search text vertically > > (column after column, top to bottom) in vim? > > > > For example, the pattern 01100010 should highlight the second column of the > > below text. > > > > 1001 > > 1111 > > 1111 > > 0011 > > 0000 > > 0010 > > 1111 > > 0000 > > > > Thanks in advance. > > > > Gowtham > > > This is not possible in Vim without some scripting or plugins. > > I would attack it this way from the scripting side: > > 1. Create a command that will search for a string in a given column > (not regex probably...that would be really hard...or at least not a > variable length regex) > > This command would probably use the \%v zero-width match to match each > character in the string (:help /\%v) and then match something like .* > \n.* between each character. > > 2. Create a function that will find the max column length in the file, > then loop over every column and call the command created in (1). If > you want to get fancy, you could even have it exclude column numbers > that don't ever have enough contiguous lines of sufficient length to > contain your string. > > 3. Create a command that will call the function created in (2).
I think I would try to do it differently, by reading the file into memory, "rotating" it so that the first character on the last line becomes the first character on the first line, the first character on the second to last line becomes the second character on the first line, etc, and then searching through it with matchstr() so I could handle pattern matches... just not sure how to treat the gaps caused if not all lines have the same number of columns... hm. ~Matt --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
