Learning to use the ex/vi editor and writing a novel with it

I'm learning ex/vi as deeply as I can (little by little) and it's fascinating how powerful the little program is.

I'm writing a novel, and yesterday I wrote for the first time using vi. Afterward I pasted the resulting fragment in MS Word, because my novel includes a complex index that you cannot create even with LibreOffice, but the writing experience was very satisfying. I'm using a "big" font on the terminal and the color combination that I prefer, which is dark grey over white, but the rest is vanilla ex/vi (with some options enabled, like line numbers and "showmode"). No mouse involved.

When I'm an expert in ex/vi, I'll think about using vim or neovim (or maybe I won't), but I'm enjoying very much the experience of learning the original in all its mighty.
 
i would recommend using emacs and org mode
and exporting to latex or a pdf

also use the emacs gui
instead of running emacs in a terminal

trying to write a novel with vi will be painful

emacs org mode can include other org files

so you can create org mode files for each chapter
and then include all the chapter files into a single master org file

includes the first 20 lines of the headline named ‘conclusion’.

Code:
#+INCLUDE: "./paper.org::*conclusion" :lines "1-20"

 
i would recommend using emacs and org mode
and exporting to latex or a pdf

also use the emacs gui
instead of running emacs in a terminal

trying to write a novel with vi will be painful

emacs org mode can include other org files

so you can create org mode files for each chapter
and then include all the chapter files into a single master org file

includes the first 20 lines of the headline named ‘conclusion’.

Code:
#+INCLUDE: "./paper.org::*conclusion" :lines "1-20"


Thanks for your answer!

I find writing with vi a great mental exercise that helps me focus. It's just something that my brain and I enjoy.

My novel doesn't have chapters ;-) Chapters break my rhythm. And that's also why it has a complex index, because it helps me keep track of things.

Everyone has to find their own path. That's the good think about having multiple options to choose.

I never thought vi/ex was so powerful, though.
 
i would recommend using emacs and org mode
and exporting to latex or a pdf

You would do that.

He is enthusiastic with vi and will find his way.

I have my way ("Dynamic TeX", any simple editor like vi or emacs, perhaps "make" to paste things).

I think, using prefabricated solutions like inflated org mode is for people without creativity.
 
i used to use vim but switched to emacs years ago

there are things you can do with emacs and org mode that arent possible with other editors

have to disagree that org mode is inflated and is for people without creativity
quite the opposite

i create custom org links that open youtube links with mpv
and then can control mpv from within emacs using a hydra

i also use org mode with elfeed and play the videos with mpv
and you even get a transcript of the video that scrolls in time with the video


20240922_16h03m53s_grim.png


org mode and babel source code blocks are far better for writing documentation
than using something like markdown

org mode works perfectly with github



another killer feature is tangling source code blocks
which i use to manage my dotfiles and root config




 
My favorite feature with Vi when writing LaTeX papers is the following keystrokes:

!}fmt

(Pipe current paragraph through the fmt(1) tool)

Basically the current long line (probably wrapped) is formatted into a block with each line shorter than 80 chars max.
Then after you edit the block, you can use the same keypress and it intelligently works on the whole paragraph.

I can't actually find a better solution with any other LaTeX text editor. Many of my collegues just make do with annoying long lines.
 
I find writing with vi a great mental exercise that helps me focus.
That's exactly one of the core points of
Allin Cottrell, 'Wordprocessors: Stupid and Inefficient'
with a texteditor you focus on your text, write what you want to write.
Typesetting comes afterwards, when the text is written.
With wordprocessors (MS Word, LibreOffice) you start with typesetting even if you haven't written a single word yet, and with any WYSIWYG (including TeX-live-editor-systems) you keep fumbling/finetuning continously with typesettings while writing, instead to focus on writing your text.

I also love vi[m]
But pure textfiles are not really good to read (for others) - hence typesetting.

So I like to agree with the advice of NapoleonWils0n, to (later) put your text with LaTeX into a PDF.
You may also use nroff/groff, as Cthulhux adviced; but I'm in LaTeX.
He's right with writing directly within LaTeX, especially when using formulas, tabulars, and such, the source will become hard(er) to read. (But nothing compares with XML ?)
Again:
First write pure text (vi) - then do the typesetting.

