==============================================================================
Useful mappings *useful-mappings*
Here are a few mappings that some people like to use.
*map-backtick* >
:map ' `
Make the single quote work like a backtick. Puts the cursor on the column of
a mark, instead of going to the first non-blank character in the line.
*emacs-keys*
For Emacs-style editing on the command-line: >
" start of line
:cnoremap <C-A> <Home>
" back one character
:cnoremap <C-B> <Left>
" delete character under cursor
:cnoremap <C-D> <Del>
" end of line
:cnoremap <C-E> <End>
" forward one character
:cnoremap <C-F> <Right>
" recall newer command-line
:cnoremap <C-N> <Down>
" recall previous (older) command-line
:cnoremap <C-P> <Up>
" back one word
:cnoremap <Esc><C-B> <S-Left>
" forward one word
:cnoremap <Esc><C-F> <S-Right>
<
*format-bullet-list*
This mapping will format any bullet list. It requires that there is an empty
line above and below each list entry. The expression commands are used to
be able to give comments to the parts of the mapping. >
:let m = ":map _f :set ai<CR>" " need 'autoindent' set
:let m ..= "{O<Esc>" " add empty line above item
:let m ..= "}{)^W" " move to text after bullet
:let m ..= "i <CR> <Esc>" " add space for indent
:let m ..= "gq}" " format text after the bullet
:let m ..= "{dd" " remove the empty line
:let m ..= "5lDJ" " put text after bullet
:execute m |" define the mapping
(<> notation |<>|. Note that this is all typed literally. ^W is "^" "W", not
CTRL-W.)
Note that the last comment starts with `|"`, because the ":execute" command
doesn't accept a comment directly.
You also need to set 'textwidth' to a non-zero value, e.g., >
:set tw=70
A mapping that does about the same, but takes the indent for the list from the
first line (Note: this mapping is a single long line with a lot of spaces): >
:map _f :set ai<CR>}{a <Esc>WWmmkD`mi<CR><Esc>kkddpJgq}'mJO<Esc>j
<
*collapse*
These two mappings reduce a sequence of empty (;b) or blank (;n) lines into a
single line >
:map ;b GoZ<Esc>:g/^$/.,/./-j<CR>Gdd
:map ;n GoZ<Esc>:g/^[ <Tab>]*$/.,/[^ <Tab>]/-j<CR>Gdd
==============================================================================
Compressing the help files *gzip-helpfile*
For those of you who are really short on disk space, you can compress the help
files and still be able to view them with Vim. This makes accessing the help
files a bit slower and requires the "gzip" program.
(1) Compress all the help files: "gzip doc/*.txt".
(2) Edit "doc/tags" and change the ".txt" to ".txt.gz": >
:%s=\(\t.*\.txt\)\t=\1.gz\t=
(3) Add this line to your vimrc: >
set helpfile={dirname}/help.txt.gz
Where {dirname} is the directory where the help files are. The |gzip| plugin
will take care of decompressing the files.
You must make sure that $VIMRUNTIME is set to where the other Vim files are,
when they are not in the same location as the compressed "doc" directory. See
|$VIMRUNTIME|.
==============================================================================
Hex editing *hex-editing* *using-xxd*
See section |23.3| of the user manual.
If one has a particular extension that one uses for binary files (such as exe,
bin, etc), you may find it helpful to automate the process with the following
bit of autocmds for your |init.vim|. Change that "*.bin" to whatever
comma-separated list of extension(s) you find yourself wanting to edit: >
" vim -b : edit binary using xxd-format!
augroup Binary
autocmd!
autocmd BufReadPre *.bin set binary
autocmd BufReadPost *.bin
\ if &binary
\ | execute "silent %!xxd -c 32"
\ | set filetype=xxd
\ | redraw
\ | endif
autocmd BufWritePre *.bin
\ if &binary
\ | let s:view = winsaveview()
\ | execute "silent