├── .vimrc ├── README.md ├── vimdo └── vimsed /.vimrc: -------------------------------------------------------------------------------- 1 | " a macro that makes vimdo really easy to use 2 | " simply record a macro with qq and then hit do 3 | " your macro will automatically be saved in ~/vimdo.vim as a 'normal' command 4 | " at that point you can automatically use the same macro to modify any text file by calling the vimdo command: 5 | " vimdo file.txt 6 | map do :split ~/vimdo.vim ggVG"qpinormal :wq 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vimsed # 2 | 3 | The vimsed script makes vim behave kind of like sed. 4 | 5 | ## Syntax: ## 6 | ```sh 7 | vimsed "" 8 | ``` 9 | 10 | vimsed will "pipe" stdin to stdout, modifying it first by running the keystrokes. 11 | 12 | Warning: Uses temporary files `~/vimsedin`, `~/vimsedcmd.vim` and `~/vimsedout`. 13 | 14 | ## Example: ## 15 | 16 | (**Note:** The `"^M"` is a special character, not `^` and `M`. Type `Ctrl-V + Enter` to type it. It stands for a carriage return) 17 | 18 | ```sh 19 | $ vimsed ":s/e/i/g^M" 20 | (user input:) 21 | hello 22 | hello 23 | (Ctrl-D to terminate user input) 24 | (vimsed output:) 25 | hillo 26 | hello 27 | ``` 28 | -------------------------------------------------------------------------------- /vimdo: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | file=$1 4 | cmd=~/vimdo.vim 5 | if [ $# -gt 1 ]; then 6 | cmd=$2 7 | fi 8 | 9 | vim -e -s -c "normal gg0" -c "source $cmd" -c "wq!" "$file" 10 | 11 | -------------------------------------------------------------------------------- /vimsed: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | in=~/.vimsedin 4 | out=~/.vimsedout 5 | cmd=~/.vimsedcmd.vim 6 | 7 | normal=$(echo "gg0$1") 8 | command="normal $normal\nwrite! $out\nquit!" 9 | 10 | cat > $in \ 11 | && echo -e $command > $cmd \ 12 | && vim -e -s -c "so $cmd" $in \ 13 | && cat $out \ 14 | && rm $in $out $cmd 15 | 16 | --------------------------------------------------------------------------------