The k‐opt heuristics are among the most common techniques for approaching the traveling salesman problem (TSP). They are used either directly or as subroutines in more sophisticated heuristics, such as the celebrated Lin–Kernighan heuristic. The value of k is typically 2 or 3. In this article, we modify the 2‐opt heuristic to be based on a function f of the distances rather than the distances solely. This may be viewed as modifying the local search with the 2‐change neighborhood to be nonoblivious. We denote the corresponding heuristic by (2, f)‐opt. We provide theoretical performance guarantees for it: both lower and upper bounds based on the ones given by Chandra et al. [SIAM J Comput 28 (1999), 1998–2029], obtained originally for the standard 2‐opt heuristic. By a tighter analysis of the neighborhood size, we improve their upper bound for the standard 2‐opt by a factor of , and we show that these bounds hold for (2, f)‐opt for any nonnegative, increasing function f. We then provide experimental evidence based on TSPLIB benchmark problems, showing that (2, f)‐opt with for various values of significantly outperforms 2‐opt. These values of r also depend on the method chosen for constructing the initial tours. Specifically, when the initial tours are random permutations, the improvement over 2‐opt is more than 35% for ; when they are generated by the Nearest Neighbor heuristic, it is about 10% for r = 0.5, 0.55, 0.6. We also see that the average length of the tour generated by (2, f)‐opt is relatively close to the optimum or the known bound. © 2013 Wiley Periodicals, Inc. NETWORKS, Vol. 62(3), 201–219 2013