From bd30daefeaf23b206ab778e8123c8a08d524ccc8 Mon Sep 17 00:00:00 2001 From: Gharbi Mohamed Date: Wed, 15 Jul 2020 02:59:35 +0100 Subject: add a config file for vim commentary --- plug-config/vim-commentary.vim | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 plug-config/vim-commentary.vim diff --git a/plug-config/vim-commentary.vim b/plug-config/vim-commentary.vim new file mode 100644 index 00000000..c9637e69 --- /dev/null +++ b/plug-config/vim-commentary.vim @@ -0,0 +1,9 @@ +function! Comment() + if (mode() == "n" ) + execute "Commentary" + else + execute "'<,'>Commentary" + endif + endfunction +vnoremap / :call Comment() +autocmd filetype javascript.jsx setlocal commentstring={/*\ %s\ */} -- cgit v1.2.3 From f3ba68b3cc03cbd07b5145c62b885db5a1ba0177 Mon Sep 17 00:00:00 2001 From: Gharbi Mohamed Date: Wed, 15 Jul 2020 03:03:47 +0100 Subject: create a function to handle multi line comment --- plug-config/vim-commentary.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plug-config/vim-commentary.vim b/plug-config/vim-commentary.vim index c9637e69..f672715d 100644 --- a/plug-config/vim-commentary.vim +++ b/plug-config/vim-commentary.vim @@ -1,3 +1,4 @@ +" this function check whether vim is in normal mode or not and comment appropriately function! Comment() if (mode() == "n" ) execute "Commentary" @@ -5,5 +6,5 @@ function! Comment() execute "'<,'>Commentary" endif endfunction -vnoremap / :call Comment() +vnoremap / :call Comment() autocmd filetype javascript.jsx setlocal commentstring={/*\ %s\ */} -- cgit v1.2.3 From 82286eca1918daea625fd40e12f2d4c43b70a9ee Mon Sep 17 00:00:00 2001 From: Gharbi Mohamed Date: Wed, 15 Jul 2020 03:05:11 +0100 Subject: modify '/' mapping to call the Comment function --- keys/which-key.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keys/which-key.vim b/keys/which-key.vim index 661882c1..cc0c41a2 100644 --- a/keys/which-key.vim +++ b/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['='] = [ '=' , 'balance windows' ] -- cgit v1.2.3 From 51d9b8841d45992d7d0e66d51844f50ac428541a Mon Sep 17 00:00:00 2001 From: Gharbi Mohamed Date: Wed, 15 Jul 2020 03:05:56 +0100 Subject: comment out nerd-comment config and add vim-commentary config file --- init.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init.vim b/init.vim index c6456734..8205e455 100644 --- a/init.vim +++ b/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 -- cgit v1.2.3