Portál AbcLinuxu, 1. května 2025 18:55
Po jednej medzere som odsadzoval zhruba tak 3 roky dozadu (a ďalších ~6 predtým) všetky moje pascalovské výtvory. Zdalo sa mi to tak prehľadnejšie. Lenže potom som prešiel na C, vim, prečítal pár návodov/odporúčaní, a zistil, že ten tabulátor má predsa len čosi do seba.
...není vůbec žádný problém napsat jednoduchý prográmek, který...
man indent
fce_call( prom1, prom2, prom3, prom4, prom5 );
a = sin(q)*(x*x + y*y); b = function_foo(x - bar(y), z);A mají-li se pro odsazení, které neodpovídá nestingu, používat mezery, tak se mohou klidně používat pro všechna odsazení.
indent
je váš kamarád.
main() { printf('this is output'); //< my output int a = 1 + 2; //< my count }po preklopení na tabstop=8 bude nasledovný:
main() { printf('this is output'); //< my output int a = 1 + 2; //< my count }ak však odsadenie v rámci kódu zameníme za medzery, tak pôvodný indent s tabstop=4 bude pôvodný:
main() { printf('this is output'); //< my output int a = 1 + 2; //< my count }a po jeho zväčšení sa zmení iba odsadenie blokov a medzery medzi kódom ostanú rovnaké:
main() { printf('this is output'); //< my output int a = 1 + 2; //< my count }K spomenutej funkcionalite som spravil malý plugin do vim-ka pre verziu 7.0 a vyššiu, sťahovať môžete na CleverTabs
TAB runs `cperl-indent-command' `cperl-indent-command' is an interactive compiled Lisp function -- loaded from "cperl-mode" (cperl-indent-command &optional WHOLE-EXP) Documentation: Indent current line as Perl code, or in some cases insert a tab character. If `cperl-tab-always-indent' is non-nil (the default), always indent current line. Otherwise, indent the current line only if point is at the left margin or in the line's indentation; otherwise insert a tab. A numeric argument, regardless of its value, means indent rigidly all the lines of the expression starting after point so that this line becomes properly indented. The relative indentation among the lines of the expression are preserved.odkedy som zacal pouzivat emacs, nemam s odsadzovanim ziadne problemy ... stlacim tabelator a odsadi ma presne tam kde chcem (ci su to 4 alebo 40 medzier ...)
man indent
man indent
.
$ sudo apt-get install indent ... $ man indentchjo. chjo.
sudo: atp-get: command not foundto bude asi tim, ze tam mam SUSE....
atp-get
vyvola stiznost shellu na neznamy prikaz...
To bezmyšlenkovitě opisujete z coding style linuxového jádra nebo si to opravdu myslíte?
trochu mi v ankete schazi jak tabulatory, tak mezery, protoze ja pisu asi takto:
void main()
{
int i=3;
if (i!=3)
{
cout>>"mne neuvidis, protoze nemuzu nastat";
}
else
{
cout>>"i je 3";
}
neco=nic;
atd....
return 0;
}
velke mezery v prikladu delam pomoci tabulatoru a mensi odsazeni pomoci jedne, maximalne dvou mezer
void main() ... return 0;- sem jedinej, komu tady neco nesedi ????
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.