MyNixOS website logo
Description

source code editing utilities.

Collection of small utilities to manipulate source code.

Some small source code manipulation tools I use with vim. They're external filters, though, so if you use acme instead of vim, they should work fine there too. See included vimrc for examples.

  • cmt - Comment and uncomment code.

  • string-literal - Toggle between raw text and list of lines or Haskell backslash string gap style. Copy paste from its usage:

string-literal [ --wrapped --{add,remove,toggle}-{backslash,lines} ]

Convert between plain text and either backslash-continued string literals, or list of lines style strings. This is to work around haskell's lack of multi-line string literals. Bind the toggle variant to a vim key to switch between raw text and haskell string literal.

It assumes a single level of indent for the strings, and leaves the indent even in the raw form, so that the text will continue to fit in more or less the same number of columns. This means they will look a bit short if printed literally on the terminal, but if you care about that, use --wrapped mode and have some terminal-aware layer do the wrapping.

--wrapped mode assumes that someone else will be wrapping the text. It doesn't put in newlines, and separates wrapped with a leading space. A paragraph newline in the input becomes an explicit newline in the haskell string. Since it assumes someone else is wrapping, it won't preserve your own leading spaces. If you are doing explicit formatting then don't use --wrapped.

Standard CPP doesn't like Haskell string-gap syntax. You can either use cpphs via -pgmP 'cpphs --cpp', or use lines mode, which is more cluttered but doesn't make CPP mad. Presumably you have a unlines or Text.unlines call at the front of the list.

Metadata

Version

0.1

Executables (2)

  • bin/string-literal
  • bin/cmt

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows