Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Word wrap and horizontal scrolling

84 views
Skip to first unread message

Alexander Stepanov

unread,
Mar 13, 2011, 11:53:37 AM3/13/11
to
I am still trying to make emacs work as usual Windows text editor such
as Notepad++ and MS Visual Studio. I can turn off word wrap in Notepad+
+ and it will show horizontal scrollbar. To do such in emacs i must
input M-x toggle-truncate-lines and scroll to the left and to the
right using C-PgDn and C-PgUp. But this method scrolls code with too
big offset. For example my current task at work is to make some
changes in such code:
if(...){
if(...){
if(...){
...
}
else{
if(...){
if(...){
if(...){
else{
if(...){
}
else{
I can edit this code in Notepad++. But Emacs wrap lines. When i turn
of line wrapping C-PgDn moves me to the last if and C-PgUp moves me to
the first if. If I want to edit center part of code I move using left
and write arrows at the keyboard. This Emacs behaviour is shameful. Is
there some way to emulate horizontal scrollbar?

Yuri Khan

unread,
Mar 14, 2011, 12:48:11 AM3/14/11
to Alexander Stepanov
On Sun, Mar 13, 2011 at 21:53, Alexander Stepanov <dark...@gmail.com> wrote:
> I am still trying to make emacs work as usual Windows text editor such
> as Notepad++ and MS Visual Studio. I can turn off word wrap in Notepad+
> + and it will show horizontal scrollbar. To do such in emacs i must
> input M-x toggle-truncate-lines and scroll to the left and to the
> right using C-PgDn and C-PgUp. But this method scrolls code with too
> big offset.

You can press C-h k C-PgDn and learn that scroll-left accepts an
optional argument that specifies how much to scroll, and that the
default is window width minus two. Then, you have options.

Firstly, you can specify this argument each time you use scroll-left:
C-u 20 C-PgDn will scroll by 20 columns.

Alternatively, you can write your own version with a different default
and bind it to C-PgDn:

(defun my-scroll-left (&optional arg set-minimum)
(interactive "P")
(scroll-left (or arg 4) set-minimum))
(global-set-key (kbd "C-<next>") 'my-scroll-left)

Le Wang

unread,
Mar 14, 2011, 1:58:09 AM3/14/11
to Alexander Stepanov, help-gn...@gnu.org
I agree that the lack of horizontal scroll-bar is _ridiculous_, perhaps even shameful :).  When I switched from XEmacs to GNU Emacs, this worried me.  However, having used GNU Emacs for a few years now, I just don't find myself missing it.

I stay away from scroll-left and scroll-right as they confuse the hell out of me -- how is the cursor being off the screen helpful to anyone?  Which is why it's disabled by default, I presume.

Just move the point(cursor) across the long line and let auto-horizontal-scroll take care of the scrolling.  It's not a big deal.  Maybe you're hesitant because you want to leave the point at an interesting location?  You can save the location of the point in Emacs by pressing C-SPC.  When want to go back just press C-u C-SPC.

If you don't want to "plan ahead" by saving interesting points to the mark-ring, I strongly suggest you take a look at the C-xC-/ feature of "session.el" that I discussed in the "_under publicized_ features thread.

--
Le

Alexander Stepanov

unread,
Mar 31, 2011, 1:54:52 AM3/31/11
to
thanks
0 new messages