One may discuss how and with which tool/ML typesetting is done,
but not about the bad influence on the quality of a text when mixing typesetting with writing at the same time.

Of course you may copy/import your textfile into Word, Libreoffice, or such, especially when you're in how to typeset with those. But besides even typesetting is more inefficient with those, wordprocessors have another big disadvantage:
Their typesetting sucks.

Especially when you're going to write a book, no clean full justification (clean left, and right margin, without gaps in the lines) not only just looks ugly, and unprofessional, above all it's less comfort to read.
Btw that's the whole point of typesetting (including to chose the right font): to improve the reading; not to 'look cool', or 'old school', or shit. (Several hundred years of the Art of typesetting, along came wordprocessors, and everything humankind invented on how to design texts to be read best went down the sewer within less than three decades :rude: ... :-/)
I don't know a single wordprocessor capable of doing that (no need to discuss, or elaborate why - it sucks!)

Just to give an example (topic/content doesn't matter) to take a peek on how a PDF done with (La)TeX looks:
tinylisp.pdf

However,
as hruodr already also put it:
As long as you don't want any 'fancy things' like math formulas, tabulars, or graphics, you don't really need to learn LaTeX.
Just remember \\ will start a new line, an empty line in your textfile starts a new paragraph, combine both you get a new paragraph after an empty line - is all you need to know if you just write plain text, only.

The 'big deal' of starting on LaTeX may be to set up the definitions the first time.
So I attached a compilable LaTeX-file with definitions, but without content you may use as a template. (It's already a bit 'fancy', could be done way more simplified ...
Code:
\documentclass[12pt]{article}
\begin{document}
text\\
another line\\
\end{document}
may be all you need.
But this one produces even a bit nicer results, and it can be used for maybe other things later. (It also can be bloated way more - depends on what you want/need.))
But you don't need to care much about it.
Simply put the name of your text file into the \input{} at the bottom,
and run pdflatex din-a4_pdf.tex
(Of course you've done a pkg install texlive-full first.)
And - voilá - a nice PDF.

You may find other templates on the internet (or maybe some others here will share theirs.)
 

Attachments

Every single word processor’s formula editor.
Nah. I remember the time when MS Word didn't had a formula editor (long time ago).
And the quality of a formula done with a wordprocessor if it gets only a bit bigger than a root over a fraction containing some exponents or index sucks in comparison what you will produce with (La)Tex.
 
Just to give an example (topic/content doesn't matter) to take a peek on how a PDF done with (La)TeX looks:
tinylisp.pdf
It certainly looks great!

Thanks, everybody (hruodr, NapoleonWils0n, Cthulhux, %pupil -sceptical...) for your answers!

My head is about to explode and I've needed extra help to understand what you all were talking about, but now that I get it a little bit, it sure does sound fascinating. I wish days had 480 hours, I didn't need to sleep, and I were much smarted so I could learn so many interesting things there are to learn. I'll do what I can. For the moment, there are plenty things about vi that I still have to learn.

I will open soon another topic so you guys can help me find a way to create complex indexes for books, so I can ditch MS Word once and for all. Wait for it! Wait for it! Don't start replying yet, please ?
 
My favorite feature with Vi when writing LaTeX papers is the following keystrokes:

!}fmt

(Pipe current paragraph through the fmt(1) tool)

I think you are going to appreciate the following vi "commands" that I've been working on:

1) Convert a file composed of consecutive long lines into a file composed of paragraphs of short lines (i.e., every original long line is transformed into consecutive short lines followed at the end by an empty line):

- Go to the beginning of the file:
Code:
1G
- Execute the command (keystrokes to type, actually, as you know):
Code:
!Gsed 's/$/\n/g' | fmt

2) Do the reverse:

- Go to the beginning of the file:
Code:
1G
- Execute the command (keystrokes to type, actually, as you know):
Code:
!Gsed 's/^$/ç/g' | tr '\n' ' ' | sed 's/ ç /\n/g'
Warning: The character 'ç' must not appear in your text for the previous to work.

