Commenting Code Blocks Made Easy With Vim Commentary

Поделиться
HTML-код
  • Опубликовано: 12 сен 2024

Комментарии • 58

  • @BrodieRobertson
    @BrodieRobertson  4 года назад +1

    How do you like doing your commenting in vim, do you like using a plugin like vim commentary or nerdcommenter or maybe you prefer doing it the more traditional vim way with a regex let me know your thoughts down below.

    • @BryanJenks
      @BryanJenks 4 года назад +1

      i use tpopes plugin but i mapped Ctrl-C to gcc for 'Ctrl-COMMENT'

    • @BrodieRobertson
      @BrodieRobertson  4 года назад

      Makes sense

  • @niklas879
    @niklas879 4 года назад +4

    7:55 I actually really like this behavior. It allows you to have multiple layers of comments which is great for testing only some parts of the code.

    • @BrodieRobertson
      @BrodieRobertson  4 года назад

      Why do you need multiple layers to test different parts of the code?

    • @awabqureshi814
      @awabqureshi814 4 года назад +2

      @@BrodieRobertson useful if you have commented out code surrounded by other code and then you comment out that surrounding code
      This way you know what was already commented out before you commented out the surrounding code

  • @awabqureshi814
    @awabqureshi814 4 года назад +4

    If you're on st just set the keybinding in your vimrc by adding
    map / gcc

    • @BrodieRobertson
      @BrodieRobertson  4 года назад +1

      That's not ctrl-/ though, I know I could replace it but I like my binding

    • @awabqureshi814
      @awabqureshi814 4 года назад +2

      @@BrodieRobertson ¯\_(ツ)_/¯ I'm just more used to my leader key

  • @awabqureshi814
    @awabqureshi814 4 года назад +1

    I've been using this plugin for quite the while now, definitely the best commenter I've used. Does one thing; does it well.

  • @BABLA13579
    @BABLA13579 3 года назад +1

    I like this style of video. It is both a tutorial and a walkthrough.

  • @chrisatmachine
    @chrisatmachine 4 года назад +2

    Commentary is definitely the way to go. Quick tip if you’re using Nerd commenter. let g:NERDCreateDefaultMappings = 0

    • @BrodieRobertson
      @BrodieRobertson  4 года назад +1

      I must have missed that setting when I used it.

  • @danieldiaz855
    @danieldiaz855 4 года назад +2

    Really you deserve many more subs

    • @BrodieRobertson
      @BrodieRobertson  4 года назад

      Christmas is coming around soon and that's usually a big growth period for every channel

  • @salmanabedin1313
    @salmanabedin1313 4 года назад +1

    TPope is a legend!
    Just put everything he has made on your config.
    You need 'em all. lol.

    • @BrodieRobertson
      @BrodieRobertson  4 года назад +1

      He's made some weird stuff that I don't see the point of but he has some really awesome plugins for sure.

  • @AtomToast
    @AtomToast 4 года назад +2

    I find your explanation of the commands kind of confusing. It kind of felt like you didn't exactly understand the entirety of vims action and motion concept.
    Those commands in the readme were mainly just examples.
    gc is just an action. You can combine it with any kind of vim motion or text object. That's like the main difference compared to something like nerd commenter bc it follows vims ideas.
    ap is a text object for around paragraph, you can also use it with other actions like visually selecting with vap or deleting with dap. gcap is not a specific hardcoded command.
    gcc kind of is but again in a way that is consistent with other vim behaviour. It just works on the entire current line. Just like things like dd, yy, cc etc work.
    that's why it is so popular and powerful, it seamlessly integrates into the rest of vim, it could just as well be part of it by default

    • @BrodieRobertson
      @BrodieRobertson  4 года назад

      I get how it integrates but the github reads as if they are hard coded commands

  • @greyman1104
    @greyman1104 4 года назад +6

    Your videos are nice, but you should rethink your beard decisions.

    • @nilsemmenegger7770
      @nilsemmenegger7770 4 года назад +1

      Why the hell are there so many people against his beard? Is it some sort of inside joke or is it just needless harassment?

    • @doingitsidesways
      @doingitsidesways 4 года назад

      @@nilsemmenegger7770 i really don’t think saying someones beard looks wierd is harassment

    • @BrodieRobertson
      @BrodieRobertson  4 года назад +1

      I have no idea at this point

    • @greyman1104
      @greyman1104 4 года назад

      No harassment, just life advice.

    • @nilsemmenegger7770
      @nilsemmenegger7770 4 года назад

      ​@@doingitsidesways I guess so, it just seemed kind of odd that I kept seeing comments criticizing his beard ¯\_(ツ)_/¯

  • @Heffsta02
    @Heffsta02 2 года назад

    Honestly dude, I love that you just get to the point in your videos, it's so refreshing.

  • @Welteam
    @Welteam 4 года назад +1

    You did an entire video on comments without mentioning EOL comments?
    Is there a way to do End of Line comments with vim commentary?

    • @BrodieRobertson
      @BrodieRobertson  4 года назад

      I don't believe so but I also do not ever use EOL comments, they end up making lines run on longer than they should be.

  • @abdi_pie7266
    @abdi_pie7266 4 года назад

    thx dude It works

  • @Phantom-pj1ls
    @Phantom-pj1ls 3 года назад

    Nice video m8! Is there any way of commenting multiple lines with like /* */ ? every time I gcc several lines it adds one // per line. Thx!

  • @niklas879
    @niklas879 4 года назад +2

    10:00 Wouldn't it be better to put the keybinding in your vimrc since thats probably the only application you are using it in?

    • @BrodieRobertson
      @BrodieRobertson  4 года назад

      You can't bind ctrl-/in vim

    • @torbid
      @torbid 4 года назад +1

      @@BrodieRobertson should map CTRL+/, just tested it.

    • @michakozio7460
      @michakozio7460 4 года назад

      @@BrodieRobertson
      Check what keys terminal sends to you terminal apps with :
      in the shell : "sed -n l "
      in vim in insert mode press and then you key combination, vim will insert the key code into the buffer.
      as @torbid wrote it can be binded with inserting code with :
      nmap ^_ :echo "CTRL-/"
      PS : in bash inserting key codes also work with and then . In my terminal it insert ^_

    • @СвятославБезуглов
      @СвятославБезуглов 2 года назад

      First way
      1. Find in help page row 'keypad /' my is
      :help key-notation
      2. In init.vim or .vimrc write
      noremap :Commentary
      3. Try to comment in visual block
      Second way
      1. In command block type '/' and then CTRL+/ you would see something like that
      ^_
      2. The symbol after '^' is your slash interpretation, write in init.vim or .vimrc
      noremap :Commentary
      3. Try to comment in visual block

    • @СвятославБезуглов
      @СвятославБезуглов 2 года назад

      @@BrodieRobertson you are wrong, check my comment 😎

  • @vftdan
    @vftdan 4 года назад

    Many terminals treat keypress as character

  • @kowsirahmed5668
    @kowsirahmed5668 3 года назад

    Control + slash sends in vim.

  • @almasabdrazak5089
    @almasabdrazak5089 4 года назад +1

    Please use key logger so it would be easier to follow

    • @BrodieRobertson
      @BrodieRobertson  4 года назад

      I forgot to install screen key on this system

  • @zacharystreeter1965
    @zacharystreeter1965 4 года назад +2

    Had your netrw setup for a little bit and it was nice. I just switched to coc-explorer since I already use coc. Check it out, it integrates nerd-fonts and git info (a ton more too). I also just added this floating Lf implementation: github.com/haorenW1025/floatLf-nvim

    • @BrodieRobertson
      @BrodieRobertson  4 года назад

      I've been working on improving netrw lately. I'll have a look into it.

    • @chrisatmachine
      @chrisatmachine 4 года назад +1

      Nothing beats cox-explorer right now.

  • @SimGunther
    @SimGunther 4 года назад

    Plugins can't fix a scissor switch keyboard
    I use a Leopold Topre BTW

  • @TechToppers
    @TechToppers Год назад

    Does anyone have a way to set keybinding in kitty terminal emulator? I can't find a way for this! :crying_face:

  • @kyp0717
    @kyp0717 4 года назад

    Can you provide the code on how you map to Ctrl-/ to toggle comment? Thanks.

    • @BrodieRobertson
      @BrodieRobertson  4 года назад

      So in vim you can't actually map to ctrl-/ so what I've done is leave commenting mapped to gc in this plugin and then in my terminal I added a mapping on ctrl-/ to print out gc. I can't show you how because it depends on which terminal you're in if it's even possible

  • @abdi_pie7266
    @abdi_pie7266 4 года назад

    how about I want comment like this one?

    • @BrodieRobertson
      @BrodieRobertson  4 года назад

      I think that one might be a bit too complex for this sadly.

  • @SayanChakraborty10397
    @SayanChakraborty10397 4 года назад

    Sorry, I'm new to vim. Can anyone tell me how to map "gc" to ctrl+/ ?
    I am pretty much used to vscode, and this would really help me out.

    • @BrodieRobertson
      @BrodieRobertson  4 года назад +1

      You actually can't do that directly in vim, I've had to do the mapping in my terminal instead

    • @SayanChakraborty10397
      @SayanChakraborty10397 4 года назад

      @@BrodieRobertson Oh. Ok. Thanks for letting me know. Actually I'm using the default gnome-terminal. I'll try and see if it works in any way within it. Otherwise will try downloading any other terminal applications.

  • @fighiblue5673
    @fighiblue5673 4 года назад

    What do you think of spacevim?

    • @BrodieRobertson
      @BrodieRobertson  4 года назад

      Tried it and it's cool if you're starting from scratch but it adds so much stuff I don't care about.

  • @kimnejudne
    @kimnejudne 4 года назад

    Visual mode to comment? No.

  • @sk8sbest
    @sk8sbest 4 года назад +1

    First