From b6a77530871c56ffc5d05b510f7eac8774fbc7ec Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 28 Jul 2024 20:31:25 -0300 Subject: Feat: folding markers --- vim.dot.link/filetype.vim | 8 +++++- vim.dot.link/plugin/auto_file.vim | 9 ++++--- vim.dot.link/plugin/key_mappings.vim | 38 +++++++++++++++++++++++------ vim.dot.link/plugin/session_workarounds.vim | 15 ++++++++---- 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 notation (works also with ) nnoremap n :tabnew nnoremap t :NERDTree @@ -74,7 +78,9 @@ inoremap c :tabclose " We're closing the buffer instead of just the window to avoid slowness due to too many opened buffers inoremap m :bd inoremap w :w +" }}} +" Alt-based shortcuts {{{ " Write, quit and close shortcuts using Alt-key combo notation "noremap n :tabnew "noremap t :OpenNERDTree @@ -98,7 +104,9 @@ inoremap w :w "inoremap e :tabclose "inoremap m :q! "inoremap w :w +" }}} +" Crtl-based shortcuts {{{ " Write, quit and close shortcuts using Ctrl-key combos " We're using these due to a conflict with wyrd(1) "nnoremap :tabnew @@ -122,16 +130,18 @@ inoremap w :w "inoremap :tabclose "inoremap :q! "inoremap :w +" }}} -" Write, quit and close shortcuts +" Write, quit and close shortcuts {{{ noremap q :Wipeout:wqa "noremap f :wq "noremap t :tabclose "noremap m :q! "noremap w :w noremap h :tabnew +" }}} -" Tab navigation +" Tab navigation {{{ " See http://vim.wikia.com/wiki/Alternative_tab_navigation " http://comments.gmane.org/gmane.os.cygwin.xfree/16419 nnoremap [5^ @@ -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 noremap Oc :bnext +" }}} -" Window navigation +" Window navigation {{{ "noremap "noremap "noremap @@ -178,21 +190,29 @@ inoremap inoremap inoremap inoremap +" }}} -" 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 + "vmap c"+p vnoremap "+yi vnoremap "+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:.;/^-- $/dO-- 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 s (simple-todo-mark-switch) " From lib.vim "nnoremap c :call ToggleCheckbox() +" }}} -" 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 d :0put =strftime('%Y-%m-%d') nnoremap d i=strftime('%Y-%m-%d') inoremap d =strftime('%Y-%m-%d') map e :put =strftime('## %Y-%m-%d') +" }}} 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 " -" 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 +" }}} -- cgit v1.2.3