2010-03-08 26 views
7
/* Suppose I have a multi-line comment with hard line-breaks 
* that are roughly uniform on the right side of the text, 
* and I want to add text to a line in order to make the 
* comment a bit more descriptive. 
*/ 

Ora, la maggior parte purtroppo, ho bisogno di aggiungere del testo a una delle migliori linee.Esistono strumenti in IDE per correggere automaticamente la formattazione dei commenti?

/* Suppose I have a multi-line comment with hard line-breaks (here is some added text for happy fun time) 
* that are roughly uniform on the right side of the text, 
* and I want to add text to a line in order to make the 
* comment a bit more descriptive. 
*/ 

Prende O (n) tempo (n essendo il numero di righe) per fissare ciascuna riga in modo che approssimativamente allineano nuovamente. Il computer dovrebbe fare questo, non io.

Esistono strumenti per gestire questo nei nostri IDE? Come si chiamano?

+0

Polystyle non lo fa ancora, ma potrebbe valerne la pena, è promesso per una delle versioni future: http://www.polystyle.com/index.jsp –

risposta

4

emacs supporta il comando fill-paragraph che in genere è mappato su meta-q.

uscita dal fill-paragraph sul secondo paragrafo del testo:

/* Suppose I have a multi-line comment with hard line-breaks (here is 
* some added text for happy fun time) that are roughly uniform on the 
* right side of the text, and I want to add text to a line in order 
* to make the comment a bit more descriptive. 
*/ 
+0

Sfortunatamente non uso emacs, ma sembra che questo sia l'unico editor che supporta questo genere di cose. – Fragsworth

+0

Per la maggior parte del mio sviluppo java, utilizzo IntelliJ. Tuttavia, continuo a estrarre emacs per svolgere alcune attività a cui emacs è veramente bravo. –

2

Eclipse ha costruito in questo (almeno, credo che sia quello che vuoi). Quando si digita un commento, si digita Ctrl + Maiusc + F e verrà formattato tutto il codice o solo la sezione di codice che è stata evidenziata.

L'ho appena testato e ha allineato tutti i miei commenti per me.

+0

Penso che stia cercando la soluzione per cambiare anche la lunghezza della linea piuttosto che allinearli in modo che siano per lo più allineati a destra e allineati precisamente a sinistra. –

+0

@Jacob G - Ah, non l'ho capito. Buona chiamata (Sembra che anche Peter abbia seguito lo stesso processo di pensiero che ho fatto.) – JasCav

Problemi correlati