Vim Help for deleting text
Hello, I would like to remove everything after a text highlight in a line for all the lines in a file. What are the commands to be used in Vim. I would appreciate your help. 00,000,00 00,000,00 I want to remove everything after "," for all the lines. Regards, Auro Ashish Saha.
Re: Vim Help for deleting text
I would like to remove everything after a text highlight in a line for all the lines in a file. What are the commands to be used in Vim. I would appreciate your help. 00,000,00 00,000,00 I want to remove everything after "," for all the lines. You have two commas...if you want to delete everything after the first comma, you can use :%s/,.*/, If you want to delete everything after the first comma *including* the comma, you can use :%s/,.* If you want to delete everything after the 2nd comma, you can use :%s/,[^,]*,\zs.*/ And if you want to delete everything after the 2nd comma (but including the comma, you can just use :%s/,[^,]*\zs,.*/ Or, if all your columns align, you can use visual-block mode with control+V to create a block across the characters in question, and then just hit "d" to delete. I'm sure there are plenty of other ways to do it, but that should get you started. -tim
Re: Vim Help for deleting text
Tim Chase wrote on 19/03/2007 23:01: > > Or, if all your columns align, you can use visual-block mode with > control+V to create a block across the characters in question, and then > just hit "d" to delete. > > -tim > Sorry, I'm begginer with VIM (under Windows XP). When I want to select a block with my mouse, I can't select column block. How can I switch to line mode to column mode? > >
Re: Vim Help for deleting text
Tim Chase wrote on 19/03/2007 23:01: > > Or, if all your columns align, you can use visual-block mode with > control+V to create a block across the characters in question, and then > just hit "d" to delete. > > -tim > Sorry, I'm begginer with VIM (Windows XP). When I want to select a block with my mouse, I can't select column block. How can I switch to line mode to column mode? -- Reclaim Your Inbox! http://www.mozilla.org/products/thunderbird
Re: Vim Help for deleting text
Arnaud Bourree wrote on 20/03/2007 10:22: > > Tim Chase wrote on 19/03/2007 23:01: >> Or, if all your columns align, you can use visual-block mode with >> control+V to create a block across the characters in question, and then >> just hit "d" to delete. >> >> -tim >> > Sorry, I'm begginer with VIM (Windows XP). > When I want to select a block with my mouse, I can't select column block. > How can I switch to line mode to column mode? > I reply myself with help file content: Since CTRL-V is used to paste, you can't use it to start a blockwise Visual selection. You can use CTRL-Q instead. You can also use CTRL-Q in Insert mode and Command-line mode to get the old meaning of CTRL-V. But CTRL-Q doesn't work for terminals when it's used for control flow. -- Reclaim Your Inbox! http://www.mozilla.org/products/thunderbird
Re: Vim Help for deleting text
Arnaud Bourree schrieb: Arnaud Bourree wrote on 20/03/2007 10:22: Tim Chase wrote on 19/03/2007 23:01: Or, if all your columns align, you can use visual-block mode with control+V to create a block across the characters in question, and then just hit "d" to delete. -tim Sorry, I'm begginer with VIM (Windows XP). When I want to select a block with my mouse, I can't select column block. How can I switch to line mode to column mode? I reply myself with help file content: Since CTRL-V is used to paste, you can't use it to start a blockwise Visual selection. You can use CTRL-Q instead. You can also use CTRL-Q in Insert mode and Command-line mode to get the old meaning of CTRL-V. But CTRL-Q doesn't work for terminals when it's used for control flow. If you're happy with the current setting of Ctrl-V, try the following: First select text characterwise with your mouse, then open context menu -> Select Blockwise or Press the Alt key while making your selection (e.g. place cursor, press and hold down Alt, click end of selection) or use a map like the following in your vimrc to make "v" toggle visual mode between characterwise and blockwise: :vno v :exe"norm!"visualmode()==#"v"?"gv\c-v>":"gvv" Andy -- EOM ___ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de