You can create a macro for each command, including going to the beginning of the file, in your .nexrc file, like this:

Code:
map º 1G!Gsed 's/$/\n/g' > .tmp;fmt .tmp^M
map ª 1G!Gsed 's/^$/ç/g' > .tmp;tr '\n' ' ' < .tmp > .tmp2;sed 's/ ç /\n/g' .tmp2^M

Notes:
-Neither I nor almighty CharGPT o1 have been able to find out how to escape a pipe into a map command, so I am using temp files instead.
-The ^M is a literal CR created in the very vi with ^V + Enter.
-'º' and 'ª' are characters of the Spanish keyboard that vi doesn't uses as standard commands, so perfect candidates for user commands.

Now I can paste a bunch of paragraphs from MS Word into vi (which results in consecutive very long lines) and format them into short lines separated by blank lines using a single keystroke, edit the result comfortably in vi, and convert it back into the format MS Word understand with another keystroke!

It was so much fun working out all that!!!!!! ?
 
My head is about to explode

there are plenty things about vi that I still have to learn.
As I said: Now you do stick to vi. The writing comes first.
Typesetting comes afterwards.

I will open soon another topic so you guys can help me find a way to create complex indexes for books
Also for getting an index - with pagenumbers match correctly without fumbling manually, and get it all killed again when editing the text - LaTeX again was a very good choice (also for lists of references/sources, bibliography [actually it's BibTeX; but that's a topic for later, too])

But for that you need to dive into it a bit; not now.

Also:
You'll find easily and quickly zillions of sites with help, introductions, tutorials, manuals, examples, references... short, or elaborated, deep dive or shallow, from easy to hardcore...on any LaTeX topic.
It's mostly again the effort to pick from that mass of choices the ones that suit you best.

If I want to dive into something I personally prefer to read anything booklike on real paper.
I don't like learning from webpages.
In this case I don't recommend to buy books on LaTeX, even if there are also very good ones.
I prefer PDF.

But that's my own personal taste, of course.

You find all official (La)TeX documentation on your machine:
/usr/local/share/texmf-dist/doc/
and
/usr/local/share/texmf-dist/doc/latex
almost always as PDF, and HTML (and more)

The mass of documenantion shall not put you off - you don't need to read all of it ?
It's just:
Anything can be done on paper can be done with TeX.
And nowadays the package simply just installs everything.
So it's much.
You only pick, what you want/need, which will be app. 1%, only. (It's doable :cool:)
so I can ditch MS Word once and for all.
That's a very good idea!
You won't regret it.

Warning:
You may run into the same issue like me, or others:
As long as you need at least access to files others wrote it's unlikely to avoid it completely - well, you may use LibreOffice instead.
And once you became a bit fond of typesetting (LaTeX - it's no rocket science; once you have a template with definitions you may look up most commands until you remember them) you will join the club of those who rant:
'why all this morons still use those stupid wordprocessor crap, while writing with a good texteditor, and then do really good typesetting with LaTeX, or troff/nroff/groff; it's so much more efficient, and delivers way better results?!?'

'Disadvantages:
One gets an eye for all the bad documents out there'
Dr Engelbert Buxbaum, 'The LATEX document preparation system'
/usr/local/share/texmf-dist/doc/latex/latex-course/LaTeX-Course.pdf
?

Now I can paste a bunch of paragraphs from MS Word into vi
As far as I remember Word is capable to export to text.
You may additionally know about iconv(1)
It converts from Window's UTF-16 to Unix' UTF-8 (and many others)
 
A little tip in case you must preserve the Word* layout: AbiWord. It can read Word documents and export to LaTeX, giving you a rats nest of text but it works. It was of great help once when I was faced a day before deadline with the demand that the donating organisation wanted to have their "we so great" page in, provided in Word and the layout to be kept as-is.

*: Of course it is called Word, not Text, for reasons obvious to the cynic.
 
I am using Micro and AsciiDoctor to write some documentation and I find the combo pretty good indeed.
Micro uses common paradigms, like ctrl-c/v to copy and paste, it looks like a regular text editor such as Mousepad or Gedit but in salsa TUI with steroids, since it has commands that you can run through a prompt.
 
That's exactly one of the core points of
Allin Cottrell, 'Wordprocessors: Stupid and Inefficient'
with a texteditor you focus on your text, write what you want to write.
Typesetting comes afterwards, when the text is written.
With wordprocessors (MS Word, LibreOffice) you start with typesetting even if you haven't written a single word yet, and with any WYSIWYG (including TeX-live-editor-systems) you keep fumbling/finetuning continously with typesettings while writing, instead to focus on writing your text.
I went to Journalism school just as electronic newspaper composition systems were coming into vogue, so they were still teaching the old ways. We typed our stories on typewriters, double spaced. Since typewriters didn't do italic, we underlined anything that should be italicized. Any other typographic styling was the editor's job and not our problem. It made it easier to concentrate on the story.

One of my instructors had an interesting comment about the electronic newspaper composition systems (which still isolated the reporter from the typographical stuff). He said that originally, newspapers thought the electronic systems would let reporters write stories more quickly. He said that a reporter is going to polish their story until just before deadline, so faster editing doesn't mean the story gets done more quickly. It takes the same amount of time, but the result is a better-written story.
 
My favorite feature with Vi when writing LaTeX papers is the following keystrokes:

!}fmt
I have had the following in my EXINIT env. var since forever!
map ^X !}fmt -p 60 61^M
Originally -p was not needed. And I used to use longer line length.

