How to wrap sentences?
I frequently copy and paste text from web pages and would like to break lines at (say) 72 without splitting words. My preference is to do this either on the command line or by ESC :command vim wrapmargin=40 testfile does not work. The best thing I've seen so far is, in vi :set wm=0 or :set wm=5 both of which cause vi to wrap lines at 0 or 5 characters from the _right_ margin which comes to a maximum line of 62 which is a little small. I've also tried set tw=nn which doesn't seem to do anything. I can't seem to find the appropriate command either on line of using my favorite reference O'Reilly's VI Editor Pocket Reference. Could someone help me? Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Re: How to wrap sentences?
Larry Alkoff wrote: I frequently copy and paste text from web pages and would like to break lines at (say) 72 without splitting words. My preference is to do this either on the command line or by ESC :command I've read the post in the thread auto-wrapping text by A.J.Mechelynck in which he suggests gggqG but I can't see how to do this from either command line or EX command. vim wrapmargin=40 testfile does not work. The best thing I've seen so far is, in vi :set wm=0 or :set wm=5 both of which cause vi to wrap lines at 0 or 5 characters from the _right_ margin which comes to a maximum line of 62 which is a little small. I've also tried set tw=nn which doesn't seem to do anything. I can't seem to find the appropriate command either on line of using my favorite reference O'Reilly's VI Editor Pocket Reference. Could someone help me? Larry Following up on the above post I have found that the command :set textwidth=72 does what I want. Is there any way I can do this when I invoke vim for the purpose of pasting in text from websites? My present .vimrc contains the lines: autocmd FileType text setlocal textwidth=78 which doesn't appear to work when pasting text. Maybe the line should be a simple textwidth=72 ?? Looking at the book VI Improved Vim it appears that I could have a special .vimrc called .vimrcp which would be my normal .vimrc with the line above changed to textwidth=72 and vim would be invoked with the alias alias vimpaste='-u .vimrcp' I'll try this tomorrow. Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Re: How to wrap sentences?
I'm posting the solution to my own question from experiments tonight. To easily force VIM to paste text wrapped at 72 characters do the following: 1. Copy the old ~/.vimrc to ~/.vimrcp 2. Edit ~/.vimrcp and comment out the existing line autocmd FileType text setlocal textwidth=78 and replace it with the line set textwidth=72 This was messing up the paste for unknown reasons. 3. Create an alias in ~/.bashrc or in my case /etc/bashrc for text pasting use. alias vip='vim -u /home/lba/.vimrcp' 4a. When you wish to copy and paste text from a web site simply invoke: vip name_of_file and the text will always be wrapped at 72. 4b. Otherwise vim will work in the normal way with ~/.vimrc. Thanks Russell Bateman for your reply although I found a different way. Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Re: Howto stop display of title, line # from a cntrl-G ?
Tim Chase wrote: While learning vim 4.6.2 I typed a control-G to display the name of the file, number of lines and characters on the bottom. As Yakov mentioned, it's not a separate mode but just a visual artifact. You can use control-L to refresh/redraw the screen and it should clear any such artifacts. -tim Thanks Tim and Yakov. I'm getting the hang of it - slowly. Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Howto stop display of title, line # from a cntrl-G ?
While learning vim 4.6.2 I typed a control-G to display the name of the file, number of lines and characters on the bottom. What is the command to get out of that mode? Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Re: Is _every_ command starting with a colon an ex command?
Tim Chase wrote: Normal mode (sometimes called Command mode) is when hittinh h j k l will go one character cell left, down, up or right, respectively. Command-LINE mode is what you enter by hitting : and quit by hitting Enter (to execute a command) or Esc (to abandon what you were typing on the command-line at the bottom of the Vim screen). Just to further muddy the waters... :) Command-line mode is entered with a colon to get into ex mode, but can also be entered into via / or ? to search. One can also enter a pseudo-command-line mode by attempting to insert the contents of the expression register (control+R followed by =) Somewhat irksomely, it's difficult to discern between these, so if you want a mapping that only applies on the Ex command-line, but that doesn't apply in the others, you have to fiddle with mappings dynamically. I've experienced this most when wanting to remap CR upon searching. To do as much, one has to create a mapping that does the following 1) create a cnoremap for cr to do what one wants and then once done, deletes these 3 temporary cnoremap mappings. 2) create a cnoremap for esc and for control+C to clean up the 3 temporary mappings and 3) then issues the / or ? as asked for. It would be handy to have a exnoremap and searchnoremap command for mappings that would only apply in only when command-line mode was entered via that particular means (the former, via the colon, and the latter, via a / or ?). Just more ramble for ya'll. :) -tim tim I thank you but all I can say is 'eek' g -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Is _every_ command starting with a colon an ex command?
I know every ex command starts with a colon. Is the reverse true in every case? Is _every_ command that starts with a colon an ex command? Examples :help Is this an ex command? :versionIs this? :blahblah This? Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Re: Is _every_ command starting with a colon an ex command?
Tim Chase wrote: I know every ex command starts with a colon. Is the reverse true in every case? Is _every_ command that starts with a colon an ex command? Examples :help Is this an ex command? :versionIs this? :blahblah This? My understanding is that _yes_, typing the colon temporarily enters ex mode for one command. To try things out, you can use Q to enter actual ex mode (use vi to re-enter visual mode). There may be some caveats, such as in general, one can do :g/regexp/ex-command However, while :g is an ex command, it can't be nested within an outer :g command (as noted in the help). There may be a distinction between what vim treats as 'ex' mode and what classic vi/ex supports, but this might be changeable by the 'cp' option to ensure compatibility with old vi/ex. Pretty much any command you can use in ex mode, one can also use in scripts (and vice-versa) which makes for some very powerful vim-script actions. With further information about what you're trying to do, it might shed light on small nuances of difference, but for the most part, one can assume that if it starts with a colon, it's an ex command. -tim Thanks Tim, Yakov and Martin. I'll just ASSume from now on that, if it starts with a colon, it may as be an ex command. Very interesting information on the use of ex. Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Re: Is _every_ command starting with a colon an ex command?
A.J.Mechelynck wrote: Thanks Tim, Yakov and Martin. I'll just ASSume from now on that, if it starts with a colon, it may as be an ex command. Very interesting information on the use of ex. Larry Vhat Vim calls ex-commands are prefixed by a colon when typed at the command-line (the colon is actually used to go from Normal mode to Command-line mode). There are more of them than what was originally valid in the ex program; and you can even define your own (using the :command command). In scripts, or after another command like :vertical, :botright, :browse, :verbose, :autocommand EventName *, etc., the colon is not necessary: e.g. :vert split foobar.txt :bot help pattern-overview :verbose set guifont? :browse edit :au VimLeave * set verbose=0 :if has(gui_running) | set lines= columns= | endif The commands split foobar.txt help pattern-overview set guifont? edit set verbose=0 set lines= columns= endif are ex-commands, which don't need a colon because there is something before them on the same command-line. (Note that :if and :endif, when typed at the command-line, should be on the same line as above) Best regards, Tony. Thanks for your (as usual) very good information Tony. I had thought Normal and Command mode was two names for the same thing. Are you saying that Command mode is ex mode? What do you mean by something before them when using the split command? I have always typed ':sp foobar'. Are you saying that is not necessary or (shudder) wrong? How can I redirect the very long list of ex commands to a file? :he ex-cmd-index file doesn't work. Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Re: entering copied text into command mode?
Erlend Hamberg wrote: On Friday 16 February 2007, A.J.Mechelynck wrote: Maybe -- I've never understood how to properly use the * register under X11. What comes from Edit = Copy (or Ctrl-C) in some non-Vim program arrives in the + register in gvim, and what I yank into the + register in gvim is available for Edit = Paste (or Ctrl-V) in any non-Vim program -- those I can understand. In short: X has, in addition to the regular clipboard, a selection buffer. When you copy/cut text, it is placed in the clipboard (register + in vim). When you select text with the mouse it's placed in the selection buffer (register * in vim) without touching the clipboard. I've been following this discussion and trying various things but still can't get the hang of pasting in from other X programs. So far the only thing that works is to use the mouse to select and copy with left click which allows me to paste in vim with xterm menu - edit - paste. Presumably this uses the vim + register. I understand that copies elsewhere in X load the + register in vim and mouse select loads the * register. What doesn't seem to work is to paste + or * register stuff into vim. Could I see some specific examples? Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Missing configuration commands in vim 7?
I have a desktop and newly configured laptop with different versions of vim. The desktop has vim 6.4.6 which contains the lines in ~/.vimrc set mouse=a syntax on They show in :help The laptop has vim 7.0.35 and gives an error on the above two vimrc commands. Also they don't show in :help. What has happened in vim 7? Are there replacements for syntax on and set mouse? Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Re: Missing configuration commands in vim 7?
Charles E Campbell Jr wrote: Larry Alkoff wrote: I have a desktop and newly configured laptop with different versions of vim. The desktop has vim 6.4.6 which contains the lines in ~/.vimrc set mouse=a syntax on They show in :help The laptop has vim 7.0.35 and gives an error on the above two vimrc commands. Also they don't show in :help. What has happened in vim 7? Are there replacements for syntax on and set mouse? These commands are fine. So, bring up your new vim and type: :version What does that show? Regards, Chip Campbell Hello Chip. :version shows 7.0 The error I get is: [EMAIL PROTECTED] X11 # vi xorg.conf Error detected while processing /home/lba/.vimrc: line 52: E319: Sorry, the command is not available in this version: syntax on line 121: E538: No mouse support: mouse=a Press ENTER or type command to continue Where line 52 says: syntax on and line 121 says: set mouse=a Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Re: Missing configuration commands in vim 7?
A.J.Mechelynck wrote: Larry Alkoff wrote: Charles E Campbell Jr wrote: Larry Alkoff wrote: I have a desktop and newly configured laptop with different versions of vim. The desktop has vim 6.4.6 which contains the lines in ~/.vimrc set mouse=a syntax on They show in :help The laptop has vim 7.0.35 and gives an error on the above two vimrc commands. Also they don't show in :help. What has happened in vim 7? Are there replacements for syntax on and set mouse? These commands are fine. So, bring up your new vim and type: :version What does that show? Regards, Chip Campbell Hello Chip. :version shows 7.0 It ought to show about a page of info. See at bottom for instance what mine displays. The error I get is: [EMAIL PROTECTED] X11 # vi xorg.conf Error detected while processing /home/lba/.vimrc: line 52: E319: Sorry, the command is not available in this version: syntax on line 121: E538: No mouse support: mouse=a Press ENTER or type command to continue Where line 52 says: syntax on and line 121 says: set mouse=a Larry My vim is from Kubuntu Edgy Eft. It would be surprising if they crippled the help. Here is my :version. I thought you only wanted the version number - sorry. :version VIM - Vi IMproved 6.4 (2005 Oct 15, compiled May 23 2006 12:03:57) Included patches: 1-6 Compiled by [EMAIL PROTECTED] Big version without GUI. Features included (+) or not (-): +arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent -clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +cryptv +cscope +dialog_con +diff +digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap +menu +mksession +modify_fname +mouse -mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm +mouse_netterm +mouse_xterm +multi_byte +multi_lang -netbeans_intg -osfiletype +path_extra -perl +postscript +printer -python +quickfix +rightleft -ruby +scrollbind +signs +smartindent -sniff +statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp -xterm_clipboard -xterm_save system vimrc file: $VIM/vimrc user vimrc file: $HOME/.vimrc user exrc file: $HOME/.exrc fall-back for $VIM: /usr/share/vim Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -Wall Linking: gcc -L/usr/local/lib -o vim -lncurses -lgpm Hit ENTER or type command to continue I've tried various things to continue the listing but it always goes back to the main editing screen. Please tell me how to see the rest of it. Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
How to get destructive backspace in command mode?
What is the proper way to have a destructive backspace key in command mode that works like the X key in vim version 6.4.6. That is, the backspace key should move to the left and delete the character there. Currently my backspace key backspaces but does not delete the character to the left. All other programs in my Kubuntu 6.10 work properly. Insert mode works correctly. Is it possible to 'alias' the X key to backspace? I do not want to change any Linix config files except .vimrc to prevent unwanted side effects. Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Re: How to get destructive backspace in command mode?
Tim Chase wrote: What is the proper way to have a destructive backspace key in command mode that works like the X key in vim version 6.4.6. That is, the backspace key should move to the left and delete the character there. Currently my backspace key backspaces but does not delete the character to the left. All other programs in my Kubuntu 6.10 work properly. Insert mode works correctly. Is it possible to 'alias' the X key to backspace? I do not want to change any Linix config files except .vimrc You can easily add the following line to your .vimrc: nnoremap bs X (typed literally with greater-than and less-than signs) which will do exactly as you describe, aliasing the backspace key to behave like X. This is actually described here: :help bs You can learn more about vim's remapping abilities here: :help :map and more about the key-notation used: :help Thanks for your very prompt reply Tim. After putting 'nnoremap bs X in ~.vimrc I see that backspace works differently than X. X will move the cursor left, deleting the character that was there, and 'pulling' all the text that was to the right over one character. Backspace now deletes the character to the left and 'pulls' the text, but the cursor does not move. The result is that repeated backspaces now delete text to the _right_ instead of to the _left_ as X does. This is quite unnerving to a longtime 'deleter' g I read the three :help items you mentioned and tried :set backspace=indent,eol,start and :set backspace=indent,eol,start but neither did want I want. Frankly I didn't understand what :he map was getting at. Is there any way to get the conventional backspace behavior I'm used to? Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Re: How to get destructive backspace in command mode?
Tim Chase wrote: You can easily add the following line to your .vimrc: nnoremap bs X Thanks for your very prompt reply Tim. After putting 'nnoremap bs X in ~.vimrc I see that backspace works differently than X. X will move the cursor left, deleting the character that was there, and 'pulling' all the text that was to the right over one character. Backspace now deletes the character to the left and 'pulls' the text, but the cursor does not move. The result is that repeated backspaces now delete text to the _right_ instead of to the _left_ as X does. It sounds like you might have had a trailing space after the X perhaps? This would move the cursor forward one character after doing what should be the correct behavior. So rather than nnoremap bs X you have nnoremap bs X (note the additional space) You can type it directly at the command-line: :nnoremap bs X and experiment without having to reload vim (to reload your vimrc) each time. This is quite unnerving to a longtime 'deleter' g Understandably :) I read the three :help items you mentioned and tried :set backspace=indent,eol,start This controls the behavior of what to do when you hit the beginning of a line/indentation/start-of-edit which is a handy option to have when you want it, but it sounds like your difficulties lie elsewhere. Frankly I didn't understand what :he map was getting at. It is a somewhat confusing section of the help to understand. It stems partially from the fact that mappings are such powerful things, it's hard to make their description simple. The whole file in which you arrive :help map.txt has volumes of information that elucidate the dark corners of mappings, but perhaps at the cost of clarity. I suspect that an extra trailing-space slipped in, and that its removal should solve your problem, as the mapping worked for me as you want. Yes Tim that's exactly what happened. Got rid of the extraneous character and backspace is working perfectly now. Thanks very much for your help. -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Re: Howto stop Thanks for flying Vim on Konsole Window Titlebar?
Just to wind up the string I started. Titles in vim are now working perfectly. My current ~/.vimrc contains (in part) set title set titleold= set titlestring=VIM:\ %F This works perfectly to display the name of the file I am editing and returns to a standard titlebar display of Shell - Konsole 2 upon exit. It was the titlestring I had to research to get right. Thanks to all for your help. Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Howto stop Thanks for flying Vim on Konsole Window Titlebar?
Whenever I run Vim, the statement Thanks for flying Vim - Shell - Console appears on the Konsole Window Titlebar (the blue one at the top). What is causing this and how can I stop it? Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Re: Howto stop Thanks for flying Vim on Konsole Window Titlebar?
Yakov Lerner wrote: On 9/21/06, Larry Alkoff [EMAIL PROTECTED] wrote: Whenever I run Vim, the statement Thanks for flying Vim - Shell - Console appears on the Konsole Window Titlebar (the blue one at the top). What is causing this and how can I stop it? :he 'title' :he 'titleold' :he 'titlestring' Yakov Thanks Yakow. I had mistakenly 'set title' in ~/.vimrc. Commenting it out fixed the problem. Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux
Re: Howto stop Thanks for flying Vim on Konsole Window Titlebar?
A.J.Mechelynck wrote: Larry Alkoff wrote: Yakov Lerner wrote: On 9/21/06, Larry Alkoff [EMAIL PROTECTED] wrote: Whenever I run Vim, the statement Thanks for flying Vim - Shell - Console appears on the Konsole Window Titlebar (the blue one at the top). What is causing this and how can I stop it? :he 'title' :he 'titleold' :he 'titlestring' Yakov Thanks Yakow. I had mistakenly 'set title' in ~/.vimrc. Commenting it out fixed the problem. Larry It may depend on your Vim version and on your running environment. In my Gnome2 GUI-enabled Vim, I don't set anything but 'title' is set by default in konsole, and it displays, for instance, [No Name] + - VIM - Shell - Konsole where [No Name] changes to the current filename and + appears if the file is 'modified'. I have 'term' and $TERM both set to xterm which ought to mean that the title can be restored. I also have 'ttybuiltin' on (the default) which means that the builtin termcap (which contains a 't_ts' setting for the xterm terminal) will be used in preference to an external termcap or terminfo. In turn, t_ts defined means that (if the value is correct) the window title can be restored. Morality: Leave 'title' 'titleold' 'titlestring' and 'ttybuiltin' at their defaults and you sould have a typical title with the current filename and (if applicable) the servername. (Note: The reason 'ttybuiltin' is on by default is that, according to Bram, many systems have fulty termcaps...) Best regards, Tony. After viewing the entire help file, I'm more confused than ever. In what file should I leave title' 'titleold' 'titlestring' and 'ttybuiltin' at their defaults? I tried putting:he 'title' :he 'titleold' :he 'titlestring' in ~/.vimrc and vim complains when I try to open a file. I'm not sure vim is going to let me edit ~/.vimrc again. Also the help file mentions nothing about something like the above :he 'string' Where do these go? :he means header? I'm using vim 1:6.4-006+2ubuntu under Kubuntu 6.0.6. Larry -- Larry Alkoff N2LA - Austin TX Using Thunderbird on Linux