Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim customization -- .vimrc -- mapping of keys

Tags:

vim

Vim customization --

I have added these lines in my .vimrc

inoremap /* /**/< Left >

  1. what i intend is, when in press open comments /* -- it should automically print the closing comment.
  2. when in comments, what do i add to .vimrc, so that when in comments block at each enter, an "*" is printed at the next line.

    / *

      • /

if i have to add some lines automatically at top of each file i create (in a particular folder) eg - like licenses headers. how to do that. -- i can think of, making a template file, doing a cp temp.c abc.c and then vi abc.c. is there any other way.

like image 944
Vivek Sharma Avatar asked Nov 21 '25 08:11

Vivek Sharma


1 Answers

Use this.

inoremap <buffer> /*          /**/<Left><Left>
inoremap <buffer> /*<Space>   /*<Space><Space>*/<Left><Left><Left>
inoremap <buffer> /*<CR>      /*<CR>*/<Esc>O
inoremap <buffer> <Leader>/*  /*
like image 184
Artem Barger Avatar answered Nov 24 '25 06:11

Artem Barger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!