Determining first backward search hit

This is a discussion on Determining first backward search hit within the Editors forums in Theory and Concepts category; Hi everyone ! Sorry to bother you, I was reffered to here by a friend. He said that people on this group sometimes help confused people (like me :-( I'm editing a file (not a programming language source, but some coordinates in a fem file, not important) ... and some things in a file always go in a row, ex. coordinates, some commands etc. x290.5 y17.5 z22.243234 (no spaces allowed) so, if the last one is x then y will always come next. Now, looking at this type of file is tiresome, so I'm trying to write a plugin which ...

Go Back   Application Development Forum > Theory and Concepts > Editors

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-05-2008, 02:33 PM
Lana
Guest
 
Default Determining first backward search hit

Hi everyone !
Sorry to bother you, I was reffered to here by a friend.
He said that people on this group sometimes help confused people (like
me :-(

I'm editing a file (not a programming language source, but some
coordinates in a fem file, not important) ... and some things in a
file always go in a row, ex. coordinates, some commands etc.
x290.5
y17.5
z22.243234
(no spaces allowed)

so, if the last one is x then y will always come next.
Now, looking at this type of file is tiresome, so I'm trying to write
a plugin which will enable me that if in the last row the first char
is x, to insert in this one y ... and so on.
(the coordinates are just an example, form-station-wl are another
pair).

This doesn't seem too difficult, I think I will be able to get it to
work with a system of if loops.
But what I can't understand is how to "grab" the first character in
previous row, so I can
if char=="x"
execute ...

Please help, I would be more than grateful on all your suggestions.
Lana
Reply With Quote
  #2  
Old 08-05-2008, 03:20 PM
Johannes Tanzler
Guest
 
Default Re: Determining first backward search hit

Lana <lana@sorry_no_mail_-_i_hate_spam.com> wrote:
> But what I can't understand is how to "grab" the first character in
> previous row, so I can
> if char=="x"
> execute ...


In Vim:

if strpart(getline(line(".")-1), 0, 1) == "x"
exe ...
endif


Johannes
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 07:12 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.