jemnotesversion 2 / featuring vim or see all/search

Feb 21
I have long used ^x^l to complete lines in vim. I only just realized, thanks to the always-excellent vim help pages, that if you do it multiple times, it keeps completing further lines under the previously-matched line. Not only that, but it will offer choices based on the entire block matched up until then.
Feb 16
When you hit o for a newline in vim, you often get the comment character prepended to your line. You can avoid this using
set fo-=o
Jan 16
Pull a non-ascii character onto the search bar (courtesy this good page):
yl/<C-R>"
This obviously expands to copying larger amounts of text as well. (And makes plenty of sense.)
Jan 11
Just use this (source):
:g/.*/m0
Dec 10
If you want to replace a line in vim with the contents of the unnamed register, you can just V to select the line, then p to paste over it. No need to use the black hole register.
Oct 29
Leave off the end of a regex replace in vim, and it will just remove the matched expression. For example, these are identical:
:+s/searchtext
:+s/searchtext//
Sep 11
  • Open the last file with :e\#.
  • U undoes all changes to the current line.
  • <Ctrl-D> <Ctrl-T> to change indent in insert mode.
  • :helpgrep, then :cn / :cN to move between matches.
  • '^ to last position where insert mode was stopped.
  • '' to the position before the latest jump.
  • '. to the position where the last change was made.
  • ": contains the last-executed command, so @: repeats that command.
  • set virtualedit lets you position the cursor where there is no actual character. Useful for editing tables etc.
Aug 18
After searching for something in vim, you can use +s//repl pattern/, and the search string will default to the previous search you just performed.
Jun 11
I found it difficult to find help on the various ways of modifying the filename in a vim script. Turns out that :help filename-modifiers uses the correct keyword.
May 7
Reminder: use ctrl+t and ctrl+d to increase/decrease the indent while in insert mode.
May 5
In smartindent mode, vim removes the indent if # is the first character on the line. This is annoying. I’ve tried various solutions that should work but don’t. Here’s one that should, and does:
inoremap # a#<Left><BS><Right>
(Courtesy of this vim tip, but beware; it contains some false information as well.) Use ^v (ctrl+v) to enter the special sequences easily.
Sep 1
Nice way of having two different kinds of syntax highlighting within one file, with vim.
Aug 16
Aug 14
Disable highlighting of spurious _ and ^ symbols in LaTeX files as errors (say, when a macro is used to start equation environments).
autocmd Filetype tex syntax clear texOnlyMath
Aug 6
The numbered register "0 contains the text from the most recent yank command, while the numbered register "1 contains the text from the most recent delete or change command. If the delete or change was ‘small’, though, (ie, less than one line), the small delete register "- is used instead.
This means that if you yank some text to move it elsewhere, then rearrange some stuff (including deleting, say, newlines), you can still easily retrieve the text that you yanked with "0p.
Jul 22
When pasting from the clipboard, in the terminal version of vim, use :put + (or :put *, depending on your system) to avoid indentation problems.