-
Uses native vim regexes (which are slightly different from the regexes used by grep, ack, ag, etc) so the patterns are the same as with vim's within-file search patterns.
You can do a normal within-file search first, then re-use the same pattern to
"""This is done with the os module, which has lots of methods for handling files and dirs. | |
<http://docs.python.org/lib/os-file-dir.html> | |
Effbot's page on the os module: <http://effbot.org/librarybook/os.htm> | |
The shutil module is useful here also: <http://docs.python.org/lib/module-shutil.html> | |
""" | |
import os |
def format_filename(s): | |
"""Take a string and return a valid filename constructed from the string. | |
Uses a whitelist approach: any characters not present in valid_chars are | |
removed. Also spaces are replaced with underscores. | |
Note: this method may produce invalid filenames such as ``, `.` or `..` | |
When I use this method I prepend a date string like '2009_01_15_19_46_32_' | |
and append a file extension like '.txt', so I avoid the potential of using | |
an invalid filename. | |
Uses native vim regexes (which are slightly different from the regexes used by grep, ack, ag, etc) so the patterns are the same as with vim's within-file search patterns.
You can do a normal within-file search first, then re-use the same pattern to
See also:
vinegar.vim, which makes - open netrw in the directory of the current file, with the cursor on the current file (and pressing - again goes up a directory). Vinegar also hides a bunch of junk that's normally at the top of netrw windows, changes the default order of files, and hides files that match wildignore
.
With vinegar, . in netrw opens Vim's command line with the path to the file under the cursor at the end of the command. ! does the same but also prepends !
at the start of the command. y. copies the absolute path of the file under the cursor. ~ goes to your home dir. Ctrl+6 goes back to the file (buffer) that you had open before you opened netrw.
To launch netrw: