vim - String search across a column -
i want search string written in column. there way search using vim? example:
b s c
if wanted search word basic column wise, how in vim?
via regular expression
regular expressions (which power vim's search) can express consecutive character matches. therefore, can match text starting b
, ending c
, including text in between:
/b.*\n.*a.*\n.*s.*\n.*i.*\n.*c
by using .*\n.*
, asserts each character in following line. shortcoming of regular expressions cannot assert match @ same column, above match non-aligned basic
. can avoid fixed column special \%v
atom:
/\%32vb.*\n.*\%32va.*\n.*\%32vs.*\n.*\%32vi.*\n.*\%32vc
via blockwise visual selection
vim have 1 way select vertical block of characters in visual mode <c-v>
. using vimscript (e.g. getline()
or searchpos()
), search individual characters , build such selection.
via text transformation
as kent commented, if transform text (effectively 90° counter-clockwise rotation), can match (now horizontal) text via default search.
Comments
Post a Comment