International audienceWe consider a walker on the line that at each step keeps the same direction with a probability which depends on the time already spent in the direction the walker is currently moving. These walks with memories of variable length can be seen as generalizations of directionally reinforced random walks introduced in Mauldin et al. (Adv Math 117(2):239–252, 1996). We give a complete and usable characterization of the recurrence or transience in terms of the probabilities to switch the direction and we formulate some laws of large numbers. The most fruitful situation emerges when the running times both have an infinite mean. In that case, these properties are related to the behaviour of some embedded random walk with an und...