Home Download Buy Blog Forum Support

Select all instances in current screen area?

Select all instances in current screen area?

Postby firefusion on Tue Dec 21, 2010 9:16 am

I'm often copying and pasting code from further up in my document but I want to change just one variable name. Is the a command like ATL F3 that select all instances of the currently highlighted word but only inside the current screen area?

Thanks.
firefusion
 
Posts: 218
Joined: Fri Oct 16, 2009 7:37 am

Re: Select all instances in current screen area?

Postby gpfsmurf on Tue Dec 21, 2010 4:04 pm

For your usecase I would recommend pressing "ctrl+d" a few times.

Here's a plugin that will deselect anything that isn't currently visible:
Code: Select all
import sublime, sublimeplugin


class CropVisibleSelectionCommand(sublimeplugin.TextCommand):
   """
   Deselects anything that is not currently visible
   """
   
   def run(self, view, args):
      mask1 = sublime.Region(0, view.visibleRegion().begin())
      mask2 = sublime.Region(view.visibleRegion().end(), view.size())
      view.sel().subtract(mask1)
      view.sel().subtract(mask2)



And here's a plugin that will put info in the status bar about how many invisible selection regions there are:
Code: Select all
import sublime, sublimeplugin


class HiddenSelectionInfo(sublimeplugin.Plugin):
   def onSelectionModified(self, view):
      hidden = 0
      visible = view.visibleRegion()
      for region in view.sel():
         if not region.intersects(visible):
            hidden += 1

      if hidden > 0:
         view.setStatus('hiddenRegions', "%i hidden region%s" % (hidden, 's' if hidden > 1 else ''))
      else:
         view.eraseStatus('hiddenRegions')
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot], Yahoo [Bot] and 14 guests