Skip to content

Instantly share code, notes, and snippets.

@jeffmccune
Created February 23, 2011 02:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffmccune/839899 to your computer and use it in GitHub Desktop.
Save jeffmccune/839899 to your computer and use it in GitHub Desktop.
In your Vim RC
" ~/.vim/ftplugin/puppet.vim
"
" Requires Align VIM plugin:
" http://mysite.verizon.net/astronaut/vim/align.html
" With a visual block selected, align =>'s
vmap . :Align =><CR>
" Function to save cursor position, select the block, and align =>'s
function! AlignFats()
let save_cursor = getpos(".")
call SelectIndent()
exe "norm ."
call setpos('.', save_cursor)
endfun
" Bind the comma to align all fats in the current resource.
noremap , :call AlignFats()<CR>
" The goal here is to select the current block with space,
" and align everything with the dot key.
" ~/.vimrc
" Visually select current indent level and greater.
" http://vim.wikia.com/wiki/VimTip1014
" Bind the function to the spacebar
function! SelectIndent ()
let temp_var=indent(line("."))
while indent(line(".")-1) >= temp_var
exe "normal k"
endwhile
exe "normal V"
while indent(line(".")+1) >= temp_var
exe "normal j"
endwhile
endfun
" Map space to visual-block-line select the current indent level
nmap <Space> :call SelectIndent()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment