aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vim.dot.link/filetype.vim8
-rw-r--r--vim.dot.link/plugin/auto_file.vim9
-rw-r--r--vim.dot.link/plugin/key_mappings.vim38
-rw-r--r--vim.dot.link/plugin/session_workarounds.vim15
4 files changed, 53 insertions, 17 deletions
diff --git a/vim.dot.link/filetype.vim b/vim.dot.link/filetype.vim
index 5513aa1..f3c90bb 100644
--- a/vim.dot.link/filetype.vim
+++ b/vim.dot.link/filetype.vim
@@ -4,6 +4,12 @@ if exists("did_load_filetypes")
finish
endif
+" VIM filetype
+augroup filetype_vim
+ autocmd!
+ autocmd FileType vim setlocal foldmethod=marker
+augroup END
+
" Filetype detection
"
" According to ":help BufRead", this augroup is also evaluated also on
@@ -26,7 +32,7 @@ augroup END
" Drupal *.module and *.install files.
if has("autocmd")
- augroup module
+ augroup filetype_drupal
autocmd!
autocmd BufRead,BufNewFile *.profile setfiletype php
autocmd BufRead,BufNewFile *.module setfiletype php
diff --git a/vim.dot.link/plugin/auto_file.vim b/vim.dot.link/plugin/auto_file.vim
index dc19ad3..72e782f 100644
--- a/vim.dot.link/plugin/auto_file.vim
+++ b/vim.dot.link/plugin/auto_file.vim
@@ -1,18 +1,20 @@
" auto_file.vim - Automatically file reading, saving; directory changer.
-" Autoread
+" Autoread {{{
"
" http://vim.wikia.com/wiki/Have_Vim_check_automatically_if_the_file_has_changed_externally
" http://stackoverflow.com/questions/2490227/how-does-vims-autoread-work
" http://stackoverflow.com/questions/2490227/how-does-vims-autoread-work
"au FocusGained,BufEnter * :silent! !
"au FocusLost,WinLeave * :silent! w
+" }}}
-" Autosave
+" Autosave {{{
" See https://github.com/vim-scripts/vim-auto-save
"let g:auto_save = 1
+" }}}
-" Auto change dir
+" Auto change dir {{{
"
" Automatically set the current working directory to the current buffer file's
" directory
@@ -23,3 +25,4 @@ augroup changedir
autocmd!
autocmd BufEnter * silent! lcd %:p:h
augroup END
+" }}}
diff --git a/vim.dot.link/plugin/key_mappings.vim b/vim.dot.link/plugin/key_mappings.vim
index 026f503..2b0f2e7 100644
--- a/vim.dot.link/plugin/key_mappings.vim
+++ b/vim.dot.link/plugin/key_mappings.vim
@@ -41,10 +41,14 @@
"
" The sollution is to decrease ESC timeout.
"
+
+" Decrease ESC delays {{{
" See https://www.johnhawthorn.com/2012/09/vi-escape-delays/
"set timeoutlen=1000 ttimeoutlen=0
set timeoutlen=0 ttimeoutlen=0
+" }}}
+" ESC-based shortcuts {{{
" Write, quit and close shortcuts using Esc <key> notation (works also with <Alt-key>)
nnoremap <ESC>n :tabnew<CR>
nnoremap <ESC>t :NERDTree
@@ -74,7 +78,9 @@ inoremap <ESC>c <ESC>:tabclose<CR>
" We're closing the buffer instead of just the window to avoid slowness due to too many opened buffers
inoremap <ESC>m <ESC>:bd<CR>
inoremap <ESC>w <ESC>:w<CR>
+" }}}
+" Alt-based shortcuts {{{
" Write, quit and close shortcuts using Alt-key combo notation
"noremap n :tabnew<CR>
"noremap t :OpenNERDTree<CR>
@@ -98,7 +104,9 @@ inoremap <ESC>w <ESC>:w<CR>
"inoremap e <ESC>:tabclose<CR>
"inoremap m <ESC>:q!<CR>
"inoremap w <ESC>:w<CR>
+" }}}
+" Crtl-based shortcuts {{{
" Write, quit and close shortcuts using Ctrl-key combos
" We're using these due to a conflict with wyrd(1)
"nnoremap <C-n> :tabnew<CR>
@@ -122,16 +130,18 @@ inoremap <ESC>w <ESC>:w<CR>
"inoremap <C-e> <ESC>:tabclose<CR>
"inoremap <C-m> <ESC>:q!<CR>
"inoremap <C-w> <ESC>:w<CR>
+" }}}
-" Write, quit and close shortcuts
+" Write, quit and close shortcuts {{{
noremap q :Wipeout<CR>:wqa <CR>
"noremap f :wq <CR>
"noremap t :tabclose <CR>
"noremap m :q! <CR>
"noremap w :w <CR>
noremap h :tabnew<CR>
+" }}}
-" Tab navigation
+" Tab navigation {{{
" See http://vim.wikia.com/wiki/Alternative_tab_navigation
" http://comments.gmane.org/gmane.os.cygwin.xfree/16419
nnoremap <ESC>[5^ <C-PageUp>
@@ -148,12 +158,14 @@ nnoremap 7 7gt
nnoremap 8 8gt
nnoremap 9 9gt
nnoremap 0 10gt
+" }}}
-" Buffer navigation: Alt-{Up,Down}
+" Buffer navigation: Alt-{Up,Down} {{{
noremap Od :bprevious<CR>
noremap Oc :bnext<CR>
+" }}}
-" Window navigation
+" Window navigation {{{
"noremap <C-Left> <C-w><Left>
"noremap <C-Right> <C-w><Right>
"noremap <C-Down> <C-w><Down>
@@ -178,21 +190,29 @@ inoremap <ESC><Left> <ESC><C-w><Left>
inoremap <ESC><Right> <ESC><C-w><Right>
inoremap <ESC><Down> <ESC><C-w><Down>
inoremap <ESC><Up> <ESC><C-w><Up>
+" }}}
-" Recording
+" Recording {{{
nnoremap Q q
+" }}}
+" Copy and paste {{{
+"
" See http://superuser.com/questions/10588/how-to-make-cut-copy-paste-in-gvim-on-ubuntu-work-with-ctrlx-ctrlc-ctrlv
"imap <C-v> <C-r><C-o>+
"vmap <C-v> c<ESC>"+p
vnoremap <C-c> "+yi
vnoremap <C-x> "+c
+" }}}
-" For email: unfold and delete to your signature
+" Email {{{
+"
+" Unfold and delete to your signature
" See https://hroy.eu/tips/vim/email-delete-til-signature/
noremap ,dd zi:.;/^-- $/d<CR>O-- <UP><End><CR><CR><UP><CR><C-O>zi
+" }}}
-" Simple TODO lists
+" Task lists {{{
" https://github.com/vitalk/vim-simple-todo/
let g:simple_todo_map_keys = 0
let g:simple_todo_list_symbol = '*'
@@ -215,11 +235,13 @@ vmap <Leader>s <Plug>(simple-todo-mark-switch)
" From lib.vim
"nnoremap <Leader>c :call ToggleCheckbox()<CR>
+" }}}
-" Insert the current date in ISO format
+" Insert the current date in ISO format {{{
"
" Thanks https://vimtricks.com/p/insert-the-current-date-or-time/
"map <leader>d :0put =strftime('%Y-%m-%d')<CR>
nnoremap <leader>d i<C-R>=strftime('%Y-%m-%d')<CR>
inoremap <leader>d <C-R>=strftime('%Y-%m-%d')<CR>
map <leader>e :put =strftime('## %Y-%m-%d')<CR>
+" }}}
diff --git a/vim.dot.link/plugin/session_workarounds.vim b/vim.dot.link/plugin/session_workarounds.vim
index 3b43b5b..31dec9f 100644
--- a/vim.dot.link/plugin/session_workarounds.vim
+++ b/vim.dot.link/plugin/session_workarounds.vim
@@ -3,7 +3,7 @@
" Author: Silvio Rhatto <rhatto@riseup.net>
"
-" Fix NERDTree width
+" Fix NERDTree width {{{
"
" Useful after restoring sessions between screen size changes (such
" as when you share sessions between different computers).
@@ -20,8 +20,9 @@ endfunction
" In case you want to invoke FixWindowWidths explicitly
command! -bang FixWindowWidths :call FixWindowWidths()
+" }}}
-" Fix window widths on all tabs
+" Fix window widths on all tabs {{{
function FixAllWindowWidths()
" Make sure to run this only once
if exists("did_fixed_window_widths")
@@ -41,8 +42,9 @@ function FixAllWindowWidths()
let did_fixed_window_widths=1
endfunction
+" }}}
-" Ensure the window has maximized height
+" Ensure the window has maximized height {{{
"
" This helps restoring the window size after reopening sessions after
" switching monitors (like from laptop screen to external HDMI monitor).
@@ -78,14 +80,16 @@ function FixWindowHeights()
" execute ':set lines=' . winheight(0) - 3
endif
endfunction
+" }}}
-" Restore all window sizes
+" Restore all window sizes {{{
function RestoreWindowSizes()
call FixWindowHeights()
call FixAllWindowWidths()
endfunction
+" }}}
-" Fix all window sizes
+" Fix all window sizes {{{
augroup workaround
autocmd!
" This tends to fire for every buffer
@@ -95,3 +99,4 @@ augroup workaround
" restored.
"autocmd workaround VimEnter * call FixAllWindowWidths()
augroup END
+" }}}