User Tools

Site Tools



Miscelanous tips and tricks for my famous Vim text editor.

Save current workspaces

:mksession [FILE]

Recover never saved file

Use this in the directory where you was at the time of crash (for Windows gVim):

:recover _.swp

Adding a modeline

With the following in your vimrc and the default leader key, you could type \ml to add a modeline based on your current settings:

" Append modeline after last line in buffer.
" Use substitute() instead of printf() to handle '%%s' modeline in LaTeX
" files.
function! AppendModeline()
  let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d enc=%s:",
        \ &tabstop, &shiftwidth, &textwidth, &encoding)
  let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
  call append(line("$"), l:modeline)
nnoremap <silent> <Leader>ml :call AppendModeline()<CR>

Useful plugins

unix/vim.txt · Last modified: 2015/08/10 18:31 by bajeluk