Skip to main content
Added links to online documentation
Source Link
Tumbler41
  • 7.8k
  • 1
  • 21
  • 48

Try a global command:

:g/^/exe ".w! line".line('.').".txt"
  • :g/^/ Do a command for every line (you can adjust this regular expression if you only want to save certain lines, i.e. . for non-empty lines)
  • exe "" execute the following command
  • .w! save the current line and overwrite if already exists. (Remove ! if you don't want to auto-overwrite everything)
  • "line".line('.').".txt" dynamically insert the line number.

See :h :g:h :g and :h execute:h execute for more info.

Try a global command:

:g/^/exe ".w! line".line('.').".txt"
  • :g/^/ Do a command for every line (you can adjust this regular expression if you only want to save certain lines, i.e. . for non-empty lines)
  • exe "" execute the following command
  • .w! save the current line and overwrite if already exists. (Remove ! if you don't want to auto-overwrite everything)
  • "line".line('.').".txt" dynamically insert the line number.

See :h :g and :h execute for more info.

Try a global command:

:g/^/exe ".w! line".line('.').".txt"
  • :g/^/ Do a command for every line (you can adjust this regular expression if you only want to save certain lines, i.e. . for non-empty lines)
  • exe "" execute the following command
  • .w! save the current line and overwrite if already exists. (Remove ! if you don't want to auto-overwrite everything)
  • "line".line('.').".txt" dynamically insert the line number.

See :h :g and :h execute for more info.

edited body
Source Link
Tumbler41
  • 7.8k
  • 1
  • 21
  • 48

Try a global command:

:g/.^/exe ".w! line".line('.').".txt"
  • :g/.^/ Do a command for every line (you can adjust this regular expression if you only want to save certain lines, i.e. . for non-empty lines)
  • exe "" execute the following command
  • .w! save the current line and overwrite if already exists. (Remove ! if you don't want to auto-overwrite everything)
  • "line".line('.').".txt" dynamically insert the line number.

See :h :g and :h execute for more info.

Try a global command:

:g/./exe ".w! line".line('.').".txt"
  • :g/./ Do a command for every line (you can adjust this regular expression if you only want to save certain lines)
  • exe "" execute the following command
  • .w! save the current line and overwrite if already exists. (Remove ! if you don't want to auto-overwrite everything)
  • "line".line('.').".txt" dynamically insert the line number.

See :h :g and :h execute for more info.

Try a global command:

:g/^/exe ".w! line".line('.').".txt"
  • :g/^/ Do a command for every line (you can adjust this regular expression if you only want to save certain lines, i.e. . for non-empty lines)
  • exe "" execute the following command
  • .w! save the current line and overwrite if already exists. (Remove ! if you don't want to auto-overwrite everything)
  • "line".line('.').".txt" dynamically insert the line number.

See :h :g and :h execute for more info.

added 82 characters in body
Source Link
Tumbler41
  • 7.8k
  • 1
  • 21
  • 48

Try a global command:

:g/./exe ".w! line".line('.').".txt"
  • :g/./ Do a command for every line (you can adjust this regular expression if you only want to save certain lines)
  • exe "" execute the following command
  • .w! save the current line and overwrite if already exists. (Remove ! if you don't want to auto-overwrite everything)
  • "line".line('.').".txt" dynamically insert the line number.

See :h :g and :h execute for more info.

Try a global command:

:g/./exe ".w! line".line('.').".txt"
  • :g/./ Do a command for every line
  • exe "" execute the following command
  • .w save the current line
  • "line".line('.').".txt" dynamically insert the line number.

See :h :g and :h execute for more info.

Try a global command:

:g/./exe ".w! line".line('.').".txt"
  • :g/./ Do a command for every line (you can adjust this regular expression if you only want to save certain lines)
  • exe "" execute the following command
  • .w! save the current line and overwrite if already exists. (Remove ! if you don't want to auto-overwrite everything)
  • "line".line('.').".txt" dynamically insert the line number.

See :h :g and :h execute for more info.

Source Link
Tumbler41
  • 7.8k
  • 1
  • 21
  • 48
Loading