You can do dap, or vap, etc to select a paragraph. I want to be able to select/yank/delete the entire file.

One way to do this would be to have:

vnoremap af ggoG$
nnoremap yaf ggVGy
nnoremap daf ggVGd

But is there a way to create a new 'text object selector; (like p for paragraph, w for word, etc) but withf` for 'file? E.g. with omap?

  • Are you saying you would like to be able to select the entire file, then yank it and then delete it all in one go?
    – ljden
    Oct 1, 2017 at 13:00
  • Not exactly. i would like to perform either of those mappings above with a single mapping. For example, the ap in vap or dap selects current paragraph - I would like to effectively create a new 'text object selector' (or whatever you would call the p in vap). I have reworded the title to hopefully be cleaer Oct 1, 2017 at 18:35
  • 5
  • @ChristianBrabandt Wow exactly what I was looking for! You can make an answer if you like. And maybe copy in this: omap af :normal Vaf<CR> vnoremap af ggoG$ Oct 1, 2017 at 19:29
  • Ah right yeah that makes a little more sense haha. Fyi ggyG and ggdG are equivalent to ggVGy and ggVGd respectively (gotta save all them excess chars). There's also some cool stuff with using specific registers so you are yanking/deleting with a bit more control. And you can even do it to clipboard so you're basically just copying/cutting
    – ljden
    Oct 1, 2017 at 20:50