Tuesday, October 14, 2014

How to paste into vim from external buffer without broking formatting

When I paste to vim some text from external buffer, e.g. using Ctrl-Shift-V in a terminal, the formatting is often broken. Use:
:set paste
Then paste the text. When you are done:
:set nopaste

Thursday, May 22, 2014

Wednesday, May 21, 2014

svn diff wrapper for vim with correct file names

#!/bin/sh

# use vimdiff to view diffs
DIFF="/usr/bin/vim -d -R"


NUM=$#  # number of arguments
LEFT=${6} # old file
RIGHT=${7} # new file
L_TITLE=${3} # actual name and revision of old file
R_TITLE=${5} # actual name and revision of new file

L_TITLE=`echo $L_TITLE | tr -s ' ' | sed 's/ /\\\\ /g'`
R_TITLE=`echo $R_TITLE | tr -s ' ' | sed 's/ /\\\\ /g'`

$DIFF $LEFT $RIGHT -c "setl stl=$L_TITLE | wincmd W | setl stl=$R_TITLE"

Thursday, March 27, 2014

Vim: Edit a file in the directory of the current file

:e %:p:h/filename
See also Set_working_directory_to_the_current_file.

Bullet lists autoformatting for text files in vim

In ~/.vim/after/ftplugin create a file text.vim containing
" Vim filetype plugin file
" Language: text
" Maintainer: Alexander Lobov 
" Last Change: 2014 Mar 27

" Only do this when not done yet for this buffer

if exists("b:did_ftplugin")
  finish
endif

" Don't load another plugin for this buffer
let b:did_ftplugin = 1

setlocal autoindent
setlocal formatoptions=tcroqln
The main strings are
setlocal autoindent
setlocal formatoptions=tcroqln
You .vimrc file should have
  filetype plugin indent on
line.