Quellcode durchsuchen

Merge pull request #37 from ghmhd/@ghmhd/feature/add-multiline-comment-support

Add multi line comment
Christian Chiarulli vor 5 Jahren
Ursprung
Commit
337e7b55c8
3 geänderte Dateien mit 13 neuen und 2 gelöschten Zeilen
  1. 2 1
      init.vim
  2. 1 1
      keys/which-key.vim
  3. 10 0
      plug-config/vim-commentary.vim

+ 2 - 1
init.vim

@@ -24,7 +24,8 @@ else
   source $HOME/.config/nvim/themes/airline.vim
   source $HOME/.config/nvim/plug-config/rnvimr.vim
   source $HOME/.config/nvim/plug-config/fzf.vim
-  source $HOME/.config/nvim/plug-config/nerd-commenter.vim
+  "source $HOME/.config/nvim/plug-config/nerd-commenter.vim switching to vim-commentary
+  source $HOME/.config/nvim/plug-config/vim-commentary.vim
   source $HOME/.config/nvim/plug-config/rainbow.vim
   source $HOME/.config/nvim/plug-config/codi.vim
   source $HOME/.config/nvim/plug-config/quickscope.vim

+ 1 - 1
keys/which-key.vim

@@ -25,7 +25,7 @@ autocmd  FileType which_key set laststatus=0 noshowmode noruler
 
 
 " Single mappings
-let g:which_key_map['/'] = [ ':Commentary'  , 'comment' ]
+let g:which_key_map['/'] = [ ':call Comment()'  , 'comment' ]
 let g:which_key_map['.'] = [ ':e $MYVIMRC'                , 'open init' ]
 let g:which_key_map[';'] = [ ':Commands'                  , 'commands' ]
 let g:which_key_map['='] = [ '<C-W>='                     , 'balance windows' ]

+ 10 - 0
plug-config/vim-commentary.vim

@@ -0,0 +1,10 @@
+" this function check whether vim is in normal mode or not and comment appropriately
+function! Comment()
+  if (mode() == "n" )
+    execute "Commentary"
+  else    
+    execute "'<,'>Commentary"
+  endif
+ endfunction
+vnoremap <silent> <space>/ :call Comment()  
+autocmd filetype javascript.jsx setlocal commentstring={/*\ %s\ */}