* Substiotution of tabs with spaces... @ 2005-04-15 9:06 luca.spinacci 2005-04-15 11:10 ` Peter Dyballa [not found] ` <mailman.1631.1113563465.2895.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 14+ messages in thread From: luca.spinacci @ 2005-04-15 9:06 UTC (permalink / raw) Hi, is there a smart way to replace all tabs with 3 spaces in a buffer edited in c-mode (both comments and code lines) Thank you very much. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Substiotution of tabs with spaces... 2005-04-15 9:06 Substiotution of tabs with spaces luca.spinacci @ 2005-04-15 11:10 ` Peter Dyballa [not found] ` <mailman.1631.1113563465.2895.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 14+ messages in thread From: Peter Dyballa @ 2005-04-15 11:10 UTC (permalink / raw) Cc: help-gnu-emacs Am 15.04.2005 um 11:06 schrieb luca.spinacci@seleniacomms.com: > is there a smart way to replace all tabs with 3 spaces in a buffer > edited > How about: replace-regexp RET TAB + RET SPC SPC SPC RET ? Or: replace-string RET TAB RET SPC SPC SPC RET ? -- Greetings Pete Got Mole problems? Call Avogadro 6.02 x 10^23 ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <mailman.1631.1113563465.2895.help-gnu-emacs@gnu.org>]
* Re: Substiotution of tabs with spaces... [not found] ` <mailman.1631.1113563465.2895.help-gnu-emacs@gnu.org> @ 2005-04-15 13:15 ` Pascal Bourguignon 2005-04-15 22:49 ` Peter Dyballa [not found] ` <mailman.1690.1113606252.2895.help-gnu-emacs@gnu.org> 2005-04-18 0:03 ` Quokka 1 sibling, 2 replies; 14+ messages in thread From: Pascal Bourguignon @ 2005-04-15 13:15 UTC (permalink / raw) Peter Dyballa <Peter_Dyballa@Web.DE> writes: > Am 15.04.2005 um 11:06 schrieb luca.spinacci@seleniacomms.com: > > > is there a smart way to replace all tabs with 3 spaces in a buffer > > edited > > > > How about: replace-regexp RET TAB + RET SPC SPC SPC RET ? > Or: replace-string RET TAB RET SPC SPC SPC RET ? It's not satisfactory. For example, try it on: (progn (find-file "/tmp/exemple") (erase-buffer) (insert "\n\ta\ta\n\taa\taa\n\taaa\taaa\n")) Also, with my emacs configuration, M-x replace-string RET TAB tries to substitute a string of four spaces, not one tabulation. Try: M-x replace-regexp RET C-q TAB + RET SPC SPC SPC RET M-x replace-string RET C-q TAB RET SPC SPC SPC RET -- __Pascal Bourguignon__ http://www.informatimago.com/ You never feed me. Perhaps I'll sleep on your face. That will sure show you. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Substiotution of tabs with spaces... 2005-04-15 13:15 ` Pascal Bourguignon @ 2005-04-15 22:49 ` Peter Dyballa [not found] ` <mailman.1690.1113606252.2895.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 14+ messages in thread From: Peter Dyballa @ 2005-04-15 22:49 UTC (permalink / raw) Am 15.04.2005 um 15:15 schrieb Pascal Bourguignon: > Also, with my emacs configuration, > M-x replace-string RET TAB > tries to substitute a string of four spaces, not one tabulation. > > Try: > > M-x replace-regexp RET C-q TAB + RET SPC SPC SPC RET > M-x replace-string RET C-q TAB RET SPC SPC SPC RET > Yes, that's something I've seen here too. I remember that I failed a few times to remove, i.e. replace-regexp with nothing, [SPC TAB]+$ -- there could be a better regexp too. Do have an idea why TAB is sometimes \t and sometimes a few spaces? -- Greetings Pete ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <mailman.1690.1113606252.2895.help-gnu-emacs@gnu.org>]
* Re: Substiotution of tabs with spaces... [not found] ` <mailman.1690.1113606252.2895.help-gnu-emacs@gnu.org> @ 2005-04-15 23:38 ` Pascal Bourguignon 2005-04-17 21:42 ` Peter Dyballa 2005-04-16 4:16 ` Stefan Monnier 1 sibling, 1 reply; 14+ messages in thread From: Pascal Bourguignon @ 2005-04-15 23:38 UTC (permalink / raw) Peter Dyballa <Peter_Dyballa@Web.DE> writes: > Am 15.04.2005 um 15:15 schrieb Pascal Bourguignon: > > > Also, with my emacs configuration, > > M-x replace-string RET TAB > > tries to substitute a string of four spaces, not one tabulation. > > > > Try: > > > > M-x replace-regexp RET C-q TAB + RET SPC SPC SPC RET > > M-x replace-string RET C-q TAB RET SPC SPC SPC RET > > > > Yes, that's something I've seen here too. I remember that I failed a > few times to remove, i.e. replace-regexp with nothing, [SPC TAB]+$ > -- there could be a better regexp too. Do have an idea why TAB is > sometimes \t and sometimes a few spaces? TAB is TAB, and SPC is SPC. What happens, is that TAB is a CONTROL character that was used to CONTROL a mecanical teletype device, to make it move mecanically the carriage to the next tabulation stop. Since its meaning depends highly on the device (the width of the tabulation changes, on some devices there's no tabulation, so it doesn't show at all or is replaced by one space), and you cannot SEE whether there is one TAB or several SPC, it should not be used in normal files. Use instead only SPC and sequences of SPC. That's why in emacs, we usually bind the TAB key to more interesting functions, such as lisp-indent-line or c-ident-command, and these command indent the current line according to the syntax (using normaly only spaces). This has the added benefit that when you visualise the file in a different environment, it always display correctly indented. You should have: (setq tab-always-indent t) in your ~/.emacs ! -- __Pascal Bourguignon__ http://www.informatimago.com/ Nobody can fix the economy. Nobody can be trusted with their finger on the button. Nobody's perfect. VOTE FOR NOBODY. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Substiotution of tabs with spaces... 2005-04-15 23:38 ` Pascal Bourguignon @ 2005-04-17 21:42 ` Peter Dyballa 0 siblings, 0 replies; 14+ messages in thread From: Peter Dyballa @ 2005-04-17 21:42 UTC (permalink / raw) Am 16.04.2005 um 01:38 schrieb Pascal Bourguignon: > You should have: > (setq tab-always-indent t) > in your ~/.emacs ! > I think that's the default value. In GNU Emacs 22.0.50 and 21.3.50 it is t although I never set it. -- Greetings Pete -- Mit friedvollen Grüßen Pete Macht kaputt, was Afghanistan kaputt macht! ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Substiotution of tabs with spaces... [not found] ` <mailman.1690.1113606252.2895.help-gnu-emacs@gnu.org> 2005-04-15 23:38 ` Pascal Bourguignon @ 2005-04-16 4:16 ` Stefan Monnier 2005-04-17 20:05 ` Steinar Børmer 1 sibling, 1 reply; 14+ messages in thread From: Stefan Monnier @ 2005-04-16 4:16 UTC (permalink / raw) > Do have an idea why TAB is sometimes \t and sometimes a few spaces? This makes no sense. TAB is TAB and nothing more. What you probably mean is that the TAB *key* is bound to a command that doesn't always insert just a TAB character or just spaces, but sometimes one, sometimes the other, and sometimes something yet different. Look for Kai's tutorial on TAB and other key bindings. Stefan ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Substiotution of tabs with spaces... 2005-04-16 4:16 ` Stefan Monnier @ 2005-04-17 20:05 ` Steinar Børmer 2005-04-17 21:18 ` Peter Dyballa ` (2 more replies) 0 siblings, 3 replies; 14+ messages in thread From: Steinar Børmer @ 2005-04-17 20:05 UTC (permalink / raw) Stefan Monnier wrote: | Look for Kai's tutorial on TAB and other key bindings. These can be hard to find, as most of the links I've come across are dead. (Kai, are you reading this?) However, I was able to locate them on the XEmacs web site: <URL: http://www.xemacs.org/Links/tutorials_toc.html > HTH. -- SB ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Substiotution of tabs with spaces... 2005-04-17 20:05 ` Steinar Børmer @ 2005-04-17 21:18 ` Peter Dyballa 2005-04-17 21:50 ` Peter Dyballa [not found] ` <mailman.1796.1113775705.2895.help-gnu-emacs@gnu.org> 2 siblings, 0 replies; 14+ messages in thread From: Peter Dyballa @ 2005-04-17 21:18 UTC (permalink / raw) Cc: help-gnu-emacs Am 17.04.2005 um 22:05 schrieb Steinar Børmer: > Stefan Monnier wrote: > > | Look for Kai's tutorial on TAB and other key bindings. > > These can be hard to find, as most of the links I've come across are > dead. (Kai, are you reading this?) However, I was able to locate them > on the XEmacs web site: > > <URL: http://www.xemacs.org/Links/tutorials_toc.html > Here is a second place to read (could be to download/checkout too): http://cvs.sourceforge.net/viewcvs.py/*checkout*/xemacs/xemacsweb/ Links/Attic/tutorials_toc.html?content-type=text%2Fplain -- Greetings Pete ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Substiotution of tabs with spaces... 2005-04-17 20:05 ` Steinar Børmer 2005-04-17 21:18 ` Peter Dyballa @ 2005-04-17 21:50 ` Peter Dyballa [not found] ` <mailman.1796.1113775705.2895.help-gnu-emacs@gnu.org> 2 siblings, 0 replies; 14+ messages in thread From: Peter Dyballa @ 2005-04-17 21:50 UTC (permalink / raw) Cc: help-gnu-emacs Am 17.04.2005 um 22:05 schrieb Steinar Børmer: > <URL: http://www.xemacs.org/Links/tutorials_toc.html > I think that is the new URL to the tutorials at the University in Duisburg: ftp://ftp.is.informatik.uni-duisburg.de/pub/src/emacs/tutorials/. I found it from the GNUS home page http://my.gnus.org/. -- Greetings Pete ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <mailman.1796.1113775705.2895.help-gnu-emacs@gnu.org>]
* Re: Substiotution of tabs with spaces... [not found] ` <mailman.1796.1113775705.2895.help-gnu-emacs@gnu.org> @ 2005-04-18 6:39 ` Steinar Børmer 0 siblings, 0 replies; 14+ messages in thread From: Steinar Børmer @ 2005-04-18 6:39 UTC (permalink / raw) Peter Dyballa wrote: | I think that is the new URL to the tutorials at the University in | Duisburg: | ftp://ftp.is.informatik.uni-duisburg.de/pub/src/emacs/tutorials/. I | found it from the GNUS home page http://my.gnus.org/. I think a lot of people who don't use Gnus would benefit from reading these. Google doesn't find the URL you mention. Seeing how the XEmacs community obviously appreciates these, I think GNU Emacs users should have the same opportunity to read them. I've added this new URL to the EmacsWiki so that it's at least a bit more accessible. <URL: http://www.emacswiki.org/cgi-bin/wiki/OnlineResources > <URL: http://www.emacswiki.org/cgi-bin/wiki/IndentationTutorial > -- SB ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Substiotution of tabs with spaces... [not found] ` <mailman.1631.1113563465.2895.help-gnu-emacs@gnu.org> 2005-04-15 13:15 ` Pascal Bourguignon @ 2005-04-18 0:03 ` Quokka 1 sibling, 0 replies; 14+ messages in thread From: Quokka @ 2005-04-18 0:03 UTC (permalink / raw) Peter Dyballa wrote: > > Am 15.04.2005 um 11:06 schrieb luca.spinacci@seleniacomms.com: > >> is there a smart way to replace all tabs with 3 spaces in a buffer edited >> > > How about: replace-regexp RET TAB + RET SPC SPC SPC RET ? > Or: replace-string RET TAB RET SPC SPC SPC RET ? Mark the whole buffer then M-x untabify RET OR (defun untabify-buffer () "Untabifies entire buffer." (interactive) (save-excursion (untabify (point-min) (point-max)))) Paul ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <mailman.1624.1113556776.2895.help-gnu-emacs@gnu.org>]
* Re: Substiotution of tabs with spaces... [not found] <mailman.1624.1113556776.2895.help-gnu-emacs@gnu.org> @ 2005-04-15 10:52 ` Pascal Bourguignon 2005-04-15 19:55 ` Alan Mackenzie 1 sibling, 0 replies; 14+ messages in thread From: Pascal Bourguignon @ 2005-04-15 10:52 UTC (permalink / raw) luca.spinacci@seleniacomms.com writes: > Hi, > is there a smart way to replace all tabs with 3 spaces in a buffer edited > in c-mode > (both comments and code lines) C-x h M-| expand -3 RET -- __Pascal Bourguignon__ http://www.informatimago.com/ Nobody can fix the economy. Nobody can be trusted with their finger on the button. Nobody's perfect. VOTE FOR NOBODY. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Substiotution of tabs with spaces... [not found] <mailman.1624.1113556776.2895.help-gnu-emacs@gnu.org> 2005-04-15 10:52 ` Pascal Bourguignon @ 2005-04-15 19:55 ` Alan Mackenzie 1 sibling, 0 replies; 14+ messages in thread From: Alan Mackenzie @ 2005-04-15 19:55 UTC (permalink / raw) luca.spinacci@seleniacomms.com wrote on Fri, 15 Apr 2005 11:06:02 +0200: > Hi, > is there a smart way to replace all tabs with 3 spaces in a buffer edited > in c-mode > (both comments and code lines) Yes, but that might not be what you really want. Assuming you've got tab-width set to 3, a tab extends to the next column which is a multiple of 3. So if you had this in a buffer a<tab>b it would look like this: a b If you replaced the tab with three spaces, you'd end up with this a b. I suggest you do this: C-x h (to mark the entire buffer) followed by M-x untabify. > Thank you very much. And the best of luck! -- Alan Mackenzie (Munich, Germany) Email: aacm@muuc.dee; to decode, wherever there is a repeated letter (like "aa"), remove half of them (leaving, say, "a"). ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2005-04-18 6:39 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-04-15 9:06 Substiotution of tabs with spaces luca.spinacci 2005-04-15 11:10 ` Peter Dyballa [not found] ` <mailman.1631.1113563465.2895.help-gnu-emacs@gnu.org> 2005-04-15 13:15 ` Pascal Bourguignon 2005-04-15 22:49 ` Peter Dyballa [not found] ` <mailman.1690.1113606252.2895.help-gnu-emacs@gnu.org> 2005-04-15 23:38 ` Pascal Bourguignon 2005-04-17 21:42 ` Peter Dyballa 2005-04-16 4:16 ` Stefan Monnier 2005-04-17 20:05 ` Steinar Børmer 2005-04-17 21:18 ` Peter Dyballa 2005-04-17 21:50 ` Peter Dyballa [not found] ` <mailman.1796.1113775705.2895.help-gnu-emacs@gnu.org> 2005-04-18 6:39 ` Steinar Børmer 2005-04-18 0:03 ` Quokka [not found] <mailman.1624.1113556776.2895.help-gnu-emacs@gnu.org> 2005-04-15 10:52 ` Pascal Bourguignon 2005-04-15 19:55 ` Alan Mackenzie
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).