For LaTeX I use TeXworks (but edit in nvi). Most all of my technical documents use LaTeX.

What I want is an editor like Obsidian but using AsciiDoc. But Obsidian itself has gotten a bit too complicated. I want something simpler. TUI is fine. Mainly the ability to cross-link code and text.
 
I used to use LaTeX (Xe and Lua flavors)… then I (re)discovered groff (with ms macro set).
Groff is a venerable and an absolutely awesome tool… now groff is my daily typesetting tool.

I still use (n)vi to type texts and sources, I can't do without.
 
I observed it on myself:

When I started computering in the 1980s (you, lgrant, started earlier, so nothing new for you what comes now :cool:)
the very few first rendering/typesetting/WYSIWYG systems were in their very early experimenting babyshoes - if even available on accessable machines.
There was just pure text - texteditors - only. Not even the possibility to even change the font. You could switch between two, or three screen modes, but that was it. Same thing at our local newspaper I used to work as a pupil to write (tiny) articels - exactly what you described: Typesetting? Not even remotely touchable.
It was a good thing, but I didn't knew it back then.

Later in the early 90s, most were still using typewriters, but at our Technical U most were switching to computers quickly. Like my girlfriend at this time. Got her first 80386 for using WordPerfect on Win 3.11.
But when the first WYSIWYG systems become available, and quickly standard, I already was using LaTeX.
Point was back then all I had was an Amiga 2000 - as a student I couldn't afford to buy me a new computer shortly again; and why. It was a very nice machine. Fully sufficient. With one deficit: There was nothing really useful avaible for the Amiga which produced some document you could drop shameless at the university.
Nothing even remotely capable to write a thesis with.
But there already was LaTeX for Amiga - which I didn't ever heard of that time.
(Maybe this reaches some who were involved in that: Thank you very much to port LaTeX to the Amiga! You not only helped me a lot, but delivered the right horse before I was corrupted by wordprocessors. :cool:)
So a friend of mine - the local Amiga user group already all used TeX - installed me LaTeX on my Amiga - no internet then, so doing the diskjockey on dozens of 3,5" diskettes for almost a weekend - ⌛:beer::beer::beer::beer::beer::beer::beer:...?)
But it worked.
Sometimes a bit slowly - "dannd; she needs to render a font, again *sigh* okay, time for the groceries" - but it worked!
And not only that.
The results were brilliant, uncomparable with what the WordPerfect/Word-Users delivered.
While some were doing diagrams not seldom still by hand, I already used Gnuplot.
Some of the teachers were amazed:"Wow! That looks great! How did you do that?" ?
And it was all for free. While a license for a wordprocessor even at student's rates cost (I can't remember, but for a student it was something about half the month's rent, or so.)
Well not completely for free - you had to learn it.
That's the crucial point of all Windows-crap up to day: You pay money for the illusion you may not need to learn anything.
And not only that.
LaTeX was reliable.
While others came into the pub late at night, completely stressed, because their fantastic, fancy, and expensive Word-system already crashed again - more than a dozen pages containing several graphics could have brought those machines back then way over their limit; and Windows was anything but rock solid (while Amiga OS was older but pretty solid) - fumbled manually with not matching pagenumbers, and tables of contents, wasted a lot of paper for printing, because still a single word appeared on an else empty page although their fancy "WYSIWYG" shown different - not to mention about no regular saves, of course not; backups? what is 'backups'? :rolleyes:, empty printer cartdriges, no paper, naturally late at night on a weekend, and of course monday was deadline...???:mad: -
we LaTeX users were: ?:beer:?:beer:?:beer:?:beer:?✌️:beer:?
"Use LaTeX!! For Christ's sake! It's no rocket science! We're all done for a week - with no stress at all!"
Back then I worked with emacs.

