Difference between revisions of "Vim for Writers"

(Useful information for writers on how to use vim for novel planning and writing)
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
Starting a new thread on [http://www.vim.org/ vim] because just today I discovered some power plugins and tools that I hadn't been aware of before; and that makes me think that there must be other vim users out there who have still other vim-related tips and tricks to share.
 
  
I had been trying out Kabikaboo but was discomfited by stability issues it had (someday I want to write an application to do that kind of GUI-driven reorganization of text blocks that can be edited in vim...), so I wondered whether I should take another look at vim folding. Lo and behold, I found a [http://vimcasts.org/episodes/how-to-fold/ video that made vim folding look utterly simple] (previously, I had tried vim outliner but it somehow never stuck with me, even though I've been a vim user since the 1990's).
+
== Introduction ==
 +
[http://www.vim.org/ vim] is a very powerful [http://www.viemu.com/a-why-vi-vim.html modal text editor] with a large system of plugins. You may have heard of the infamous [https://www.udemy.com/blog/vim-vs-emacs/ vim vs. emacs] wars that have existed from the time of usenet and persist till today. [http://net.tutsplus.com/articles/web-roundups/25-vim-tutorials-screencasts-and-resources/ vim does have a learning curve] but it is very worthwhile to learn because your fingers never leave the keyboard as you are writing and editing. ViM = Vi Improved; it is a superset of the original vi editor.
  
The vimcast video was good; however, it took a little work to get my environment to where I was opening folds with a simple spacebar press; and to where my [http://daringfireball.net/projects/markdown/ markdown] file (for later transformation via [http://johnmacfarlane.net/pandoc/ pandoc]) was automatically folded.
+
== A great example vimrc (WurdBender) ==
 +
[http://nanowrimo.org/participants/wurdbender WurdBender] writes:  
 +
I noticed most of the Vim community seems to prefer the Solarized theme, but I really can't stand it myself. I've been using Tomorrow Night from the repository you linked, except I run in 256 color mode (set t_Co=256) to subdue the colors a bit. I'm still trying out fonts. At the moment I'm liking Input Mono.
  
# installed [https://github.com/gmarik/vundle vundle], a vim bundle manager that lets you EASILY install other vim plugins/bundles.
+
Below is what my setup looks like with some code to show off the colors. I wasn't sure I'd get much use out of the Airline bar, but it comes in handy. I've also created a [https://github.com/WurdBendur/vimrc/blob/master/.vimrc repository for my .vimrc on GitHub], which I'm told is a good idea in case you need to quickly set up Vim on a new system. It's there if anybody wants to see it, though it's maybe a bit cluttered and noobish.
# used vundle to install [https://github.com/tpope/vim-markdown vim-markdown] (better markdown syntax highlighting) and [https://github.com/nelstrom/vim-markdown-folding vim-markdown-folding]  
 
# added the spacebar mapping to my .vimrc:<br/> <nowiki>nnoremap <Space> za</nowiki>
 
  
Then I discovered the beauty of [https://github.com/altercation/vim-colors-solarized vim-colors-solarized] that "''is a sixteen color palette (eight monotones, eight accent colors) designed for use with terminal and gui applications. It has several [https://github.com/altercation/solarized#features unique properties]. I designed this colorscheme with both precise [http://en.wikipedia.org/wiki/Lab_color_space CIELAB] lightness relationships and a refined set of hues based on fixed color wheel relationships. It has been tested extensively in real world use on color calibrated displays (as well as uncalibrated/intentionally miscalibrated displays) and in a variety of lighting conditions.''" ([http://ethanschoonover.com/solarized ethanschoonover.com])
+
=== A derivative vimrc (NewMexicoKid) ===
 +
[http://nanowrimo.org/participants/newmexicokid NewMexicoKid] writes:
 +
I made a (slightly modified) [https://github.com/NewMexicoKid/vimrc vimrc] based on WurdBender's. I turned off numbers (too technical for NaNo), added autoindent and shift width/expand tab (which I find more useful for doing sub-bullets in markdown).
  
Vim is, basically, my goto editor for just about anything (I'm a programmer by trade, so it's perhaps unsurprising).
+
== How to learn how to use vim ==
 +
* [https://www.quora.com/What-is-the-best-way-to-learn-Vim quora answers on the best ways to learn vim]
  
Personally, I use vim script called [https://github.com/cwoac/nvim nvim] to build my piles of random little notes during planning - it works well for me, but then again it ought to given I wrote it!
+
== vimrc tips ==
 +
HBBisenieks writes:
 +
Most of my vimrc is set for the benefit of my dayjob as a sysadmin, but one line I always make sure is in my vimrc is
  
Vim can be more or less as powerful as you want it. It's really worth the time spent learning how to jump around ( using '(' and ')' to jump to the start of the previous / next sentence in particular).
+
  set title
 +
 
 +
That way I rarely forget what file I'm editing.
 +
 
 +
== ViM Folding ==
 +
Here is a must-see [http://vimcasts.org/episodes/how-to-fold/ video that makes vim folding look utterly simple].
 +
 
 +
Also see this plugin: [https://github.com/vimoutliner/vimoutliner vim-outliner]
 +
 
 +
== ViM plugins ==
 +
There are several ViM plugin managers. One of them is: [https://github.com/gmarik/vundle vundle], a vim bundle manager that lets you EASILY install other vim plugins/bundles.
 +
 
 +
== Markdown ==
 +
[http://daringfireball.net/projects/markdown/ Markdown] is a very simple mark-up language that encourages writers to focus on their content rather than on presentation. It can handle '''bolding''', ''italics'', bullet lists, section headings, hypertext links, etc. and you can use utilities like [http://johnmacfarlane.net/pandoc/ pandoc] to transform your markdown text to many, many different formats, including:
 +
 
 +
* .PDF
 +
* .docx, .doc and .rtf
 +
* [http://www.latex-project.org/ LaTeX]
 +
* [http://johnmacfarlane.net/pandoc/epub.html epub]
 +
* [http://mediawiki.org Mediawiki]
 +
 
 +
ViM has plugins for better markdown syntax highlighting ([https://github.com/tpope/vim-markdown vim-markdown]) and [https://github.com/nelstrom/vim-markdown-folding vim-markdown-folding]. With the latter, you can:
 +
 
 +
* add the spacebar mapping to your .vimrc:<br/> <nowiki>nnoremap <Space> za</nowiki>
 +
 
 +
Some [http://lincolnmullen.com/blog/make-and-pandoc/ use gnu make to automatically generate everything from the markdown source].
 +
 
 +
== Beautiful colors ==
 +
Check out the beauty of [https://github.com/altercation/vim-colors-solarized vim-colors-solarized] that "''is a sixteen color palette (eight monotones, eight accent colors) designed for use with terminal and gui applications. It has several [https://github.com/altercation/solarized#features unique properties]. I designed this colorscheme with both precise [http://en.wikipedia.org/wiki/Lab_color_space CIELAB] lightness relationships and a refined set of hues based on fixed color wheel relationships. It has been tested extensively in real world use on color calibrated displays (as well as uncalibrated/intentionally miscalibrated displays) and in a variety of lighting conditions.''" ([http://ethanschoonover.com/solarized ethanschoonover.com])
 +
 
 +
Also see [https://www.quora.com/What-are-some-of-the-best-Vim-color-schemes this quora question with plenty of answers that recommend different color schemes].
  
You can get help on just about any vim feature by entering the command ':help SOMETHING', e.g. ':help spell'
+
Another couple of references that show you color samples:  
 +
* http://vimcolors.com/
 +
*
  
Useful .vimrc options for beginners:
+
== Notes for Planning ==
 +
See the vim script called [https://github.com/cwoac/nvim nvim] to build piles of random little notes during novel planning.
  
'set autowriteall' - autosave your current document whenever you change away from the current buffer. You can just do 'set autowrite', which will save in *most* situations (the main exemption being quitting).
+
== Movement ==
 +
Vim can be more or less as powerful as you want it. It's really worth the time spent learning how to jump around ( using '(' and ')' to jump to the start of the previous / next sentence in particular).
  
'set spell spelllang=en_gb' - enable (in this case British) spell checking - see the help page for details of the commands to jump to mistakes and pick / learn corrections.
+
== Help ==
 +
* You can get help on just about any vim feature by entering the command ':help SOMETHING', e.g. ':help spell'
 +
* This might be useful: [http://bullium.com/support/vim.html Vim Commands Cheat Sheet]
  
 +
== Autosave ==
 +
* 'set autowriteall' - autosave your current document whenever you change away from the current buffer. You can just do 'set autowrite', which will save in *most* situations (the main exemption being quitting).
 +
* There is also a vim plugin: [https://github.com/907th/vim-auto-save https://github.com/907th/vim-auto-save]. It apparently turns on auto save and saves every time a buffer is modified.
  
Found [http://www.cs.swarthmore.edu/help/vim/vim7.html some more documentation on the built-in support for spell checking] (as of vim 7).
+
== Spell Checking ==
 +
* 'set spell spelllang=en_gb' - enable (in this case British) spell checking - see the help page for details of the commands to jump to mistakes and pick / learn corrections.
 +
* See [http://www.cs.swarthmore.edu/help/vim/vim7.html some more documentation on the built-in support for spell checking] (as of vim 7).
  
 
* it supports a personal word list (very useful for fantasy authors ;-) )  
 
* it supports a personal word list (very useful for fantasy authors ;-) )  
Line 41: Line 87:
 
** :spellr - repeat last spell replacement for all words in window  
 
** :spellr - repeat last spell replacement for all words in window  
  
If you *do* happen to use vim, this might be useful:&nbsp;[http://bullium.com/support/vim.html http://bullium.com/support/vim.html]
+
== Thesaurus ==
 +
* [https://github.com/beloglazov/vim-online-thesaurus a thesaurus plugin for vim]
  
 +
== WriteRoom / DarkRoom simulator ==
 +
There apparently are many writeroom/darkroom vim plugins and configurations for "distraction free writing". Of the three I tried, I think I like this plugin ([http://projects.mikewest.org/vimroom/ vimroom]) the best. For installation using vundle, see [https://github.com/mikewest/vimroom https://github.com/mikewest/vimroom] (Bundle 'mikewest/vimroom'). [https://github.com/vim-scripts/DistractFree/blob/master/doc/DistractFree.txt A rival noted ]that on Windows, VimTweak yields transparent gvim windows.
  
Here are a few more vim novel writing resources that have caught my eye:
+
== Sessions ==
 +
''Sessions can be used to save window configurations''
 +
* https://github.com/xolox/vim-session
 +
* https://github.com/xolox/vim-misc
  
* [http://chrismdp.com/2010/11/how-im-writing-my-book-using-git-and-ruby/ an article of a guy who wants to devise a ruby gem for handling novel writing/formatting tasks] (okay, not really a vim resource; but something that looked interesting to those of us writing text files)
+
You can use vundle to load both of these and then :SaveSession to save the session. Put
* [http://www.antipope.org/charlie/blog-static/2010/01/writing-tools.html blog article about writing novels in a text editor vs. a WYSIWYG word processor]<nowiki>; some interesting comments, including a reference to </nowiki>[http://bitbucketlabs.net/flashbake/ flashbake], a set of scripts designed to make it easier for writers to use version control software
 
* [http://www.drbunsen.org/writing-in-vim/ writing in vim] -- this author shares his vimrc and some of his plugins; the thing of interest here is his use of a set thesaurus command. I found this intriguing and found [https://github.com/beloglazov/vim-online-thesaurus this nifty thesaurus plugin for vim] that looks very useful and usable.
 
* there apparently are many writeroom/darkroom vim plugins and configurations for "distraction free writing". Of the three I tried, I think I like this plugin ([http://projects.mikewest.org/vimroom/ vimroom]) the best. For installation using vundle, see [https://github.com/mikewest/vimroom https://github.com/mikewest/vimroom] (Bundle 'mikewest/vimroom'). [https://github.com/vim-scripts/DistractFree/blob/master/doc/DistractFree.txt A rival noted ]that on Windows, VimTweak yields transparent gvim windows.
 
* [http://vim.wikia.com/wiki/Word_count the vim wikia gives some very good options for managing wordcount] (simplest is '''g''' then '''Ctrl-g''').  
 
  
Found and installed this vim plugin today: [https://github.com/907th/vim-auto-save https://github.com/907th/vim-auto-save]
+
  let g:session_autosave = 'no'
  
It apparently turns on auto save and saves every time a buffer is modified.
+
at the end of your vimrc so you don't get prompted to save sessions when you close files. A session will preserve your layout and place in the file--very cool!
  
Considering two of the plugins mentioned [http://www.openlogic.com/wazi/bid/276417/Nine-all-purpose-plugins-for-Vim in this blog article suggesting nine]:
+
== Wordcount ==
 +
* [http://vim.wikia.com/wiki/Word_count the vim wikia gives some very good options for managing wordcount] (simplest is '''g''' then '''Ctrl-g''').
 +
* Found [http://cromwell-intl.com/linux/vim-word-count.html this .vimrc script for putting the current wordcount in the status line]:
  
* Showmarks<br/> Marks are '''bookmarks within a Vim document. '''You can set a mark by pressing m followed by another letter that designates the mark. To jump to a mark, enter ' followed by the mark's letter.<br/> The great weakness of marks is that they are invisible. This limits the number you can use to however many you can remember, and you can easily accidentally overwrite an existing mark by creating another with the same name.<br/> [https://github.com/vimez/vim-showmarks Showmarks] allows you to toggle the visibility of marks off and on – and that tiny functionality is enough to increase the usefulness of marks several times over.
+
<nowiki>
* Vim-abolish<br/> [https://github.com/tpope/vim-abolish Vim-abolish] is so elegant that you wonder why no one thought of it before, but it's hard to describe. It has aspects of a word processor's spell checker or autocorrect, but might best be described as a configurable search and replace tool. '''What makes Vim-abolish so powerful is that it allows you not only to search and replace one word or spelling for another, but also to include all instances of a word. Upper case, lower case, noun and adverb, past and present tense, participles''' – all can be added to the search and replaced with a few dozen characters.<br/> Admittedly, you might take a while to learn how to think in the terms necessary to set up a Vim-abolish command, and learning how to construct a command may take some time too. However, once you understand how Vim-abolish works, you will probably find it an invaluable proofreading tool.
+
  """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 +
  " Here begins my automated wordcount addition.
 +
  " This combines several ideas from:
 +
  " http://stackoverflow.com/questions/114431/fast-word-count-function-in-vim
 +
  """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 +
  let g:word_count="<unknown>"
 +
  function WordCount()
 +
      return g:word_count
 +
  endfunction
 +
  function UpdateWordCount()
 +
      let lnum = 1
 +
      let n = 0
 +
      while lnum <= line('$')
 +
          let n = n + len(split(getline(lnum)))
 +
          let lnum = lnum + 1
 +
      endwhile
 +
      let g:word_count = n
 +
  endfunction
 +
  " Update the count when cursor is idle in command or insert mode.
 +
  " Update when idle for 1000 msec (default is 4000 msec).
 +
  set updatetime=1000
 +
  augroup WordCounter
 +
      au! CursorHold,CursorHoldI * call UpdateWordCount()
 +
  augroup END
 +
  " Set statusline, shown here a piece at a time
 +
  highlight User1 ctermbg=green guibg=green ctermfg=black guifg=black
 +
  set statusline=%1*            " Switch to User1 color highlight
 +
  set statusline+=%<%F            " file name, cut if needed at start
 +
  set statusline+=%M            " modified flag
 +
  set statusline+=%y            " file type
 +
  set statusline+=%=            " separator from left to right justified
 +
  set statusline+=\ %{WordCount()}\ words,
 +
  set statusline+=\ %l/%L\ lines,\ %P    " percentage through the file
 +
</nowiki>
  
Next, I think I will buff up my perl script that I used for word wars (incremental wordcounts by saving my current word count in a file along with the current date and time; then doing a little math). It might also help me keep track of my writing progress [http://thisblogisaploy.blogspot.com.es/2011/06/how-i-went-from-writing-2000-words-day.html as Rachel Aaron advised in this excellent blog article] (on how to increase ones writing productivity).
+
== Vim Wiki ==
 +
The [https://github.com/vimwiki/vimwiki vim wiki plugin] is surprisingly powerful. I've noticed quite a few people advocating the use of the [http://zim-wiki.org/ zim desktop wiki tool] (but, of course, it isn't edited in vim, even though there is a vim [http://www.vim.org/scripts/script.php?script_id=3703 zim syntax support]); I regularly use Mediawiki instances (and once played with [http://tiddlywiki.com/ tiddlywiki]). The vim wiki plugin looks interesting; and, since I now use the [https://github.com/gmarik/vundle vundle] plugin manager, I may give it a try.
  
 +
Some reviews I've seen for vim wiki:
  
I was looking into software for novel writing and there's surprisingly little that's free, 64 bit and doesn't require mono. I'm pretty particular about my working environment so I refuse to mess it up with 32bit compatibility libraries.
+
* one guy [http://www.stochasticgeometry.ie/2012/11/23/vimwiki/ uses it along with encryption and distribution through Mercurial]
 +
* another [http://code.google.com/p/vimwiki/wiki/TimeTrackingWithVimwiki uses it for time tracking]
 +
* '''holy cow!''' [https://www.youtube.com/watch?v=N2G8Quh9GdA&noredirect=1 vim wiki apparently has a really nifty ASCII table editing mode]--might be useful for tracking characters...  
  
Probably better this way, in the long run I'll be much happier with vim. I use it together with git (flashbake), vimroom, onlinethesaurus, vim-abolish, vim-repeat and vim-outline.Vimroom does not always work as well, and there's little support for it, but it's still usable with a bit of tinkering.
+
== Related Articles of Interest ==
 +
* [https://opensource.com/article/17/2/vim-plugins-writers Awesome vim plugins for writers] - Posted 08 Feb 2017 by Zsolt Szakács
 +
* [http://wynnnetherland.com/journal/reed-esau-s-growing-list-of-vim-plugins-for-writers ViM Plugins For Writers] - [https://github.com/reedes Reed Esau]'s growing list of ViM plugins for writers. Includes [https://github.com/reedes/vim-colors-pencil vim colors pencil] (pretty theme for writers), [http://github.com/reedes/vim-thematic vim thematic] (theme manager), [http://github.com/reedes/vim-pencil vim-pencil] (handles wrap modes for writers)
 +
* [http://chrismdp.com/2010/11/how-im-writing-my-book-using-git-and-ruby/ an article of a guy who wants to devise a ruby gem for handling novel writing/formatting tasks] (okay, not really a vim resource; but something that looked interesting to those of us writing text files)
 +
* [http://www.antipope.org/charlie/blog-static/2010/01/writing-tools.html blog article about writing novels in a text editor vs. a WYSIWYG word processor]; some interesting comments, including a reference to [http://bitbucketlabs.net/flashbake/ flashbake], a set of scripts designed to make it easier for writers to use version control software
 +
* [http://www.drbunsen.org/writing-in-vim/ writing in vim] -- this author shares his vimrc and some of his plugins; the thing of interest here is his use of a set thesaurus command. I found this intriguing and found [https://github.com/beloglazov/vim-online-thesaurus this nifty thesaurus plugin for vim] that looks very useful and usable.
 +
* Nine great plugins mentioned [http://www.openlogic.com/wazi/bid/276417/Nine-all-purpose-plugins-for-Vim in this blog article], including:
 +
** Showmarks<br/> Marks are '''bookmarks within a Vim document. '''You can set a mark by pressing m followed by another letter that designates the mark. To jump to a mark, enter ' followed by the mark's letter.<br/> The great weakness of marks is that they are invisible. This limits the number you can use to however many you can remember, and you can easily accidentally overwrite an existing mark by creating another with the same name.<br/> [https://github.com/vimez/vim-showmarks Showmarks] allows you to toggle the visibility of marks off and on – and that tiny functionality is enough to increase the usefulness of marks several times over.
 +
** Vim Signature<br/> [https://github.com/kshenoy/vim-signature vim-signature] is a plugin to place, toggle and display marks. Apart from the above, you can also
 +
*** Navigate forward/backward by position/alphabetical order
 +
*** Displaying multiple marks (upto 2, limited by the signs feature)
 +
*** Placing custom signs !@#$%^&*() as visual markers
 +
** Vim-abolish<br/> [https://github.com/tpope/vim-abolish Vim-abolish] is so elegant that you wonder why no one thought of it before, but it's hard to describe. It has aspects of a word processor's spell checker or autocorrect, but might best be described as a configurable search and replace tool. '''What makes Vim-abolish so powerful is that it allows you not only to search and replace one word or spelling for another, but also to include all instances of a word. Upper case, lower case, noun and adverb, past and present tense, participles''' – all can be added to the search and replaced with a few dozen characters.<br/> Admittedly, you might take a while to learn how to think in the terms necessary to set up a Vim-abolish command, and learning how to construct a command may take some time too. However, once you understand how Vim-abolish works, you will probably find it an invaluable proofreading tool.
 +
* [http://thisblogisaploy.blogspot.com.es/2011/06/how-i-went-from-writing-2000-words-day.html Rachel Aaron advises tracking ones reading progress in this excellent blog article] (on how to increase ones writing productivity).
 +
* One user uses ViM together with git (flashbake), vimroom, onlinethesaurus, vim-abolish, vim-repeat and vim-outline. Vimroom does not always work as well, and there's little support for it, but it's still usable with a bit of tinkering.  Of all the plugins vim-outline is the most useful. She recommends it to everyone planning to use vim. It allows you to easily structure your text, and makes for easy folding/expanding.
 +
* [https://github.com/tpope/vim-repeat vim-repeat] looks interesting for better repetition with: .
 +
* Seth Brown wrote: [http://www.drbunsen.org/the-text-triumvirate/ The Text Triumvirate] (zsh, vim and tmux) -- in this article, Seth mentions [https://github.com/Lokaltog/powerline vim-powerline], a python-powered status line plugin. The author of that plugin then points to [https://github.com/bling/vim-airline vim-airline] as a lighter-weight but still featureful status line plugin.
 +
* [http://www.reddit.com/r/vim/comments/142zn7/are_you_interested_in_a_vim_for_writers_book/ one redditor has plans to write a book on Vim for Writers]<nowiki>; there are some interesting chapter titles in this reddit.</nowiki>
 +
* Here is a [https://www.youtube.com/watch?v=p6K4iIMlouI&noredirect=1 nifty Google tech talk by vim creator Bram Moolenaar] with useful tips for productive vim; and [http://connermcd.com/blog/2011/10/21/notetaking-with-vim/ a blog post] about how to use vim and ack for notetaking.
  
Of all the plugins vim-outline is the most usefull. I'd reccomend it to everyone planning to use vim. It allows you to easily structure your text, and makes for easy folding/expanding.
+
== Annotations ==
 +
Question: What's a good way to 'highlight' bits of text that you know you need to fact-check/add to/etc. so that it's easily seen upon a reread?  I've just changed the text color in programs I've used previously...but how to best do that in vim?
  
Spookje, can you give the URL for vim-outline? Are you referring to vim-[https://github.com/vimoutliner/vimoutliner outliner]?
+
One answer: I first thought about using [http://usevim.com/2013/01/18/tags/ vim tags] -- I have never used them before, but I've heard of them and it sounds like they do some things that might be useful.
 +
* Then I ran across the qfn ([http://www.vim.org/scripts/script.php?script_id=2216 quickfixnotes]) plugin. The [http://vimdoc.sourceforge.net/htmldoc/quickfix.html qfn helpfile] makes it sound like it is a step in the right direction:
  
[https://github.com/tpope/vim-repeat vim-repeat] looks interesting...
+
''In Vim the [http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix quickfix] commands are used more generally to find a list of positions in files. For example, |[http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:vimgrep :vimgrep]| finds [http://vimdoc.sourceforge.net/htmldoc/pattern.html#pattern pattern] matches. You can use the positions in a [http://vimdoc.sourceforge.net/htmldoc/usr_41.html#script script] with the |[http://vimdoc.sourceforge.net/htmldoc/eval.html#getqflist%28%29 getqflist()]| function. Thus you can [http://vimdoc.sourceforge.net/htmldoc/diff.html#do do] a lot more than the edit/compile/fix cycle!''
  
Seth Brown has two blog articles that also look interesting:
+
* But this [https://github.com/wdicarlo/vim-notebook vim-notebook plugin] sounds much more straightforward and easy-to-use right off the bat:
  
* [http://www.drbunsen.org/writing-in-vim/ Writing in ViM]
+
''This plugin has been created to annotate and aggregate key aspects, such as source code, documentation, notes etc, relative to tasks to be done. Annotations with referenced resources are stored into text files called notebooks under the folder $HOME/.notebook.''
* [http://www.drbunsen.org/the-text-triumvirate/ The Text Triumvirate] (zsh, vim and tmux) -- in this article, Seth mentions [https://github.com/Lokaltog/powerline vim-powerline], a python-powered status line plugin. The author of that plugin then points to [https://github.com/bling/vim-airline vim-airline] as a lighter-weight but still featureful status line plugin.  
 
  
Also, [http://www.reddit.com/r/vim/comments/142zn7/are_you_interested_in_a_vim_for_writers_book/ one redditor has plans to write a book on Vim for Writers]<nowiki>; there are some interesting chapter titles in this reddit.</nowiki>
+
''A typical usage scenario is:''
 +
# '' create a new notebook called issue_missing_refresh_of referenced_line ''
 +
# '' open the text file containing key information''
 +
# '' select text of interest''
 +
# '' annotate selecting proper category and description''
 +
# '' repeat annotation for other interesting text''
 +
# '' open the notebook to have an overview of interesting information''
 +
# '' go to an entry of interest''
 +
# '' jump to the referenced text file''
 +
# '' repeat the exploration with other entries''
  
 +
Traditionally, I've just made my notes directly in the text, marking it with NOTES ;-)
  
This year, I am planning on writing my novel in Markdown using Vim.&nbsp; As has already been suggested, I will be using Pandoc to convert to PDF and HTML for convenience.&nbsp; I found a great post about using 'gnu make' to automatically generate everything:
+
This year, though, writing in Markdown, I might take the HTML commenting approach ([https://groups.google.com/forum/#%21topic/pandoc-discuss/FnTRTIhCEi4 as suggested in this pandoc google group]). On the other hand, the [https://github.com/wdicarlo/vim-notebook vim-notebook plugin] sounds pretty cool--being able to annotate things in a separate file and yet jump to them at will... neat!
  
http://lincolnmullen.com/blog/make-and-pandoc/
+
== Why use ViM? ==
 +
'''Question''': Is there a portable OFFLINE text editor that could be run from a USB drive? If so, would such a thing be safe for use on public computers or able to be secured? It doesn't need to be anything fancy.
  
Finally, I will be using git as revision control and a form of backup to a central bitbucket repository.
+
'''One Answer''':
 +
A very good text editor [http://portableapps.com/apps/development/gvim_portable with a PortableApps version], [http://net.tutsplus.com/sessions/vim-essential-plugins/ lots of available, easily-manageable plugins] and extremely good ergonomics is [http://www.vim.org/ ViM] (vi improved).
  
 +
I would encourage you to see [http://naperwrimo.org/wiki/index.php?title=Vim_for_Writers this summary] of [http://nanowrimo.org/forums/nano-technology/threads/122633 this year's nano-technology thread on ViM] (that focuses on how ViM can be used for writing).
  
I'm curious whether anyone has used the [https://github.com/vimwiki/vimwiki vim wiki plugin]. I've noticed quite a few people advocating the use of the [http://zim-wiki.org/ zim desktop wiki tool] (but, of course, it isn't edited in vim, even though there is a vim [http://www.vim.org/scripts/script.php?script_id=3703 zim syntax support]); I regularly use Mediawiki instances (and once played with [http://tiddlywiki.com/ tiddlywiki]). The vim wiki plugin looks interesting; and, since I now use the [https://github.com/gmarik/vundle vundle] plugin manager, I may give it a try.
+
Why should you give this modal ASCII editor a try?
 
 
Some reviews I've seen for vim wiki:
 
  
* one guy [http://www.stochasticgeometry.ie/2012/11/23/vimwiki/ uses it along with encryption and distribution through Mercurial]  
+
* think of it as [http://www.viemu.com/a-why-vi-vim.html an extension to touch typing] (your fingers never need to reach for a mouse)
* another [http://code.google.com/p/vimwiki/wiki/TimeTrackingWithVimwiki uses it for time tracking]
+
* the [http://blog.ngedit.com/2005/06/03/the-vi-input-model/ vi input model is extremely efficient]  
* '''holy cow!''' [https://www.youtube.com/watch?v=N2G8Quh9GdA&noredirect=1 vim wiki apparently has a really nifty ASCII table editing mode]--might be useful for tracking characters...  
+
* because of [http://www.makeuseof.com/tag/top-7-reasons-to-give-the-vim-text-editor-a-chance/ these seven reasons] (well, the last is a bit facetious, but the other six are spot on: it's mature and people who learn it generally swear by it, it's free and has a vibrant community, it's customizable and extensible, it works over ssh connections, its configuration is extremely portable, and it is very thoroughly documented)
 +
* "[http://protoiyer.github.io/blog/2011/11/04/vim-at-20-simply-the-best-text-editor/ If you are someone who writes text or code for a number of hours every day, learning Vim would be a gamechanger for you.] "
  
I think I am wandering down a different internet trail at this point ;-) ; found a [https://www.youtube.com/watch?v=p6K4iIMlouI&noredirect=1 nifty Google tech talk by vim creator Bram Moolenaar] with useful tips for productive vim; and [http://connermcd.com/blog/2011/10/21/notetaking-with-vim/ a blog post] about how to use vim and ack for notetaking. But vim wiki looks very interesting...
+
== Other references ==
 +
* See [https://www.youtube.com/watch?v=aHm36-na4-4 Damian Conway's terrific talk with vim tips: More Instantly Better Vim] that has, among [http://is.gd/IBV2013 other things], a nifty plugin that handles orphaned swap files.
 +
* [http://benmccormick.org/2014/07/02/learning-vim-in-2014-vim-as-language/ Learning ViM as a language]
 +
* [http://timotheepoisot.fr/2014/01/01/vim-writing-environment/ Using ViM as a writing environment]

Revision as of 05:28, 11 February 2017

Introduction

vim is a very powerful modal text editor with a large system of plugins. You may have heard of the infamous vim vs. emacs wars that have existed from the time of usenet and persist till today. vim does have a learning curve but it is very worthwhile to learn because your fingers never leave the keyboard as you are writing and editing. ViM = Vi Improved; it is a superset of the original vi editor.

A great example vimrc (WurdBender)

WurdBender writes: I noticed most of the Vim community seems to prefer the Solarized theme, but I really can't stand it myself. I've been using Tomorrow Night from the repository you linked, except I run in 256 color mode (set t_Co=256) to subdue the colors a bit. I'm still trying out fonts. At the moment I'm liking Input Mono.

Below is what my setup looks like with some code to show off the colors. I wasn't sure I'd get much use out of the Airline bar, but it comes in handy. I've also created a repository for my .vimrc on GitHub, which I'm told is a good idea in case you need to quickly set up Vim on a new system. It's there if anybody wants to see it, though it's maybe a bit cluttered and noobish.

A derivative vimrc (NewMexicoKid)

NewMexicoKid writes: I made a (slightly modified) vimrc based on WurdBender's. I turned off numbers (too technical for NaNo), added autoindent and shift width/expand tab (which I find more useful for doing sub-bullets in markdown).

How to learn how to use vim

vimrc tips

HBBisenieks writes: Most of my vimrc is set for the benefit of my dayjob as a sysadmin, but one line I always make sure is in my vimrc is

  set title

That way I rarely forget what file I'm editing.

ViM Folding

Here is a must-see video that makes vim folding look utterly simple.

Also see this plugin: vim-outliner

ViM plugins

There are several ViM plugin managers. One of them is: vundle, a vim bundle manager that lets you EASILY install other vim plugins/bundles.

Markdown

Markdown is a very simple mark-up language that encourages writers to focus on their content rather than on presentation. It can handle bolding, italics, bullet lists, section headings, hypertext links, etc. and you can use utilities like pandoc to transform your markdown text to many, many different formats, including:

ViM has plugins for better markdown syntax highlighting (vim-markdown) and vim-markdown-folding. With the latter, you can:

  • add the spacebar mapping to your .vimrc:
    nnoremap <Space> za

Some use gnu make to automatically generate everything from the markdown source.

Beautiful colors

Check out the beauty of vim-colors-solarized that "is a sixteen color palette (eight monotones, eight accent colors) designed for use with terminal and gui applications. It has several unique properties. I designed this colorscheme with both precise CIELAB lightness relationships and a refined set of hues based on fixed color wheel relationships. It has been tested extensively in real world use on color calibrated displays (as well as uncalibrated/intentionally miscalibrated displays) and in a variety of lighting conditions." (ethanschoonover.com)

Also see this quora question with plenty of answers that recommend different color schemes.

Another couple of references that show you color samples:

Notes for Planning

See the vim script called nvim to build piles of random little notes during novel planning.

Movement

Vim can be more or less as powerful as you want it. It's really worth the time spent learning how to jump around ( using '(' and ')' to jump to the start of the previous / next sentence in particular).

Help

  • You can get help on just about any vim feature by entering the command ':help SOMETHING', e.g. ':help spell'
  • This might be useful: Vim Commands Cheat Sheet

Autosave

  • 'set autowriteall' - autosave your current document whenever you change away from the current buffer. You can just do 'set autowrite', which will save in *most* situations (the main exemption being quitting).
  • There is also a vim plugin: https://github.com/907th/vim-auto-save. It apparently turns on auto save and saves every time a buffer is modified.

Spell Checking

  • it supports a personal word list (very useful for fantasy authors ;-) )
  • some useful keys for spellchecking:
    • ]s - forward to misspelled/rare/wrong cap word
    • [s - backwards ]
    • S - only stop at misspellings
    • [S - in other direction
    • zG - accept spelling for this session
    • zg - accept spelling and add to personal dictionary
    • zW - treat as misspelling for this session
    • zw - treat as misspelling and add to personal dictionary
    • z= - show spelling suggestions
    • :spellr - repeat last spell replacement for all words in window

Thesaurus

WriteRoom / DarkRoom simulator

There apparently are many writeroom/darkroom vim plugins and configurations for "distraction free writing". Of the three I tried, I think I like this plugin (vimroom) the best. For installation using vundle, see https://github.com/mikewest/vimroom (Bundle 'mikewest/vimroom'). A rival noted that on Windows, VimTweak yields transparent gvim windows.

Sessions

Sessions can be used to save window configurations

You can use vundle to load both of these and then :SaveSession to save the session. Put

  let g:session_autosave = 'no'

at the end of your vimrc so you don't get prompted to save sessions when you close files. A session will preserve your layout and place in the file--very cool!

Wordcount

   """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
   " Here begins my automated wordcount addition.
   " This combines several ideas from:
   " http://stackoverflow.com/questions/114431/fast-word-count-function-in-vim
   """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
   let g:word_count="<unknown>"
   function WordCount()
       return g:word_count
   endfunction
   function UpdateWordCount()
       let lnum = 1
       let n = 0
       while lnum <= line('$')
           let n = n + len(split(getline(lnum)))
           let lnum = lnum + 1
       endwhile
       let g:word_count = n
   endfunction
   " Update the count when cursor is idle in command or insert mode.
   " Update when idle for 1000 msec (default is 4000 msec).
   set updatetime=1000
   augroup WordCounter
       au! CursorHold,CursorHoldI * call UpdateWordCount()
   augroup END
   " Set statusline, shown here a piece at a time
   highlight User1 ctermbg=green guibg=green ctermfg=black guifg=black
   set statusline=%1*            " Switch to User1 color highlight
   set statusline+=%<%F            " file name, cut if needed at start
   set statusline+=%M            " modified flag
   set statusline+=%y            " file type
   set statusline+=%=            " separator from left to right justified
   set statusline+=\ %{WordCount()}\ words,
   set statusline+=\ %l/%L\ lines,\ %P    " percentage through the file

Vim Wiki

The vim wiki plugin is surprisingly powerful. I've noticed quite a few people advocating the use of the zim desktop wiki tool (but, of course, it isn't edited in vim, even though there is a vim zim syntax support); I regularly use Mediawiki instances (and once played with tiddlywiki). The vim wiki plugin looks interesting; and, since I now use the vundle plugin manager, I may give it a try.

Some reviews I've seen for vim wiki:

Related Articles of Interest

  • Awesome vim plugins for writers - Posted 08 Feb 2017 by Zsolt Szakács
  • ViM Plugins For Writers - Reed Esau's growing list of ViM plugins for writers. Includes vim colors pencil (pretty theme for writers), vim thematic (theme manager), vim-pencil (handles wrap modes for writers)
  • an article of a guy who wants to devise a ruby gem for handling novel writing/formatting tasks (okay, not really a vim resource; but something that looked interesting to those of us writing text files)
  • blog article about writing novels in a text editor vs. a WYSIWYG word processor; some interesting comments, including a reference to flashbake, a set of scripts designed to make it easier for writers to use version control software
  • writing in vim -- this author shares his vimrc and some of his plugins; the thing of interest here is his use of a set thesaurus command. I found this intriguing and found this nifty thesaurus plugin for vim that looks very useful and usable.
  • Nine great plugins mentioned in this blog article, including:
    • Showmarks
      Marks are bookmarks within a Vim document. You can set a mark by pressing m followed by another letter that designates the mark. To jump to a mark, enter ' followed by the mark's letter.
      The great weakness of marks is that they are invisible. This limits the number you can use to however many you can remember, and you can easily accidentally overwrite an existing mark by creating another with the same name.
      Showmarks allows you to toggle the visibility of marks off and on – and that tiny functionality is enough to increase the usefulness of marks several times over.
    • Vim Signature
      vim-signature is a plugin to place, toggle and display marks. Apart from the above, you can also
      • Navigate forward/backward by position/alphabetical order
      • Displaying multiple marks (upto 2, limited by the signs feature)
      • Placing custom signs !@#$%^&*() as visual markers
    • Vim-abolish
      Vim-abolish is so elegant that you wonder why no one thought of it before, but it's hard to describe. It has aspects of a word processor's spell checker or autocorrect, but might best be described as a configurable search and replace tool. What makes Vim-abolish so powerful is that it allows you not only to search and replace one word or spelling for another, but also to include all instances of a word. Upper case, lower case, noun and adverb, past and present tense, participles – all can be added to the search and replaced with a few dozen characters.
      Admittedly, you might take a while to learn how to think in the terms necessary to set up a Vim-abolish command, and learning how to construct a command may take some time too. However, once you understand how Vim-abolish works, you will probably find it an invaluable proofreading tool.
  • Rachel Aaron advises tracking ones reading progress in this excellent blog article (on how to increase ones writing productivity).
  • One user uses ViM together with git (flashbake), vimroom, onlinethesaurus, vim-abolish, vim-repeat and vim-outline. Vimroom does not always work as well, and there's little support for it, but it's still usable with a bit of tinkering. Of all the plugins vim-outline is the most useful. She recommends it to everyone planning to use vim. It allows you to easily structure your text, and makes for easy folding/expanding.
  • vim-repeat looks interesting for better repetition with: .
  • Seth Brown wrote: The Text Triumvirate (zsh, vim and tmux) -- in this article, Seth mentions vim-powerline, a python-powered status line plugin. The author of that plugin then points to vim-airline as a lighter-weight but still featureful status line plugin.
  • one redditor has plans to write a book on Vim for Writers; there are some interesting chapter titles in this reddit.
  • Here is a nifty Google tech talk by vim creator Bram Moolenaar with useful tips for productive vim; and a blog post about how to use vim and ack for notetaking.

Annotations

Question: What's a good way to 'highlight' bits of text that you know you need to fact-check/add to/etc. so that it's easily seen upon a reread? I've just changed the text color in programs I've used previously...but how to best do that in vim?

One answer: I first thought about using vim tags -- I have never used them before, but I've heard of them and it sounds like they do some things that might be useful.

In Vim the quickfix commands are used more generally to find a list of positions in files. For example, |:vimgrep| finds pattern matches. You can use the positions in a script with the |getqflist()| function. Thus you can do a lot more than the edit/compile/fix cycle!

  • But this vim-notebook plugin sounds much more straightforward and easy-to-use right off the bat:

This plugin has been created to annotate and aggregate key aspects, such as source code, documentation, notes etc, relative to tasks to be done. Annotations with referenced resources are stored into text files called notebooks under the folder $HOME/.notebook.

A typical usage scenario is:

  1. create a new notebook called issue_missing_refresh_of referenced_line
  2. open the text file containing key information
  3. select text of interest
  4. annotate selecting proper category and description
  5. repeat annotation for other interesting text
  6. open the notebook to have an overview of interesting information
  7. go to an entry of interest
  8. jump to the referenced text file
  9. repeat the exploration with other entries

Traditionally, I've just made my notes directly in the text, marking it with NOTES ;-)

This year, though, writing in Markdown, I might take the HTML commenting approach (as suggested in this pandoc google group). On the other hand, the vim-notebook plugin sounds pretty cool--being able to annotate things in a separate file and yet jump to them at will... neat!

Why use ViM?

Question: Is there a portable OFFLINE text editor that could be run from a USB drive? If so, would such a thing be safe for use on public computers or able to be secured? It doesn't need to be anything fancy.

One Answer: A very good text editor with a PortableApps version, lots of available, easily-manageable plugins and extremely good ergonomics is ViM (vi improved).

I would encourage you to see this summary of this year's nano-technology thread on ViM (that focuses on how ViM can be used for writing).

Why should you give this modal ASCII editor a try?

Other references