Is there any way to word wrap the code in .wl file extensions? When I select Format > WordWrapping > Wrap at Window Width in a .wl file, it extends the block and doesn't word wrap the code. Thank you.

  • 1
    $\begingroup$ Highlight the cell bracket you are typing in and right click, under "Style" change it from "Code" to "Input". If you want to start a new "Input" cell, put the cursor in between cells and hit Cmd-9 (may be Ctrl-9 on a non-Mac) $\endgroup$ – Jason B. Aug 31 '16 at 14:45
  • $\begingroup$ Will users who use my program have to do this every time when they look at the code in my package? $\endgroup$ – Wilson Aug 31 '16 at 14:48
  • $\begingroup$ No, it seems that the package saves the style for a given cell. Here is a .wl package I just created and saved, with 2 "Input" cells and one "Code" cell. i.stack.imgur.com/8ynDF.png - so it will remember what the style is for a given cell. $\endgroup$ – Jason B. Aug 31 '16 at 14:58
  • 1
    $\begingroup$ if you do that, the code will actually be commented, that means it will not be loaded when doing a Get for that file. If you use the .wl files just as a lightweigt text-version of notebooks that might be fine, but if you plan to load the file as a package then you might need to additionally make those "Input"-style cells to initialization cells (which "Code" cells are automatically by style definitions)... (I have not tried that with .wl files but know that the behavior is like that for .m files, please correct me if .wl files behave different...) $\endgroup$ – Albert Retey Aug 31 '16 at 16:16
  • 2
    $\begingroup$ as I wrote: every cell that has the option InitializationCell set to True will be written uncommented to the package file and thus loaded with Get. All other input and text cells will be written as comments, generated cells will be discarded. In the default style sheet "Code" cells do have InitializationCell set to True but Input cells don't. If you want an input cell to be written uncommented you just need to set that option to true. Of course it might make more sense to define your own style for packages, where you could do that by default. $\endgroup$ – Albert Retey Aug 31 '16 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.