Commits

Gabriel AHTUNE committed 337e964

Change on the home button

Comments (0)

Files changed (1)

plugin/supernormal.vim

 "          In visual mode: <Tab> indents, and <S-Tab> un-indent.
 "          In normal mode: switch the window (<S-Tab> to switch in reverse 
 "          order).
-" Home  -> Goto first non word character if the cursor is after the first 
+" Home  -> Goto first word character if the cursor is after the first 
 "          non word character (useful in indented comment).
 "          Goto the first non blank character if the cursor is after the first
 "          non blank character and before the first word
 "          otherwise goto the beginning of the line.
 "          when already at the begining of the line, goto the first non blank
 "          character.
+"          In Explorer Goto home folder
 " Back  -> pop one tags, and in explorer up one directory
 " Enter -> Follow links in help buffer
 "          In visual mode delete selection and insert a new line
 
 if !exists("g:SuperNormalDeactivateHomeMapping")
     function! GotoFirstWord()
+        let commentchar = substitute(&commentstring,'\S\zs%s','','')
         let save_search = @/
         norm! 0
-        let @/='^\%'.line('.').'l\W*\zs\w*'
+        let @/='^\%'.line('.').'l\s*['.commentchar.'*-]*\s*\zs\w*'
         silent exec "keepjump norm! n"
         silent exec "nohl"
         let @/ = save_search
     endfunction
 
     function! SuperHome()
+        let commentchar = substitute(&commentstring,'\S\zs%s','','')
         let startofline = strpart(getline('.'), 0, col('.') - 1)
         if (startofline =~'^\s*$') && col('.') != 1
             norm! 0
-        elseif startofline =~ '^\W*$' && col('.') != 1
+        elseif startofline =~ '^\s*['.commentchar.'*-]*\s*$' && col('.') != 1
             norm! ^
         else
             call GotoFirstWord()
     nnoremap <silent> <Home> :call SuperHome()<CR>
     inoremap <silent> <Home> <C-O>:call SuperHomeInInsert()<CR>
     vnoremap <silent> <Home> om`o<ESC>:call SuperHome()<CR>v``o
+
+    autocmd FileType netrw nmap <buffer> <Home> :Ex ~
 endif
 
 " -----------------------------------------------------------------------------