Maybe you want something like:
import os, osproc, posix, strutils
proc userEditString(content = "", editor = "vim"): string =
let tmpPath = getTempDir() / "userEditString"
let tmpFile = tmpPath / $getpid()
createDir tmpPath
writeFile tmpFile, content
let err = execCmd(editor & " " & tmpFile)
return tmpFile.readFile
when isMainModule:
var s = "Vim him Nim, Jim?"
echo "\n\n(Press `i` for insert mode, edit, then <esc> and `ZZ`.)\n\n"
echo "Original: ", s
s = s.userEditString
echo "Modified: ", s.strip
Run