So my normal workflow on writing something always was to separate text from typesetting.

Later on the job as an employee in companys of course there always were Windows machines only, with MS Office, of course. So I had to work with Word.
I hated it.
It's so inefficient, so time wasting - could have done a better job in less than half the time with LaTeX, its UI is so not-intuitive, its usage illogical, its files are bloated, its results look so ugly ... - Word sucks!
So I installed a Tex-Live system on all my office machines, and every document not to be edited by others (e.g. datasheets I produced for my electronics) I did in LaTeX.
I needed some oasis of efficient, intuitive work, not always :rude:?? all the time.

Even later when I became self-employed: Good bye MS Office!
Even later: Good bye Windows!
Hello FreeBSD, Hello LaTeX, Hello vim ?

And I still observe it on myself.
When I have to use some WYSIWYG system, some wordprocessor again, at two-and-a-half pages at the latest, my concentration is so wasted, distracted by looking at, and keep the typesetting correct all the time - otherwise it annoys me much, I simply lost the thread several times, even forgot what I wanted to write; not really thinking about anymore how to phrase something better, sometimes even give a damn about the spelling, just get it on the paper somehow.
Using the texteditor only, and just write, don't even look at the line's length -I recommend to activate automatic line breaks, especially when writing texts using vi[m]; and chose a good readable font for your terminal; but that's it.
I can write a dozen pages.
And my language is way better.

Typesetting comes afterwards.

So, yes.
 
then I (re)discovered groff
I personally never used groff (or likewise) so far.
But I have my eye on it, and maybe someday I will try it.
All I saw about it by manpages, tutorials, etc. so far is:
1. It produces results at least as good as standard [La]TeX
2. It seems way easier to learn; much less complex, shorter commands, better readable source (if the LaTeX source contains lots of fancy stuff.)
With LaTeX you can do (way) more things.
But if you don't need them, one may better use it instead of LaTeX - I agree.
 
[snip]
With LaTeX you can do (way) more things.
But if you don't need them, one may better use it instead of LaTeX - I agree.
Absolutely.

All I need is to have consistent typesetted documents with headers numbered, pictures inclusion, TOC, and columns.
Groff is sufficient for that and the result is visually awesome.
One can also easily use any TTF or OTF font with groff, thanks to guys like WA.Iglesias (a novelist by the way).

I manage typographic specifics (non breaking spaces, narrow spaces etc.) by parsing (mostly sed and tr) the source before piping it to groff, for instance:

sh ./my_parser.sh ./my_source.ms | groff -Kutf8 -e -Tps -dpaper=a4 -P-pa4 -ms - | ps2pdf - | zathura -

All in all, groff is lightweight, and handy.

groff ~25Mb at most
TeXLive (full) > 4Gb

PS: Recently I often tend to use "ed" as my main text editor… I go back to very ancient yet powerful tools.
 
Back
Top