abstract
| - Here is the usage of $c: Imagine you are editing "~/Desktop/project/view/core/admin/MenuEdit.tmpl" and the cwd (current working directory) is "~/Desktop/project". Now imagine that you need to edit something else in the MenuEdit directory (admin dir), but you don't want to change the cwd. Then you go to the Vim commandline and press $c, and it will transform to "e ~/Desktop/project/view/core/admin/". That is, the $c expands to "e " + the directory of the current file. I also found out that I sometimes needed to go to a parent directory from the commandline and I found it really tiring to use backspace. Here is the usage of : Imagine you are editing "~/Desktop/project/view/core/admin/MenuEdit.tmpl" and you would like to step to core/ directory to edit a file there. Enter commandline and press $c, then press , your commandline should then be "e ~/Desktop/project/view/core/". That is, the on commandline deletes text till last slash. Why use this? It's nice to have when working on bigger projects. It's especially useful for MVC (model, view and controller) kind of applications where the different parts are split into different directories. It's also useful in Java applications where you have source in one directory and tests in another. func! Cwd() let cwd = getcwd() return "e " . cwd endfunc func! DeleteTillSlash() let cmd = getcmdline() let cmd_edited = substitute(cmd, "\\(.*/\\).*", "\\1", "") if cmd == cmd_edited let cmd_edited = substitute(cmd, "\\(.*/\\).*/", "\\1", "") endif return cmd_edited endfunc func! CurrentFileDir() return "e " . expand("%:p:h") . "/" endfunc cno $c e eCurrentFileDir() cmap eDeleteTillSlash()
|