TextMate Vim Comment Banner

I am transitioning from TextMate to Vim for all text editing. However, one of the functions that I used a lot in TextMate was the banner-banner command ( ctr-shift-b ). He would create a banner and allow you to enter text inside the banner, and the banner would be adjusted to the length of the text. Are there any plugins in Vim or any similar function? If not, is there a way I can program vim to create a comment banner? Any suggestions would be great. Thanks!

enter image description here

+4
source share
2 answers

I am currently using Snipmate.vim https://github.com/msanders/snipmate.vim

Although I'm not quite sure that there is a snippet that will fit your specific need, it will be trivial to add one that will do it!

It has very simple scripting to add everything you need.

You will have to assign a fragment of a certain key combination, so when you are in this combination in the insert mode and you press Tab, the plugin will add all the things you need and also allow you to change the text that you previously typed.

So, for the example that you give, I would give it a combination that says “banner”. When I type this word and press Tab, I would put it in the “Comment Banner” so that I can print and replace the title.

There is a very good video on this site about how everything works: http://www.catonmat.net/blog/vim-plugins-snipmate-vim/

+5
source

I have these lines in my .vimrc :

 autocmd FileType vim map <leader>ccb I"<Del> <Esc>A "<Del><Esc>yyp0lv$hhr"yykPjj autocmd FileType javascript,php,c map <leader>ccb I// <Esc>A //<Esc>yyp0llv$hhhr-yykPjj autocmd FileType python,ruby,sh,zsh map <leader>ccb I# <Esc>A #<Esc>yyp0lv$hhr-yykPjj autocmd FileType css map <leader>ccb I/* <Esc>A */<Esc>yyp0llv$r-$hc$*/<Esc>yykPjj 

In .vimrc he turns this:

 vimrc banner 

in it:

 """""""""""""""""" " vimrc banner " """""""""""""""""" 

In the JS file, it looks like this:

 javascript banner 

in it:

 //---------------------// // javascript banner // //---------------------// 

Etc.

 " Creating underline/overline headings for markup languages " Inspired by http://sphinx.pocoo.org/rest.html#sections nnoremap <leader>== yyP^v$r=jyyp^v$r= nnoremap <leader>** yyP^v$r*jyyp^v$r* nnoremap <leader>= yyp^v$r= nnoremap <leader>- yyp^v$r- nnoremap <leader>^ yyp^v$r^ nnoremap <leader>" yyp^v$r" 

I would like for me to keep a link to where I found it.

+6
source

Source: https://habr.com/ru/post/1340893/


All Articles