Whole-word searching in Sublime Text, and an interesting character study in Another Year.

Searching for something whole

Searching by whole words. It doesn’t seem like it would be a difficult task, but when you select a word and use the find tool to find it elsewhere in the document, partial matches also end up being included. This makes it very difficult to refactor code when “ar” appears in widely different places.

Some examples for example if where “ar” appears in some code are:

  • wingEfficiencyFactor(data.aspect_ratio).rectangular
  • data.wing_area_ft
  • ar: data.aspect_ratio
  • solve(…).ear

Up until now I would be tempted to use a regular expression to search for ar surrounded by non-letter parts:

find: (\W)ar(\W) replace: \1aspect_ratio\2

But with Sublime Text I have now found that you can find or replace based on a full word search, and it’s easy to achieve.

Instead of selecting the text before you search, just have the insertion bar on the word instead with nothing selected, and you can use Alt+F3 to select all occurrences of that word, or Ctrl+D to add the next whole-word match to your selection. Then when they’re selected you can just type in your replacement and you’re done – nice and simple. No more problems from partial matches within other words.

Another Year

It was off to Troy’s in Spreydon tonight to enjoy Another Year (2010), which is a story involving an upper middle-class couple Gerri (Ruth Sheen) and Tom (Jim Broadbent) who are nearing retirement, and the story centres on Mary (Lesley Manville) a 50-something flighty friend of theirs from Gerri’s work. Tom and Gerri are secure with an allotment from where their vegetable garden helps to give them a sense of place and stability.

The movie is structured in to four seasons. Spring is where we get to know the people involved, when Mary is invited to a dinner party and we learn that she’s a glass half-full sort of person but invariably empties several bottles of wine as she complains about how hard done by she is, mostly by situations that she might be able to do something about. Summer is where an old mate of Tom’s arrives who’s a heavy smoker/drinker/eater, and ends up making an unsuccessful pass at Mary who fends him off because she’s not interested. Meanwhile Mary wants to get things on with Tom’s son Joe, who’s in his early 30’s, but she’s not aware that his lightly mocking banter isn’t exactly flirting.

Come autumn we find that Joe arrives with his girlfriend, that he hadn’t mentioned previously, and when Mary arrives her behaviour turns on a dime when she learns of this. In the winter section a change of pace occurs when Gerri and Tom head away to a funeral of his sister-in-law, and when Tom’s brother Ronnie returns with them things for Mary aren’t going well at all. She arrives frail as a bird while Tom and Gerri are out at their allotment, and Mary’s litany of wants and needs is met by Ronnie with an uninterested silence.

Overall it’s an amazing character study, and says many interesting things about what brings happiness and contentment, and delves in to different ways that people unwittingly sabotage themselves from attaining it.

Advertisements