Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Export from Rust Module

Each module contains a function, which we want to export.

Before

mod generate_demos;
mod mdbook_preprocessor;
mod validate;

After

mod generate_demos;
mod mdbook_preprocessor;
mod validate;

pub use generate_demos::generate_demos;
pub use mdbook_preprocessor::mdbook_preprocessor;
pub use validate::validate;

Preview

Command

%yp[<space>

<alt-s>gse

cpub use<esc>leypi::
  1. % select all 3 "mod" statements
  2. yp duplicate them
  3. [<space> add a blank line above the 3 duplicated statements
  4. <alt-s>gse create 3 selections for each "mod" in the duplicated statements
  5. cpub use<esc> convert each "mod" into "pub use"
  6. ley copy name of each module
  7. p duplicate name of each module at the end, since each module contains a function named the same as the module
  8. i:: add a double-colon path separator between them