benjamwelker wrote: > I have a macro set up on my F2 key in my other editor that does the > following: > changes the filetype to unix (changes line endings from whatever to > unix) > removes trailing whitespace > converts leading whitespace to tabs based on tabstop length > saves the file
Here are some comments on some of the issues: " remove all trailing whitespace execute "%s/\s$//g" Vim script is simply commands that have a colon prefix, so you could type ":w newfile.txt" and a script could contain: w newfile.txt You need "execute" to build commands: let myvar = 'newfile.txt' ... execute 'w '.myvar In your above regex, you need \+ (one or more), and you do not need the "execute", so it is: %s/\s\+$//ge The 'e' means no error is reported if no trailing whitespace is found (you do not need the 'g' but it doesn't hurt). A mapping is a command, and multiple commands can be entered, separated by '|'. If you want the '|' in the mapping, you need to use '<Bar>'. Quick example: map <F2> :%s/\r/\r/ge<Bar>%s/\s\+$//e<CR> You need <CR> so the command is actually executed. Have a look at the following for entabbing indents: http://vim.wikia.com/wiki/Super_retab John --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
