Skip to content

Instantly share code, notes, and snippets.

@nelsonsar
Last active December 22, 2015 18:49
Show Gist options
  • Save nelsonsar/6515454 to your computer and use it in GitHub Desktop.
Save nelsonsar/6515454 to your computer and use it in GitHub Desktop.
Commenting a lot of code with Vim

This is how I comment a lot of code in Vim

    $convenio = formata_numero($dadosboleto["convenio"],6,0,"convenio");
    
    if ($dadosboleto["formatacao_nosso_numero"] == "1") {
        $nossonumero = formata_numero($dadosboleto["nosso_numero"],5,0);
        $dv = modulo_11("$codigobanco$nummoeda$fator_vencimento$valor$convenio$nossonumero$agencia$conta$carteira");
        $linha = "$codigobanco$nummoeda$dv$fator_vencimento$valor$convenio$nossonumero$agencia$conta$carteira";
        $nossonumero = $convenio . $nossonumero ."-". modulo_11($convenio.$nossonumero);
    }   
    
    if ($dadosboleto["formatacao_nosso_numero"] == "2") {
        $nservico = "21";
        $nossonumero = formata_numero($dadosboleto["nosso_numero"],17,0);
        $dv = modulo_11("$codigobanco$nummoeda$fator_vencimento$valor$convenio$nossonumero$nservico");
        $linha = "$codigobanco$nummoeda$dv$fator_vencimento$valor$convenio$nossonumero$nservico";
    }   

Go to the first line and press (this will make you enter into Vim visual block mode) and then you can just go down until you reach the number of lines that you want to comment. For this example let's make all this code right here, so let's press 15j. Finally, you can press c, put "//" and press Esc key to quit visual block mode. All this code is commented :D

Keystrokes in sequence: <Ctrl-v>15jc//<Esc>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment